• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // https://bugs.llvm.org/show_bug.cgi?id=16343
19 
20 #include <cmath>
21 #include <functional>
22 #include <cassert>
23 
24 #include "test_macros.h"
25 
26 struct power
27 {
28   template <typename T>
29   T
operator ()power30   operator()(T a, T b)
31   {
32     return static_cast<T>(std::pow(a, b));
33   }
34 };
35 
36 struct plus_one
37 {
38   template <typename T>
39   T
operator ()plus_one40   operator()(T a)
41   {
42     return a + 1;
43   }
44 };
45 
main(int,char **)46 int main(int, char**)
47 {
48     using std::placeholders::_1;
49 
50     auto g = std::bind(power(), 2, _1);
51     assert(g(5) == 32);
52     assert(std::bind(plus_one(), g)(5) == 33);
53 
54   return 0;
55 }
56