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 template <class R, class F>
21 void
test(F f,R expected)22 test(F f, R expected)
23 {
24 assert(f() == expected);
25 }
26
27 template <class R, class F>
28 void
test_const(const F & f,R expected)29 test_const(const F& f, R expected)
30 {
31 assert(f() == expected);
32 }
33
f()34 int f() {return 1;}
35
36 struct A_int_0
37 {
operator ()A_int_038 int operator()() {return 4;}
operator ()A_int_039 int operator()() const {return 5;}
40 };
41
main()42 int 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