1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // UNSUPPORTED: c++03
10
11 // <functional>
12
13 // template<CopyConstructible Fn, CopyConstructible... Types>
14 // unspecified bind(Fn, Types...);
15 // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
16 // unspecified bind(Fn, Types...);
17
18 #include <functional>
19 #include <cassert>
20
21 #include "test_macros.h"
22
23 template <class R, class F>
24 void
test(F f,R expected)25 test(F f, R expected)
26 {
27 assert(f() == expected);
28 }
29
30 template <class R, class F>
31 void
test_const(const F & f,R expected)32 test_const(const F& f, R expected)
33 {
34 assert(f() == expected);
35 }
36
f()37 int f() {return 1;}
38
39 struct A_int_0
40 {
operator ()A_int_041 int operator()() {return 4;}
operator ()A_int_042 int operator()() const {return 5;}
43 };
44
main(int,char **)45 int main(int, char**)
46 {
47 test(std::bind(f), 1);
48 test(std::bind(&f), 1);
49 test(std::bind(A_int_0()), 4);
50 test_const(std::bind(A_int_0()), 5);
51
52 test(std::bind<int>(f), 1);
53 test(std::bind<int>(&f), 1);
54 test(std::bind<int>(A_int_0()), 4);
55 test_const(std::bind<int>(A_int_0()), 5);
56
57 return 0;
58 }
59