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 // http://llvm.org/bugs/show_bug.cgi?id=16343
18 
19 #include <cmath>
20 #include <functional>
21 #include <cassert>
22 
23 struct power
24 {
25   template <typename T>
26   T
operator ()power27   operator()(T a, T b)
28   {
29     return std::pow(a, b);
30   }
31 };
32 
33 struct plus_one
34 {
35   template <typename T>
36   T
operator ()plus_one37   operator()(T a)
38   {
39     return a + 1;
40   }
41 };
42 
43 int
main()44 main()
45 {
46     using std::placeholders::_1;
47 
48     auto g = std::bind(power(), 2, _1);
49     assert(g(5) == 32);
50     assert(std::bind(plus_one(), g)(5) == 33);
51 }
52