]>
Commit | Line | Data |
---|---|---|
1a669380 | 1 | // { dg-options "-std=gnu++17" } |
2 | // { dg-do compile } | |
3 | ||
fbd26352 | 4 | // Copyright (C) 2016-2019 Free Software Foundation, Inc. |
1a669380 | 5 | // |
6 | // This file is part of the GNU ISO C++ Library. This library is free | |
7 | // software; you can redistribute it and/or modify it under the | |
8 | // terms of the GNU General Public License as published by the | |
9 | // Free Software Foundation; either version 3, or (at your option) | |
10 | // any later version. | |
11 | ||
12 | // This library is distributed in the hope that it will be useful, | |
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | // GNU General Public License for more details. | |
16 | ||
a9aab74c | 17 | // You should have received a copy of the GNU General Public License along |
1a669380 | 18 | // with this library; see the file COPYING3. If not see |
19 | // <http://www.gnu.org/licenses/>. | |
20 | ||
21 | #include <utility> | |
22 | #include <type_traits> | |
23 | #include <testsuite_hooks.h> | |
24 | ||
25 | using std::in_place_t; | |
26 | using std::in_place_type_t; | |
27 | using std::in_place_index_t; | |
28 | ||
29 | float f(in_place_type_t<float>); | |
30 | double f(in_place_type_t<double>); | |
31 | char f(in_place_index_t<0>); | |
32 | unsigned int f(in_place_index_t<1>); | |
33 | int f(in_place_t); | |
34 | ||
ee6c971a | 35 | static_assert(std::is_same<decltype(f(std::in_place)), int>::value); |
36 | static_assert(std::is_same<decltype(f(std::in_place_type<float>)), | |
37 | float>::value); | |
38 | static_assert(std::is_same<decltype(f(std::in_place_type<double>)), | |
39 | double>::value); | |
40 | static_assert(std::is_same<decltype(f(std::in_place_index<0>)), char>::value); | |
41 | static_assert(std::is_same<decltype(f(std::in_place_index<1>)), | |
42 | unsigned int>::value); | |
1a669380 | 43 | |
44 | template <class T, class... Args> float h(in_place_type_t<T>, Args&&...); | |
45 | template <size_t N, class... Args> int h(in_place_index_t<N>, Args&&...); | |
46 | template <class T> double h(in_place_t, T&&); | |
47 | ||
48 | static_assert(std::is_same<decltype(h(std::in_place, 1)), double>::value); | |
ee6c971a | 49 | static_assert(std::is_same<decltype(h(std::in_place_type<float>, 1)), |
50 | float>::value); | |
51 | static_assert(std::is_same<decltype(h(std::in_place_index<0>, 1)), | |
52 | int>::value); |