1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. 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 20 int count = 0; 21 22 template <class F> 23 void 24 test(F f) 25 { 26 int save_count = count; 27 f(); 28 assert(count == save_count + 1); 29 } 30 31 template <class F> 32 void 33 test_const(const F& f) 34 { 35 int save_count = count; 36 f(); 37 assert(count == save_count + 2); 38 } 39 40 void f() {++count;} 41 42 struct A_int_0 43 { 44 void operator()() {++count;} 45 void operator()() const {count += 2;} 46 }; 47 48 int main() 49 { 50 test(std::bind(f)); 51 test(std::bind(&f)); 52 test(std::bind(A_int_0())); 53 test_const(std::bind(A_int_0())); 54 55 test(std::bind<void>(f)); 56 test(std::bind<void>(&f)); 57 test(std::bind<void>(A_int_0())); 58 test_const(std::bind<void>(A_int_0())); 59 } 60