1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
11
12 // <utility>
13
14 // struct in_place_t {
15 // explicit in_place_t() = default;
16 // };
17 // inline constexpr in_place_t in_place{};
18
19 // template <class T>
20 // struct in_place_type_t {
21 // explicit in_place_type_t() = default;
22 // };
23 // template <class T>
24 // inline constexpr in_place_type_t<T> in_place_type{};
25
26 // template <size_t I>
27 // struct in_place_index_t {
28 // explicit in_place_index_t() = default;
29 // };
30 // template <size_t I>
31 // inline constexpr in_place_index_t<I> in_place_index{};
32
33 #include <utility>
34 #include <cassert>
35 #include <memory>
36
37 #include "test_macros.h"
38 #include "type_id.h"
39
40 template <class Tp, class Up>
check_tag(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;
44 }
45
main()46 int main() {
47 // test in_place_t
48 {
49 using T = std::in_place_t;
50 static_assert(check_tag<T>(std::in_place));
51 }
52 // test in_place_type_t
53 {
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>));
62 }
63 // test in_place_index_t
64 {
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)>));
73 }
74 }
75