| 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 |
| 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 |
static_assert(std::is_base_of<std::integral_constant<int, Expected>, std::is_placeholder<T> >::value, ""); |
| 25 |
LIBCPP_STATIC_ASSERT(std::is_base_of<std::integral_constant<int, Expected>, std::is_placeholder<T&> >::value, ""); |
| 26 |
LIBCPP_STATIC_ASSERT(std::is_base_of<std::integral_constant<int, Expected>, std::is_placeholder<const T> >::value, ""); |
| 27 |
LIBCPP_STATIC_ASSERT(std::is_base_of<std::integral_constant<int, Expected>, std::is_placeholder<const T&> >::value, ""); |
| 28 |
|
| 29 |
#if TEST_STD_VER > 14 |
| 30 |
ASSERT_SAME_TYPE(decltype(std::is_placeholder_v<T>), const int); |
| 31 |
static_assert(std::is_placeholder_v<T> == Expected, ""); |
| 32 |
LIBCPP_STATIC_ASSERT(std::is_placeholder_v<T&> == Expected, ""); |
| 33 |
LIBCPP_STATIC_ASSERT(std::is_placeholder_v<const T> == Expected, ""); |
| 34 |
LIBCPP_STATIC_ASSERT(std::is_placeholder_v<const T&> == Expected, ""); |
| 35 |
#endif |
| 36 |
} |
| 37 |
|
| 38 |
struct C {}; |
| 39 |
|
| 40 |
int main(int, char**) |
| 41 |
{ |
| 42 |
test<1>(std::placeholders::_1); |
| 43 |
test<2>(std::placeholders::_2); |
| 44 |
test<3>(std::placeholders::_3); |
| 45 |
test<4>(std::placeholders::_4); |
| 46 |
test<5>(std::placeholders::_5); |
| 47 |
test<6>(std::placeholders::_6); |
| 48 |
test<7>(std::placeholders::_7); |
| 49 |
test<8>(std::placeholders::_8); |
| 50 |
test<9>(std::placeholders::_9); |
| 51 |
test<10>(std::placeholders::_10); |
| 52 |
test<0>(4); |
| 53 |
test<0>(5.5); |
| 54 |
test<0>('a'); |
| 55 |
test<0>(C()); |
| 56 |
|
| 57 |
return 0; |
| 58 |
} |