1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
14 // struct in_place_t {
15 // explicit in_place_t() = default;
17 // inline constexpr in_place_t in_place{};
20 // struct in_place_type_t {
21 // explicit in_place_type_t() = default;
24 // inline constexpr in_place_type_t<T> in_place_type{};
26 // template <size_t I>
27 // struct in_place_index_t {
28 // explicit in_place_index_t() = default;
30 // template <size_t I>
31 // inline constexpr in_place_index_t<I> in_place_index{};
37 #include "test_macros.h"
40 template <class Tp, class Up>
41 constexpr bool check_tag(Up) {
42 return std::is_same<Tp, std::decay_t<Tp>>::value
43 && std::is_same<Tp, Up>::value;
49 using T = std::in_place_t;
50 static_assert(check_tag<T>(std::in_place));
52 // test in_place_type_t
54 using T1 = std::in_place_type_t<void>;
55 using T2 = std::in_place_type_t<int>;
56 using T3 = std::in_place_type_t<const int>;
57 static_assert(!std::is_same<T1, T2>::value && !std::is_same<T1, T3>::value);
58 static_assert(!std::is_same<T2, T3>::value);
59 static_assert(check_tag<T1>(std::in_place_type<void>));
60 static_assert(check_tag<T2>(std::in_place_type<int>));
61 static_assert(check_tag<T3>(std::in_place_type<const int>));
63 // test in_place_index_t
65 using T1 = std::in_place_index_t<0>;
66 using T2 = std::in_place_index_t<1>;
67 using T3 = std::in_place_index_t<static_cast<size_t>(-1)>;
68 static_assert(!std::is_same<T1, T2>::value && !std::is_same<T1, T3>::value);
69 static_assert(!std::is_same<T2, T3>::value);
70 static_assert(check_tag<T1>(std::in_place_index<0>));
71 static_assert(check_tag<T2>(std::in_place_index<1>));
72 static_assert(check_tag<T3>(std::in_place_index<static_cast<size_t>(-1)>));