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 // UNSUPPORTED: c++98, c++03
11 
12 // <functional>
13 
14 // template<CopyConstructible Fn, CopyConstructible... Types>
15 //   unspecified bind(Fn, Types...);
16 // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
17 //   unspecified bind(Fn, Types...);
18 
19 #include <functional>
20 #include <cassert>
21 
22 template <class R, class F>
23 void
test(F f,R expected)24 test(F f, R expected)
25 {
26     assert(f() == expected);
27 }
28 
29 template <class R, class F>
30 void
test_const(const F & f,R expected)31 test_const(const F& f, R expected)
32 {
33     assert(f() == expected);
34 }
35 
f()36 int f() {return 1;}
37 
38 struct A_int_0
39 {
operator ()A_int_040     int operator()() {return 4;}
operator ()A_int_041     int operator()() const {return 5;}
42 };
43 
main()44 int main()
45 {
46     test(std::bind(f), 1);
47     test(std::bind(&f), 1);
48     test(std::bind(A_int_0()), 4);
49     test_const(std::bind(A_int_0()), 5);
50 
51     test(std::bind<int>(f), 1);
52     test(std::bind<int>(&f), 1);
53     test(std::bind<int>(A_int_0()), 4);
54     test_const(std::bind<int>(A_int_0()), 5);
55 }
56