1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11
13 // template<class T> struct is_bind_expression;
14 // A program may specialize this template for a program-defined type T
15 // to have a base characteristic of true_type to indicate that T should
16 // be treated as a subexpression in a bind call.
17 // https://llvm.org/PR51753
21 #include <type_traits>
25 int operator()(int x
, int y
) const { return 10*x
+ y
; }
27 template<> struct std::is_bind_expression
<MyBind
> : std::true_type
{};
32 auto f
= [](auto x
) { return 10*x
+ 9; };
34 auto bound
= std::bind(f
, bindexpr
);
35 assert(bound(7, 8) == 789);
38 auto f
= [](auto x
) { return 10*x
+ 9; };
39 const MyBind bindexpr
;
40 auto bound
= std::bind(f
, bindexpr
);
41 assert(bound(7, 8) == 789);
44 auto f
= [](auto x
) { return 10*x
+ 9; };
46 auto bound
= std::bind(f
, std::move(bindexpr
));
47 assert(bound(7, 8) == 789);
50 auto f
= [](auto x
) { return 10*x
+ 9; };
51 const MyBind bindexpr
;
52 auto bound
= std::bind(f
, std::move(bindexpr
));
53 assert(bound(7, 8) == 789);