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 <cassert> |
20 | #include <functional> |
21 | #include <type_traits> |
22 | #include <utility> |
23 | |
24 | struct My2 {}; |
25 | template<> struct std::is_placeholder<My2> : std::integral_constant<int, 2> {}; |
26 | |
27 | int main(int, char**) |
28 | { |
29 | { |
30 | auto f = [](auto x) { return 10*x + 9; }; |
31 | My2 place; |
32 | auto bound = std::bind(f&: f, args&: place); |
33 | assert(bound(7, 8) == 89); |
34 | } |
35 | { |
36 | auto f = [](auto x) { return 10*x + 9; }; |
37 | const My2 place; |
38 | auto bound = std::bind(f&: f, args: place); |
39 | assert(bound(7, 8) == 89); |
40 | } |
41 | { |
42 | auto f = [](auto x) { return 10*x + 9; }; |
43 | My2 place; |
44 | auto bound = std::bind(f&: f, args: std::move(place)); |
45 | assert(bound(7, 8) == 89); |
46 | } |
47 | { |
48 | auto f = [](auto x) { return 10*x + 9; }; |
49 | const My2 place; |
50 | auto bound = std::bind(f&: f, args: std::move(place)); |
51 | assert(bound(7, 8) == 89); |
52 | } |
53 | |
54 | return 0; |
55 | } |
56 | |