xref: /llvm-project/libcxx/test/std/utilities/function.objects/func.bind_front/bind_front.verify.cpp (revision 9bb9ec380ace81d040d3a0a0a2ae9a75733ab330)
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, c++14, c++17
10 
11 // functional
12 
13 // template <class F, class... Args>
14 // constexpr unspecified bind_front(F&&, Args&&...);
15 
16 #include <functional>
17 
pass(const int n)18 constexpr int pass(const int n) { return n; }
19 
simple(int n)20 int simple(int n) { return n; }
21 
22 template<class T>
do_nothing(T t)23 T do_nothing(T t) { return t; }
24 
25 struct NotMoveConst
26 {
27     NotMoveConst(NotMoveConst &&) = delete;
28     NotMoveConst(NotMoveConst const&) = delete;
29 
NotMoveConstNotMoveConst30     NotMoveConst(int) { }
31 };
32 
testNotMoveConst(NotMoveConst)33 void testNotMoveConst(NotMoveConst) { }
34 
f()35 void f() {
36     int n = 1;
37     const int c = 1;
38 
39     auto p = std::bind_front(pass, c);
40     static_assert(p() == 1); // expected-error {{static assertion expression is not an integral constant expression}}
41 
42     auto d = std::bind_front(do_nothing, n); // expected-error {{no matching function for call to 'bind_front'}}
43 
44     auto t = std::bind_front(testNotMoveConst, NotMoveConst(0)); // expected-error {{no matching function for call to 'bind_front'}}
45 }
46