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, c++11
10 
11 // <functional>
12 
13 // template<class T> struct is_placeholder;
14 //   A program may specialize this template for a program-defined type T
15 //   to have a base characteristic of integral_constant<int, N> with N > 0
16 //   to indicate that T should be treated as a placeholder type.
17 //   https://llvm.org/PR51753
18 
19 #include <functional>
20 #include <cassert>
21 #include <type_traits>
22 
23 struct My2 {};
24 template<> struct std::is_placeholder<My2> : std::integral_constant<int, 2> {};
25 
main(int,char **)26 int main(int, char**)
27 {
28   {
29     auto f = [](auto x) { return 10*x + 9; };
30     My2 place;
31     auto bound = std::bind(f, place);
32     assert(bound(7, 8) == 89);
33   }
34   {
35     auto f = [](auto x) { return 10*x + 9; };
36     const My2 place;
37     auto bound = std::bind(f, place);
38     assert(bound(7, 8) == 89);
39   }
40   {
41     auto f = [](auto x) { return 10*x + 9; };
42     My2 place;
43     auto bound = std::bind(f, std::move(place));
44     assert(bound(7, 8) == 89);
45   }
46   {
47     auto f = [](auto x) { return 10*x + 9; };
48     const My2 place;
49     auto bound = std::bind(f, std::move(place));
50     assert(bound(7, 8) == 89);
51   }
52 
53   return 0;
54 }
55