1 // Copyright (C) 2017 Free Software Foundation, Inc.
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)
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.
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/>.
18 // { dg-options "-std=gnu++17" }
19 // { dg-do compile { target c++17 } }
22 #include <testsuite_iterators.h>
25 using input_iterator_seq
26 = __gnu_test::test_container
<C
, __gnu_test::input_iterator_wrapper
>;
28 template<typename T
, typename U
> struct require_same
;
29 template<typename T
> struct require_same
<T
, T
> { using type
= void; };
31 template<typename T
, typename U
>
32 typename require_same
<T
, U
>::type
39 std::allocator
<char> a
;
41 std::basic_string s1
= s0
;
42 check_type
<std::string
>(s1
);
44 std::basic_string s2
= std::move(s0
);
45 check_type
<std::string
>(s2
);
47 const std::basic_string s3
= s0
;
48 check_type
<const std::string
>(s3
);
50 const std::basic_string s4
= s3
;
51 check_type
<const std::string
>(s4
);
53 #if _GLIBCXX_USE_CXX11_ABI
54 std::basic_string
s5(s0
, a
);
55 check_type
<std::string
>(s5
);
57 std::basic_string
s6(std::move(s0
), a
);
58 check_type
<std::string
>(s6
);
61 std::basic_string
s7(s0
, 0, 0);
62 check_type
<std::string
>(s7
);
69 input_iterator_seq
<char> seq(a
);
71 std::basic_string
s1(seq
.begin(), seq
.end());
72 check_type
<std::string
>(s1
);
74 std::basic_string
s2(seq
.begin(), seq
.end(), std::allocator
<char>());
75 check_type
<std::string
>(s2
);
77 std::basic_string
s3((char)1, 'a');
78 check_type
<std::string
>(s3
);
80 std::basic_string
s4((char)1, 'a', std::allocator
<char>());
81 check_type
<std::string
>(s4
);
88 input_iterator_seq
<char16_t
> seq(a
);
90 std::basic_string
s1(seq
.begin(), seq
.end());
91 check_type
<std::u16string
>(s1
);
93 std::basic_string
s2(seq
.begin(), seq
.end(), std::allocator
<char16_t
>());
94 check_type
<std::u16string
>(s2
);
96 std::basic_string
s3((char16_t
)1, u
'a');
97 check_type
<std::u16string
>(s3
);
99 std::basic_string
s4((char16_t
)1, u
'a', std::allocator
<char16_t
>());
100 check_type
<std::u16string
>(s4
);
107 input_iterator_seq
<char32_t
> seq(a
);
109 std::basic_string
s1(seq
.begin(), seq
.end());
110 check_type
<std::u32string
>(s1
);
112 std::basic_string
s2(seq
.begin(), seq
.end(), std::allocator
<char32_t
>());
113 check_type
<std::u32string
>(s2
);
115 std::basic_string
s3((char32_t
)1, U
'a');
116 check_type
<std::u32string
>(s3
);
118 std::basic_string
s4((char32_t
)1, U
'a', std::allocator
<char32_t
>());
119 check_type
<std::u32string
>(s4
);