]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc
libstdc++: Remove unnecessary uses of _GLIBCXX_USE_WCHAR_T in testsuite [PR98725]
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 21_strings / char_traits / requirements / constexpr_functions_c++20.cc
CommitLineData
eb11134d
PK
1// { dg-options "-std=gnu++2a" }
2// { dg-do compile { target c++2a } }
3
99dee823 4// Copyright (C) 2017-2021 Free Software Foundation, Inc.
eb11134d
PK
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
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
20
21#include <string>
22
23template<typename CT>
24 constexpr bool
25 test_move()
26 {
27 using char_type = typename CT::char_type;
28 char_type s1[3] = {1, 2, 3};
29 CT::move(s1+1, s1, 2);
30 return s1[0]==char_type{1} && s1[1]==char_type{1} && s1[2]==char_type{2};
31 }
32
3da80ed7
JW
33#ifndef __cpp_lib_constexpr_string
34# error Feature-test macro for constexpr char_traits is missing
35#elif __cpp_lib_constexpr_string < 201811
36# error Feature-test macro for constexpr char_traits has the wrong value
37#endif
38
39// We also provide this non-standard macro for P0426R1 and P1032R1.
eb11134d
PK
40#ifndef __cpp_lib_constexpr_char_traits
41# error Feature-test macro for constexpr char_traits is missing
b6ab9ecd 42#elif __cpp_lib_constexpr_char_traits != 201811
eb11134d
PK
43# error Feature-test macro for constexpr char_traits has the wrong value
44#endif
45
46static_assert( test_move<std::char_traits<char>>() );
eb11134d 47static_assert( test_move<std::char_traits<wchar_t>>() );
eb11134d
PK
48#ifdef _GLIBCXX_USE_CHAR8_T
49static_assert( test_move<std::char_traits<char8_t>>() );
50#endif
51static_assert( test_move<std::char_traits<char16_t>>() );
52static_assert( test_move<std::char_traits<char32_t>>() );
53
54struct C { unsigned char c; };
55constexpr bool operator==(const C& c1, const C& c2) { return c1.c == c2.c; }
56constexpr bool operator<(const C& c1, const C& c2) { return c1.c < c2.c; }
57static_assert( test_move<std::char_traits<C>>() );