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 // <functional>
10
11 // struct is_placeholder
12
13 #include <functional>
14 #include "test_macros.h"
15
16 template <int Expected, class T>
17 void
test(const T &)18 test(const T&)
19 {
20 static_assert(std::is_placeholder<T>::value == Expected, "");
21 LIBCPP_STATIC_ASSERT(std::is_placeholder<T&>::value == Expected, "");
22 LIBCPP_STATIC_ASSERT(std::is_placeholder<const T>::value == Expected, "");
23 LIBCPP_STATIC_ASSERT(std::is_placeholder<const T&>::value == Expected, "");
24
25 #if TEST_STD_VER > 14
26 static_assert(std::is_placeholder_v<T> == Expected, "");
27 LIBCPP_STATIC_ASSERT(std::is_placeholder_v<T&> == Expected, "");
28 LIBCPP_STATIC_ASSERT(std::is_placeholder_v<const T> == Expected, "");
29 LIBCPP_STATIC_ASSERT(std::is_placeholder_v<const T&> == Expected, "");
30 #endif
31 }
32
33 struct C {};
34
main(int,char **)35 int main(int, char**)
36 {
37 test<1>(std::placeholders::_1);
38 test<2>(std::placeholders::_2);
39 test<3>(std::placeholders::_3);
40 test<4>(std::placeholders::_4);
41 test<5>(std::placeholders::_5);
42 test<6>(std::placeholders::_6);
43 test<7>(std::placeholders::_7);
44 test<8>(std::placeholders::_8);
45 test<9>(std::placeholders::_9);
46 test<10>(std::placeholders::_10);
47 test<0>(4);
48 test<0>(5.5);
49 test<0>('a');
50 test<0>(C());
51
52 return 0;
53 }
54