[MLIR] Fix LLVMIRTransforms build failure (#125485)
[llvm-project.git] / libcxx / test / std / utilities / function.objects / bind / func.bind / func.bind.isbind / specialization.pass.cpp
blob32279ac339298e34407a6a18e36802cc238dd3df
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11
11 // <functional>
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
19 #include <cassert>
20 #include <functional>
21 #include <type_traits>
22 #include <utility>
24 struct MyBind {
25 int operator()(int x, int y) const { return 10*x + y; }
27 template<> struct std::is_bind_expression<MyBind> : std::true_type {};
29 int main(int, char**)
32 auto f = [](auto x) { return 10*x + 9; };
33 MyBind bindexpr;
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; };
45 MyBind bindexpr;
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);
56 return 0;