107a0b0eeSArthur O'Dwyer //===----------------------------------------------------------------------===//
207a0b0eeSArthur O'Dwyer //
307a0b0eeSArthur O'Dwyer // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
407a0b0eeSArthur O'Dwyer // See https://llvm.org/LICENSE.txt for license information.
507a0b0eeSArthur O'Dwyer // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
607a0b0eeSArthur O'Dwyer //
707a0b0eeSArthur O'Dwyer //===----------------------------------------------------------------------===//
807a0b0eeSArthur O'Dwyer 
907a0b0eeSArthur O'Dwyer // <functional>
1007a0b0eeSArthur O'Dwyer 
1107a0b0eeSArthur O'Dwyer // struct is_placeholder
1207a0b0eeSArthur O'Dwyer 
1307a0b0eeSArthur O'Dwyer #include <functional>
14*09e3a360SLouis Dionne #include <type_traits>
15*09e3a360SLouis Dionne 
1607a0b0eeSArthur O'Dwyer #include "test_macros.h"
1707a0b0eeSArthur O'Dwyer 
1807a0b0eeSArthur O'Dwyer template <int Expected, class T>
1907a0b0eeSArthur O'Dwyer void
2007a0b0eeSArthur O'Dwyer test(const T&)
2107a0b0eeSArthur O'Dwyer {
2207a0b0eeSArthur O'Dwyer     static_assert(std::is_placeholder<T>::value == Expected, "");
2307a0b0eeSArthur O'Dwyer     LIBCPP_STATIC_ASSERT(std::is_placeholder<T&>::value == Expected, "");
2407a0b0eeSArthur O'Dwyer     LIBCPP_STATIC_ASSERT(std::is_placeholder<const T>::value == Expected, "");
2507a0b0eeSArthur O'Dwyer     LIBCPP_STATIC_ASSERT(std::is_placeholder<const T&>::value == Expected, "");
26049a3fe1SArthur O'Dwyer     static_assert(std::is_base_of<std::integral_constant<int, Expected>, std::is_placeholder<T> >::value, "");
27049a3fe1SArthur O'Dwyer     LIBCPP_STATIC_ASSERT(std::is_base_of<std::integral_constant<int, Expected>, std::is_placeholder<T&> >::value, "");
28049a3fe1SArthur O'Dwyer     LIBCPP_STATIC_ASSERT(std::is_base_of<std::integral_constant<int, Expected>, std::is_placeholder<const T> >::value, "");
29049a3fe1SArthur O'Dwyer     LIBCPP_STATIC_ASSERT(std::is_base_of<std::integral_constant<int, Expected>, std::is_placeholder<const T&> >::value, "");
3007a0b0eeSArthur O'Dwyer 
3107a0b0eeSArthur O'Dwyer #if TEST_STD_VER > 14
32049a3fe1SArthur O'Dwyer     ASSERT_SAME_TYPE(decltype(std::is_placeholder_v<T>), const int);
3307a0b0eeSArthur O'Dwyer     static_assert(std::is_placeholder_v<T> == Expected, "");
3407a0b0eeSArthur O'Dwyer     LIBCPP_STATIC_ASSERT(std::is_placeholder_v<T&> == Expected, "");
3507a0b0eeSArthur O'Dwyer     LIBCPP_STATIC_ASSERT(std::is_placeholder_v<const T> == Expected, "");
3607a0b0eeSArthur O'Dwyer     LIBCPP_STATIC_ASSERT(std::is_placeholder_v<const T&> == Expected, "");
3707a0b0eeSArthur O'Dwyer #endif
3807a0b0eeSArthur O'Dwyer }
3907a0b0eeSArthur O'Dwyer 
4007a0b0eeSArthur O'Dwyer struct C {};
4107a0b0eeSArthur O'Dwyer 
4207a0b0eeSArthur O'Dwyer int main(int, char**)
4307a0b0eeSArthur O'Dwyer {
4407a0b0eeSArthur O'Dwyer     test<1>(std::placeholders::_1);
4507a0b0eeSArthur O'Dwyer     test<2>(std::placeholders::_2);
4607a0b0eeSArthur O'Dwyer     test<3>(std::placeholders::_3);
4707a0b0eeSArthur O'Dwyer     test<4>(std::placeholders::_4);
4807a0b0eeSArthur O'Dwyer     test<5>(std::placeholders::_5);
4907a0b0eeSArthur O'Dwyer     test<6>(std::placeholders::_6);
5007a0b0eeSArthur O'Dwyer     test<7>(std::placeholders::_7);
5107a0b0eeSArthur O'Dwyer     test<8>(std::placeholders::_8);
5207a0b0eeSArthur O'Dwyer     test<9>(std::placeholders::_9);
5307a0b0eeSArthur O'Dwyer     test<10>(std::placeholders::_10);
5407a0b0eeSArthur O'Dwyer     test<0>(4);
5507a0b0eeSArthur O'Dwyer     test<0>(5.5);
5607a0b0eeSArthur O'Dwyer     test<0>('a');
5707a0b0eeSArthur O'Dwyer     test<0>(C());
5807a0b0eeSArthur O'Dwyer 
5907a0b0eeSArthur O'Dwyer   return 0;
6007a0b0eeSArthur O'Dwyer }
61