do_test<char>();
do_test<signed char>();
do_test<unsigned char>();
-#ifdef _GLIBCXX_USE_WCHAR_T
do_test<wchar_t>();
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
do_test<char8_t>();
#endif
DEFINE_EXTREMA(long, LONG_MIN, LONG_MAX);
DEFINE_EXTREMA(unsigned long, 0UL, ULONG_MAX);
-#if _GLIBCXX_USE_WCHAR_T
+#if defined WCHAR_MIN && defined WCHAR_MAX
DEFINE_EXTREMA(wchar_t, WCHAR_MIN, WCHAR_MAX);
-#endif //_GLIBCXX_USE_WCHAR_T
+#endif
DEFINE_EXTREMA(float, FLT_MIN, FLT_MAX);
DEFINE_EXTREMA(double, DBL_MIN, DBL_MAX);
test_extrema<char>();
test_extrema<signed char>();
test_extrema<unsigned char>();
-
+
test_extrema<short>();
test_extrema<unsigned short>();
void
test01(const char* first, const char* last)
{
-#if _GLIBCXX_USE_WCHAR_T
wchar_t wc;
-#else
- enum W { } wc;
-#endif
std::from_chars(first, last, wc); // { dg-error "no matching" }
std::from_chars(first, last, wc, 10); // { dg-error "no matching" }
// { dg-do run { target c++17 } }
#include <functional>
+#include <string_view>
#include <cstring>
#include <cctype>
-#ifdef _GLIBCXX_USE_WCHAR_T
-# include <cwchar>
-#endif
#include <algorithm>
#include <testsuite_hooks.h>
void
test02()
{
-#ifdef _GLIBCXX_USE_WCHAR_T
const wchar_t s[] = { L'a', (wchar_t)-97, L'a', L'\0' };
const wchar_t* needles[] = {
s, L"", L"a", L"aa", L"aaa", L"ab", L"cd", L"abcd", L"abcdabcd", L"abcabcd"
for (auto n : needles)
{
- auto nlen = std::wcslen(n);
+ auto nlen = std::char_traits<wchar_t>::length(n);
auto ne = n + nlen;
default_searcher d(n, ne);
boyer_moore_searcher bm(n, ne);
boyer_moore_horspool_searcher bmh(n, ne);
for (auto h : haystacks)
{
- auto he = h + std::wcslen(h);
+ auto he = h + std::char_traits<wchar_t>::length(h);
auto res = std::search(h, he, n, ne);
auto d_res = d(h, he);
VERIFY( d_res.first == res );
VERIFY( bmh_res.second == (bmh_res.first + nlen) );
}
}
-#endif
}
void
template class std::hash<std::error_condition>;
#endif
-#ifdef _GLIBCXX_USE_WCHAR_T
template class std::hash<wchar_t>;
template class std::hash<std::wstring>;
-#endif
-
static_assert(test_category<is_arithmetic, char>(true), "");
static_assert(test_category<is_arithmetic, signed char>(true), "");
static_assert(test_category<is_arithmetic, unsigned char>(true), "");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(test_category<is_arithmetic, wchar_t>(true), "");
-#endif
static_assert(test_category<is_arithmetic, short>(true), "");
static_assert(test_category<is_arithmetic, unsigned short>(true), "");
static_assert(test_category<is_arithmetic, int>(true), "");
static_assert(test_category<is_compound, char>(false), "");
static_assert(test_category<is_compound, signed char>(false), "");
static_assert(test_category<is_compound, unsigned char>(false), "");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(test_category<is_compound, wchar_t>(false), "");
-#endif
static_assert(test_category<is_compound, short>(false), "");
static_assert(test_category<is_compound, unsigned short>(false), "");
static_assert(test_category<is_compound, int>(false), "");
static_assert(test_category<is_floating_point, char>(false), "");
static_assert(test_category<is_floating_point, signed char>(false), "");
static_assert(test_category<is_floating_point, unsigned char>(false), "");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(test_category<is_floating_point, wchar_t>(false), "");
-#endif
static_assert(test_category<is_floating_point, short>(false), "");
static_assert(test_category<is_floating_point, unsigned short>(false), "");
static_assert(test_category<is_floating_point, int>(false), "");
{
using std::is_fundamental;
using namespace __gnu_test;
-
+
static_assert(test_category<is_fundamental, void>(true), "");
static_assert(test_category<is_fundamental, char>(true), "");
static_assert(test_category<is_fundamental, signed char>(true), "");
static_assert(test_category<is_fundamental, unsigned char>(true), "");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(test_category<is_fundamental, wchar_t>(true), "");
-#endif
static_assert(test_category<is_fundamental, short>(true), "");
static_assert(test_category<is_fundamental, unsigned short>(true), "");
static_assert(test_category<is_fundamental, int>(true), "");
using namespace __gnu_test;
static_assert(test_category<is_integral, void>(false), "");
-
+
static_assert(test_category<is_integral, char>(true), "");
static_assert(test_category<is_integral, signed char>(true), "");
static_assert(test_category<is_integral, unsigned char>(true), "");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(test_category<is_integral, wchar_t>(true), "");
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
static_assert(test_category<is_integral, char8_t>(true), "");
#endif
{
using std::is_signed;
using namespace __gnu_test;
-
+
static_assert(test_category<is_signed, void>(false), "");
-
+
static_assert(test_category<is_signed, char>(char(-1) < char(0)), "");
static_assert(test_category<is_signed, signed char>(true), "");
static_assert(test_category<is_signed, unsigned char>(false), "");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(test_category<is_signed, wchar_t>
(wchar_t(-1) < wchar_t(0)), "");
-#endif
static_assert(test_category<is_signed, short>(true), "");
static_assert(test_category<is_signed, unsigned short>(false), "");
static_assert(test_category<is_signed, int>(true), "");
using namespace __gnu_test;
static_assert(test_category<is_unsigned, void>(false), "");
-
+
static_assert(test_category<is_unsigned, char>(char(-1) > char(0)), "");
static_assert(test_category<is_unsigned, signed char>(false), "");
static_assert(test_category<is_unsigned, unsigned char>(true), "");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(test_category<is_unsigned, wchar_t>
(wchar_t(-1) > wchar_t(0)), "");
-#endif
static_assert(test_category<is_unsigned, short>(false), "");
static_assert(test_category<is_unsigned, unsigned short>(true), "");
static_assert(test_category<is_unsigned, int>(false), "");
using namespace __gnu_test;
static_assert(test_category<is_void, void>(true), "");
-
+
static_assert(test_category<is_void, char>(false), "");
static_assert(test_category<is_void, signed char>(false), "");
static_assert(test_category<is_void, unsigned char>(false), "");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(test_category<is_void, wchar_t>(false), "");
-#endif
static_assert(test_category<is_void, short>(false), "");
static_assert(test_category<is_void, unsigned short>(false), "");
static_assert(test_category<is_void, int>(false), "");
static_assert( is_same<test22_type, const signed char>::value,
"make_signed<const char>" );
-#ifdef _GLIBCXX_USE_WCHAR_T
typedef make_signed<volatile wchar_t>::type test23_type;
static_assert( is_signed<test23_type>::value
&& is_volatile<test23_type>::value
&& sizeof(test23_type) == sizeof(volatile wchar_t),
"make_signed<volatile wchar_t>" );
-#endif
// Chapter 48, chapter 20. Smallest rank such that new signed type same size.
typedef make_signed<test_enum>::type test24_type;
typedef make_signed<const char>::type test22_type;
static_assert(is_same<test22_type, const signed char>::value, "");
-#ifdef _GLIBCXX_USE_WCHAR_T
typedef make_signed<volatile wchar_t>::type test23_type;
static_assert(is_signed<test23_type>::value
&& is_volatile<test23_type>::value
&& sizeof(test23_type) == sizeof(volatile wchar_t), "");
-#endif
typedef make_signed<test_enum>::type test24_type;
static_assert(is_same<test24_type, short>::value, "");
using I7 = smallest_rank_t<char32_t>;
static_assert(is_same<make_signed<char32_t>::type, I7>::value, "");
static_assert(is_same<make_signed<char32_t const>::type, I7 const>::value, "");
-#ifdef _GLIBCXX_USE_WCHAR_T
using I8 = smallest_rank_t<wchar_t>;
static_assert(is_same<make_signed<wchar_t>::type, I8>::value, "");
static_assert(is_same<make_signed<wchar_t const>::type, I8 const>::value, "");
-#endif
// libstdc++/60326
using namespace std;
-#ifdef _GLIBCXX_USE_WCHAR_T
using wchar_signed = make_signed<wchar_t>::type;
using wchar_unsigned = make_unsigned<wchar_t>::type;
static_assert( !is_same<wchar_signed, wchar_unsigned>::value, "wchar_t" );
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
static_assert( is_signed<make_signed<char8_t>::type>::value, "char8_t");
#endif
typedef make_unsigned<const char>::type test22_type;
static_assert(is_same<test22_type, const unsigned char>::value, "");
-#ifdef _GLIBCXX_USE_WCHAR_T
typedef make_unsigned<volatile wchar_t>::type test23_type;
static_assert(is_unsigned<test23_type>::value
&& is_volatile<test23_type>::value
&& sizeof(test23_type) == sizeof(volatile wchar_t), "");
-#endif
// Chapter 48, chapter 20. Smallest rank such that new unsigned type
// same size.
typedef make_unsigned<const char>::type test22_type;
static_assert(is_same<test22_type, const unsigned char>::value, "");
-#ifdef _GLIBCXX_USE_WCHAR_T
typedef make_unsigned<volatile wchar_t>::type test23_type;
static_assert(is_unsigned<test23_type>::value
&& is_volatile<test23_type>::value
&& sizeof(test23_type) == sizeof(volatile wchar_t), "");
-#endif
typedef make_unsigned<test_enum>::type test24_type;
static_assert(is_same<test24_type, unsigned short>::value, "");
using I7 = smallest_rank_t<char32_t>;
static_assert(is_same<make_unsigned<char32_t>::type, I7>::value, "");
static_assert(is_same<make_unsigned<char32_t const>::type, I7 const>::value, "");
-#ifdef _GLIBCXX_USE_WCHAR_T
using I8 = smallest_rank_t<wchar_t>;
static_assert(is_same<make_unsigned<wchar_t>::type, I8>::value, "");
static_assert(is_same<make_unsigned<wchar_t const>::type, I8 const>::value, "");
-#endif
{
VERIFY( check_to_chars(u'\x21') );
VERIFY( check_to_chars(U'\x21') );
-#if _GLIBCXX_USE_WCHAR_T
VERIFY( check_to_chars(L'\x21') );
-#endif
}
int main()
static_assert(test<volatile unsigned int>::value, "");
static_assert(test<const volatile unsigned int>::value, "");
static_assert(test<const unsigned char>::value, "");
-
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(test<volatile wchar_t>::value, "" );
-#endif
// Pointers
static_assert(test<void*>::value, "");
#endif
VERIFY( test(__gnu_debug::u16string(u"a utf-16 string")) );
VERIFY( test(__gnu_debug::u32string(U"a utf-32 string")) );
-#if _GLIBCXX_USE_WCHAR_T
VERIFY( test(__gnu_debug::wstring(L"a wide string")) );
-#endif
}
#if _GLIBCXX_USE_CHAR8_T
VERIFY( test(std::string("a narrow string")) );
VERIFY( test(std::u16string(u"a utf-16 string")) );
VERIFY( test(std::u32string(U"a utf-32 string")) );
-#if _GLIBCXX_USE_WCHAR_T
VERIFY( test(std::wstring(L"a wide string")) );
-#endif
}
void
VERIFY( test(std::pmr::string("a narrow string, but with PMR!")) );
VERIFY( test(std::pmr::u16string(u"a utf-16 string, but with PMR!")) );
VERIFY( test(std::pmr::u32string(U"a utf-32 string, but with PMR!")) );
-#if _GLIBCXX_USE_WCHAR_T
VERIFY( test(std::pmr::wstring(L"a wide string, but with PMR!")) );
#endif
-#endif
}
int
#endif
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(std::is_same<decltype(L"Hello"s), std::wstring>::value,
"L\"Hello\"s is std::wstring");
-#endif
static_assert(std::is_same<decltype(u"Hello"s), std::u16string>::value,
"u\"Hello\"s is std::u16string");
static_assert(std::is_same<decltype(u8"Hello"s), u8string>::value,
"u8\"Hello\"s is std::string");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(std::is_same<decltype(L"Hello"s), std::wstring>::value,
"L\"Hello\"s is std::wstring");
-#endif
static_assert(std::is_same<decltype(u"Hello"s), std::u16string>::value,
"u\"Hello\"s is std::u16string");
using namespace std::literals::string_literals;
std::string planet = "Mercury"s;
-#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring wplanet = L"Venus"s;
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
std::u8string u8planet = u8"Mars"s;
#else
std::u32string u32planet = U"Saturn"s;
VERIFY( planet == std::string("Mercury") );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet == std::wstring(L"Venus") );
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
VERIFY( u8planet == std::u8string(u8"Mars") );
#else
using namespace std::literals::string_literals;
std::string planet = "Mercury"s;
-#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring wplanet = L"Venus"s;
-#endif
u8string u8planet = u8"Mars"s;
std::u16string u16planet = u"Jupiter"s;
std::u32string u32planet = U"Saturn"s;
VERIFY( planet == std::string("Mercury") );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet == std::wstring(L"Venus") );
-#endif
VERIFY( u8planet == u8string(u8"Mars") );
VERIFY( u16planet == std::u16string(u"Jupiter") );
VERIFY( u32planet == std::u32string(U"Saturn") );
x.replace (x.begin (), x.end (), best, best + 4);
x.replace (x.begin (), x.end (), x);
x.erase (x.begin (), x.end ());
-#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring w;
w.insert (w.begin (), 10, L'x');
const wchar_t west[] = L"west";
w.replace (w.begin (), w.end (), rest, rest + 4);
w.replace (w.begin (), w.end (), w);
w.erase (w.begin (), w.end ());
-#endif
return 0;
}
void
test01()
{
-#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring ws(L"Hello, World!");
(void) std::begin(ws);
(void) std::end(ws);
-#endif
}
{
__gnu_test::citerator<std::string> test1;
__gnu_test::citerator<__gnu_debug::string> dtest1;
-#ifdef _GLIBCXX_USE_WCHAR_T
__gnu_test::citerator<std::wstring> test2;
__gnu_test::citerator<__gnu_debug::wstring> dtest2;
-#endif
return 0;
}
// Check container for required typedefs.
__gnu_test::types<std::string> t1;
__gnu_test::types<__gnu_debug::string> dt1;
-#ifdef _GLIBCXX_USE_WCHAR_T
__gnu_test::types<std::wstring> t2;
__gnu_test::types<__gnu_debug::wstring> dt2;
-#endif
std::basic_string<char32_t, std::char_traits<char32_t>,
std::pmr::polymorphic_allocator<char32_t>>>);
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(std::is_same_v<std::pmr::basic_string<wchar_t>,
std::basic_string<wchar_t, std::char_traits<wchar_t>,
std::pmr::polymorphic_allocator<wchar_t>>>);
static_assert(std::is_same_v<std::pmr::wstring,
std::basic_string<wchar_t, std::char_traits<wchar_t>,
std::pmr::polymorphic_allocator<wchar_t>>>);
-#endif
"u8\"Hello\"sv is std::string_view");
#endif
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(std::is_same<decltype(L"Hello"sv), std::wstring_view>::value,
"L\"Hello\"sv is std::wstring_view");
-#endif
static_assert(std::is_same<decltype(u"Hello"sv), std::u16string_view>::value,
"u\"Hello\"sv is std::u16string_view");
static_assert(std::is_same<decltype(u8"Hello"sv), u8string_view>::value,
"u8\"Hello\"s is std::string_view");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(std::is_same<decltype(L"Hello"sv), std::wstring_view>::value,
"L\"Hello\"s is std::wstring_view");
-#endif
static_assert(std::is_same<decltype(u"Hello"sv), std::u16string_view>::value,
"u\"Hello\"s is std::u16string_view");
using namespace std::literals::string_view_literals;
std::string_view planet = "Mercury"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring_view wplanet = L"Venus"sv;
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
std::u8string_view u8planet = u8"Mars"sv;
#else
std::u32string_view u32planet = U"Saturn"sv;
VERIFY( planet == std::string_view("Mercury") );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet == std::wstring_view(L"Venus") );
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
VERIFY( u8planet == std::u8string_view(u8"Mars") );
#else
using namespace std::literals::string_view_literals;
std::string_view planet_cratered = "Mercury\0cratered"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
std::u8string_view u8planet_cratered = u8"Mars\0cratered"sv;
#else
std::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
VERIFY( planet_cratered == std::string_view("Mercury\0cratered", 16) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet_cratered == std::wstring_view(L"Venus\0cratered", 14) );
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
VERIFY( u8planet_cratered == std::u8string_view(u8"Mars\0cratered", 13) );
#else
using namespace std::literals::string_view_literals;
std::string_view planet = "Mercury"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring_view wplanet = L"Venus"sv;
-#endif
u8string_view u8planet = u8"Mars"sv;
std::u16string_view u16planet = u"Jupiter"sv;
std::u32string_view u32planet = U"Saturn"sv;
VERIFY( planet == std::string_view("Mercury") );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet == std::wstring_view(L"Venus") );
-#endif
VERIFY( u8planet == u8string_view(u8"Mars") );
VERIFY( u16planet == std::u16string_view(u"Jupiter") );
VERIFY( u32planet == std::u32string_view(U"Saturn") );
using namespace std::literals::string_view_literals;
std::string_view planet_cratered = "Mercury\0cratered"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
-#endif
u8string_view u8planet_cratered = u8"Mars\0cratered"sv;
std::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
std::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
VERIFY( planet_cratered == std::string_view("Mercury\0cratered", 16) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet_cratered == std::wstring_view(L"Venus\0cratered", 14) );
-#endif
VERIFY( u8planet_cratered == u8string_view(u8"Mars\0cratered", 13) );
VERIFY( u16planet_cratered == std::u16string_view(u"Jupiter\0cratered", 16) );
VERIFY( u32planet_cratered == std::u32string_view(U"Saturn\0cratered", 15) );
__gnu_test::reversible_types<std::string_view> t1r;
typedef typename std::string_view::traits_type traits_type1;
-#ifdef _GLIBCXX_USE_WCHAR_T
__gnu_test::basic_types<std::wstring_view> t2b;
__gnu_test::reversible_types<std::wstring_view> t2r;
typedef typename std::wstring_view::traits_type traits_type2;
-#endif
static_assert(std::is_same<std::string_view::pointer, char*>(),
"pointer should be value_type*");
using check5_t = std::u32string_view;
#endif
-#ifdef _GLIBCXX_USE_WCHAR_T
using check6_t = std::wstring_view;
-#endif
struct _Concept
{
void __constraint()
- {
+ {
typedef typename _Ttesttype::char_type char_type;
typedef typename _Ttesttype::int_type int_type;
const char_type c1(0);
{
__gnu_test::constexpr_member_functions test;
test.operator()<std::char_traits<char>>();
-#ifdef _GLIBCXX_USE_WCHAR_T
test.operator()<std::char_traits<wchar_t>>();
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
test.operator()<std::char_traits<char8_t>>();
#endif
static_assert( test_compare<std::char_traits<char>>() );
static_assert( test_length<std::char_traits<char>>() );
static_assert( test_find<std::char_traits<char>>() );
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert( test_assign<std::char_traits<wchar_t>>() );
static_assert( test_compare<std::char_traits<wchar_t>>() );
static_assert( test_length<std::char_traits<wchar_t>>() );
static_assert( test_find<std::char_traits<wchar_t>>() );
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
static_assert( test_assign<std::char_traits<char8_t>>() );
static_assert( test_compare<std::char_traits<char8_t>>() );
#endif
static_assert( test_move<std::char_traits<char>>() );
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert( test_move<std::char_traits<wchar_t>>() );
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
static_assert( test_move<std::char_traits<char8_t>>() );
#endif
std::tolower(make_str<char, 12>(), loc); // { dg-error "required from here" }
}
-#ifdef _GLIBCXX_USE_WCHAR_T
void test02()
{
const std::locale& loc = std::locale::classic();
std::toupper(make_str<wchar_t, 11>(), loc); // { dg-error "required from here" }
std::tolower(make_str<wchar_t, 12>(), loc); // { dg-error "required from here" }
}
-#endif
const int A1[] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3};
const int N1 = sizeof(A1) / sizeof(int);
-
+
int i1[N1];
fill(i1, i1 + N1, 3);
VERIFY( equal(i1, i1 + N1, A1) );
fill(v2.begin(), v2.end(), '\3');
VERIFY( equal(v2.begin(), v2.end(), A2) );
-#ifdef _GLIBCXX_USE_WCHAR_T
const wchar_t A3[] = {L'\3', L'\3', L'\3', L'\3', L'\3',
L'\3', L'\3', L'\3', L'\3', L'\3'};
const int N3 = sizeof(A3) / sizeof(wchar_t);
vector<wchar_t> v3(N3);
fill(v3.begin(), v3.end(), L'\3');
VERIFY( equal(v3.begin(), v3.end(), A3) );
-#endif
}
int
const int A1[] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3};
const int N1 = sizeof(A1) / sizeof(int);
-
+
int i1[N1];
test_container<int, output_iterator_wrapper> c1(i1, i1 + N1);
fill_n(c1.begin(), N1, 3);
fill_n(v2.begin(), N2, '\3');
VERIFY( equal(v2.begin(), v2.end(), A2) );
-#ifdef _GLIBCXX_USE_WCHAR_T
const wchar_t A3[] = {L'\3', L'\3', L'\3', L'\3', L'\3',
L'\3', L'\3', L'\3', L'\3', L'\3'};
const int N3 = sizeof(A3) / sizeof(wchar_t);
vector<wchar_t> v3(N3);
fill_n(v3.begin(), N3, L'\3');
VERIFY( equal(v3.begin(), v3.end(), A3) );
-#endif
}
int
// { dg-do run { target c++14 } }
#include <experimental/functional>
+#include <experimental/string_view>
#include <cstring>
-#ifdef _GLIBCXX_USE_WCHAR_T
-# include <cwchar>
-#endif
#include <algorithm>
#include <testsuite_hooks.h>
void
test02()
{
-#ifdef _GLIBCXX_USE_WCHAR_T
const wchar_t s[] = { L'a', (wchar_t)-97, L'a', L'\0' };
const wchar_t* needles[] = {
s, L"", L"a", L"aa", L"aaa", L"ab", L"cd", L"abcd", L"abcdabcd", L"abcabcd"
for (auto n : needles)
{
- auto ne = n + std::wcslen(n);
+ auto ne = n + std::char_traits<wchar_t>::length(n);
auto d = make_default_searcher(n, ne);
auto bm = make_boyer_moore_searcher(n, ne);
auto bmh = make_boyer_moore_horspool_searcher(n, ne);
for (auto h : haystacks)
{
- auto he = h + std::wcslen(h);
+ auto he = h + std::char_traits<wchar_t>::length(h);
auto res = std::search(h, he, n, ne);
auto d_res = d(h, he);
VERIFY( d_res == res );
VERIFY( bmh_res == res );
}
}
-#endif
}
void
xpmr::polymorphic_allocator<char32_t>>>::value,
"pmr::u32string");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(std::is_same<xpmr::basic_string<wchar_t>,
std::basic_string<wchar_t, std::char_traits<wchar_t>,
xpmr::polymorphic_allocator<wchar_t>>>::value,
std::basic_string<wchar_t, std::char_traits<wchar_t>,
xpmr::polymorphic_allocator<wchar_t>>>::value,
"pmr::wstring");
-#endif
"u8\"Hello\"sv is std::string_view");
#endif
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(std::is_same<decltype(L"Hello"sv), std::experimental::wstring_view>::value,
"L\"Hello\"sv is std::wstring_view");
-#endif
static_assert(std::is_same<decltype(u"Hello"sv), std::experimental::u16string_view>::value,
"u\"Hello\"sv is std::u16string_view");
static_assert(std::is_same<decltype(u8"Hello"sv), u8string_view>::value,
"u8\"Hello\"s is std::string_view");
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert(std::is_same<decltype(L"Hello"sv), std::experimental::wstring_view>::value,
"L\"Hello\"s is std::wstring_view");
-#endif
static_assert(std::is_same<decltype(u"Hello"sv), std::experimental::u16string_view>::value,
"u\"Hello\"s is std::u16string_view");
using namespace std::experimental::literals::string_view_literals;
std::experimental::string_view planet = "Mercury"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
std::experimental::wstring_view wplanet = L"Venus"sv;
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
std::experimental::u8string_view u8planet = u8"Mars"sv;
#else
std::experimental::u32string_view u32planet = U"Saturn"sv;
VERIFY( planet == std::experimental::string_view("Mercury") );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet == std::experimental::wstring_view(L"Venus") );
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
VERIFY( u8planet == std::experimental::u8string_view(u8"Mars") );
#else
using namespace std::experimental::literals::string_view_literals;
std::experimental::string_view planet_cratered = "Mercury\0cratered"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
std::experimental::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
std::experimental::u8string_view u8planet_cratered = u8"Mars\0cratered"sv;
#else
VERIFY( planet_cratered ==
std::experimental::string_view("Mercury\0cratered", 16) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet_cratered ==
std::experimental::wstring_view(L"Venus\0cratered", 14) );
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
VERIFY( u8planet_cratered ==
std::experimental::u8string_view(u8"Mars\0cratered", 13) );
using namespace std::experimental::literals::string_view_literals;
std::experimental::string_view planet = "Mercury"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
std::experimental::wstring_view wplanet = L"Venus"sv;
-#endif
u8string_view u8planet = u8"Mars"sv;
std::experimental::u16string_view u16planet = u"Jupiter"sv;
std::experimental::u32string_view u32planet = U"Saturn"sv;
VERIFY( planet == std::experimental::string_view("Mercury") );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet == std::experimental::wstring_view(L"Venus") );
-#endif
VERIFY( u8planet == u8string_view(u8"Mars") );
VERIFY( u16planet == std::experimental::u16string_view(u"Jupiter") );
VERIFY( u32planet == std::experimental::u32string_view(U"Saturn") );
using namespace std::experimental::literals::string_view_literals;
std::experimental::string_view planet_cratered = "Mercury\0cratered"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
std::experimental::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
-#endif
u8string_view u8planet_cratered = u8"Mars\0cratered"sv;
std::experimental::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
std::experimental::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
VERIFY( planet_cratered ==
std::experimental::string_view("Mercury\0cratered", 16) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet_cratered ==
std::experimental::wstring_view(L"Venus\0cratered", 14) );
-#endif
VERIFY( u8planet_cratered == u8string_view(u8"Mars\0cratered", 13) );
VERIFY( u16planet_cratered ==
std::experimental::u16string_view(u"Jupiter\0cratered", 16) );
void
test01()
{
-#ifdef _GLIBCXX_USE_WCHAR_T
std::experimental::wstring_view ws(L"Hello, World!");
(void) std::begin(ws);
(void) std::end(ws);
-#endif
}
__gnu_test::reversible_types<std::experimental::string_view> t1r;
typedef typename std::experimental::string_view::traits_type traits_type1;
-#ifdef _GLIBCXX_USE_WCHAR_T
__gnu_test::basic_types<std::experimental::wstring_view> t2b;
__gnu_test::reversible_types<std::experimental::wstring_view> t2r;
typedef typename std::experimental::wstring_view::traits_type traits_type2;
-#endif
static_assert(
std::is_same<std::experimental::string_view::pointer, char*>(),
using check5_t = std::experimental::fundamentals_v1::u32string_view;
#endif
-#ifdef _GLIBCXX_USE_WCHAR_T
using check6_t = std::experimental::fundamentals_v1::wstring_view;
-#endif
-
(void) std::begin(s);
(void) std::end(s);
-#ifdef _GLIBCXX_USE_WCHAR_T
__gnu_cxx::__wvstring ws(L"Hello, World!");
(void) std::begin(ws);
(void) std::end(ws);
-#endif
}
static_assert( std::integral<char> );
static_assert( std::integral<char16_t> );
static_assert( std::integral<char32_t> );
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert( std::integral<wchar_t> );
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
static_assert( std::integral<char8_t> );
#endif
static_assert( std::is_signed_v<char> ? std::signed_integral<char> : true );
static_assert( !std::signed_integral<char16_t> );
static_assert( !std::signed_integral<char32_t> );
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert( std::is_signed_v<wchar_t> ? std::signed_integral<wchar_t> : true );
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
static_assert( !std::signed_integral<char8_t> );
#endif
static_assert( std::is_signed_v<char> ? true : std::unsigned_integral<char> );
static_assert( std::unsigned_integral<char16_t> );
static_assert( std::unsigned_integral<char32_t> );
-#ifdef _GLIBCXX_USE_WCHAR_T
static_assert( std::is_signed_v<wchar_t> ? true : std::unsigned_integral<wchar_t> );
-#endif
#ifdef _GLIBCXX_USE_CHAR8_T
static_assert( std::unsigned_integral<char8_t> );
#endif
VERIFY( (test_category<is_arithmetic, char>(true)) );
VERIFY( (test_category<is_arithmetic, signed char>(true)) );
VERIFY( (test_category<is_arithmetic, unsigned char>(true)) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_arithmetic, wchar_t>(true)) );
-#endif
VERIFY( (test_category<is_arithmetic, short>(true)) );
VERIFY( (test_category<is_arithmetic, unsigned short>(true)) );
VERIFY( (test_category<is_arithmetic, int>(true)) );
VERIFY( (test_category<is_compound, char>(false)) );
VERIFY( (test_category<is_compound, signed char>(false)) );
VERIFY( (test_category<is_compound, unsigned char>(false)) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_compound, wchar_t>(false)) );
-#endif
VERIFY( (test_category<is_compound, short>(false)) );
VERIFY( (test_category<is_compound, unsigned short>(false)) );
VERIFY( (test_category<is_compound, int>(false)) );
VERIFY( (test_category<is_floating_point, char>(false)) );
VERIFY( (test_category<is_floating_point, signed char>(false)) );
VERIFY( (test_category<is_floating_point, unsigned char>(false)) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_floating_point, wchar_t>(false)) );
-#endif
VERIFY( (test_category<is_floating_point, short>(false)) );
VERIFY( (test_category<is_floating_point, unsigned short>(false)) );
VERIFY( (test_category<is_floating_point, int>(false)) );
VERIFY( (test_category<is_fundamental, char>(true)) );
VERIFY( (test_category<is_fundamental, signed char>(true)) );
VERIFY( (test_category<is_fundamental, unsigned char>(true)) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_fundamental, wchar_t>(true)) );
-#endif
VERIFY( (test_category<is_fundamental, short>(true)) );
VERIFY( (test_category<is_fundamental, unsigned short>(true)) );
VERIFY( (test_category<is_fundamental, int>(true)) );
VERIFY( (test_category<is_integral, char>(true)) );
VERIFY( (test_category<is_integral, signed char>(true)) );
VERIFY( (test_category<is_integral, unsigned char>(true)) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_integral, wchar_t>(true)) );
-#endif
VERIFY( (test_category<is_integral, short>(true)) );
VERIFY( (test_category<is_integral, unsigned short>(true)) );
VERIFY( (test_category<is_integral, int>(true)) );
VERIFY( (test_category<is_signed, char>(false)) );
VERIFY( (test_category<is_signed, signed char>(true)) );
VERIFY( (test_category<is_signed, unsigned char>(false)) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_signed, wchar_t>(false)) );
-#endif
VERIFY( (test_category<is_signed, short>(true)) );
VERIFY( (test_category<is_signed, unsigned short>(false)) );
VERIFY( (test_category<is_signed, int>(true)) );
VERIFY( (test_category<is_unsigned, char>(false)) );
VERIFY( (test_category<is_unsigned, signed char>(false)) );
VERIFY( (test_category<is_unsigned, unsigned char>(true)) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_unsigned, wchar_t>(false)) );
-#endif
VERIFY( (test_category<is_unsigned, short>(false)) );
VERIFY( (test_category<is_unsigned, unsigned short>(true)) );
VERIFY( (test_category<is_unsigned, int>(false)) );
VERIFY( (test_category<is_void, char>(false)) );
VERIFY( (test_category<is_void, signed char>(false)) );
VERIFY( (test_category<is_void, unsigned char>(false)) );
-#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_void, wchar_t>(false)) );
-#endif
VERIFY( (test_category<is_void, short>(false)) );
VERIFY( (test_category<is_void, unsigned short>(false)) );
VERIFY( (test_category<is_void, int>(false)) );
do_test<double>();
do_test<long double>();
-#ifdef _GLIBCXX_USE_WCHAR_T
do_test<wchar_t>();
do_test<std::wstring>();
-#endif
}
int main()