1 // { dg-options "-std=gnu++20" }
2 // { dg-do compile { target c++20 } }
4 // Copyright (C) 2017-2022 Free Software Foundation, Inc.
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)
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.
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/>.
27 using char_type
= typename
CT::char_type
;
29 // Overlapping strings
30 char_type s1
[3] = {1, 2, 3};
31 CT::move(s1
+1, s1
, 2);
32 if (s1
[0] != char_type
{1} || s1
[1] != char_type
{1} || s1
[2] != char_type
{2})
34 CT::move(s1
, s1
+1, 2);
35 if (s1
[0] != char_type
{1} || s1
[1] != char_type
{2} || s1
[2] != char_type
{2})
39 char_type why_is_six_scared_of_seven
[] = {4, 5, 6};
40 char_type because789
[] = {7, 8, 9};
41 CT::move(why_is_six_scared_of_seven
, because789
, 3);
42 if (why_is_six_scared_of_seven
[0] != char_type
{7}
43 || why_is_six_scared_of_seven
[1] != char_type
{8}
44 || why_is_six_scared_of_seven
[2] != char_type
{9})
50 #ifndef __cpp_lib_constexpr_string
51 # error Feature-test macro for constexpr char_traits is missing
52 #elif __cpp_lib_constexpr_string < 201811
53 # error Feature-test macro for constexpr char_traits has the wrong value
56 // We also provide this non-standard macro for P0426R1 and P1032R1.
57 #ifndef __cpp_lib_constexpr_char_traits
58 # error Feature-test macro for constexpr char_traits is missing
59 #elif __cpp_lib_constexpr_char_traits != 201811
60 # error Feature-test macro for constexpr char_traits has the wrong value
63 static_assert( test_move
<std::char_traits
<char>>() );
64 static_assert( test_move
<std::char_traits
<wchar_t>>() );
65 #ifdef _GLIBCXX_USE_CHAR8_T
66 static_assert( test_move
<std::char_traits
<char8_t
>>() );
68 static_assert( test_move
<std::char_traits
<char16_t
>>() );
69 static_assert( test_move
<std::char_traits
<char32_t
>>() );
71 struct C
{ unsigned char c
; };
72 constexpr bool operator==(const C
& c1
, const C
& c2
) { return c1
.c
== c2
.c
; }
73 constexpr bool operator<(const C
& c1
, const C
& c2
) { return c1
.c
< c2
.c
; }
74 static_assert( test_move
<std::char_traits
<C
>>() );