invoke_int_0.pass.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02c
1//===----------------------------------------------------------------------===// 2// 3// ��������������������The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <functional> 11 12// template<CopyConstructible Fn, CopyConstructible... Types> 13// unspecified bind(Fn, Types...); 14// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> 15// unspecified bind(Fn, Types...); 16 17#include <functional> 18#include <cassert> 19 20template <class R, class F> 21void 22test(F f, R expected) 23{ 24 assert(f() == expected); 25} 26 27template <class R, class F> 28void 29test_const(const F& f, R expected) 30{ 31 assert(f() == expected); 32} 33 34int f() {return 1;} 35 36struct A_int_0 37{ 38 int operator()() {return 4;} 39 int operator()() const {return 5;} 40}; 41 42int main() 43{ 44 test(std::bind(f), 1); 45 test(std::bind(&f), 1); 46 test(std::bind(A_int_0()), 4); 47 test_const(std::bind(A_int_0()), 5); 48 49 test(std::bind<int>(f), 1); 50 test(std::bind<int>(&f), 1); 51 test(std::bind<int>(A_int_0()), 4); 52 test_const(std::bind<int>(A_int_0()), 5); 53} 54