]>
Commit | Line | Data |
---|---|---|
7adcbafe | 1 | // Copyright (C) 2015-2022 Free Software Foundation, Inc. |
bd1eb5e0 JW |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
6458742a | 18 | // { dg-do compile { target c++17 } } |
bd1eb5e0 JW |
19 | |
20 | #include <type_traits> | |
21 | ||
22 | #ifndef __cpp_lib_void_t | |
23 | # error "Feature-test macro for void_t missing" | |
24 | #elif __cpp_lib_void_t != 201411 | |
25 | # error "Feature-test macro for void_t has wrong value" | |
26 | #endif | |
27 | ||
28 | static_assert( std::is_same<std::void_t<int, long, double>, void>::value, | |
29 | "void_t is a synonym for void" ); | |
30 | ||
31 | struct X { }; | |
32 | X operator+(const X& x) { return x; } | |
33 | ||
34 | template<typename T, typename U = std::void_t<>> | |
35 | struct has_unary_plus | |
36 | : std::false_type | |
37 | { }; | |
38 | ||
39 | template<typename T> | |
40 | struct has_unary_plus<T, std::void_t<decltype(+std::declval<X>())>> | |
41 | : std::true_type | |
42 | { }; | |
43 | ||
44 | static_assert( has_unary_plus<X>::value, "void_t detects valid expressions" ); |