1 // { dg-do run { target c++11 } }
2 // { dg-require-iconv "ISO-8859-1" }
4 // Copyright (C) 2006-2024 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/>.
21 // 22.1.1.2 locale constructors and destructors [lib.locale.cons]
23 #include <cwchar> // for mbstate_t
27 #include <testsuite_hooks.h>
28 #include <ext/codecvt_specializations.h>
30 typedef std::codecvt
<char, char, std::mbstate_t> c_codecvt
;
32 #ifdef _GLIBCXX_USE_WCHAR_T
33 typedef std::codecvt
<wchar_t, char, std::mbstate_t> w_codecvt
;
36 typedef std::codecvt
<char16_t
, char, std::mbstate_t> u16_codecvt
;
37 typedef std::codecvt
<char32_t
, char, std::mbstate_t> u32_codecvt
;
38 #ifdef _GLIBCXX_USE_CHAR8_T
39 typedef std::codecvt
<char16_t
, char8_t
, std::mbstate_t> u16u8_codecvt
;
40 typedef std::codecvt
<char32_t
, char8_t
, std::mbstate_t> u32u8_codecvt
;
43 class gnu_facet
: public std::locale::facet
46 static std::locale::id id
;
49 std::locale::id
gnu_facet::id
;
54 typedef unsigned short int_type
;
55 typedef char ext_type
;
56 typedef __gnu_cxx::encoding_state state_type
;
57 typedef codecvt
<int_type
, ext_type
, state_type
> unicode_codecvt
;
60 locale
loc01(locale::classic());
61 locale
loc13(locale::classic(), new unicode_codecvt
);
62 VERIFY( loc01
!= loc13
);
63 VERIFY( loc13
.name() == "*" );
66 VERIFY( has_facet
<c_codecvt
>(loc13
) );
67 #ifdef _GLIBCXX_USE_WCHAR_T
68 VERIFY( has_facet
<w_codecvt
>(loc13
) );
70 VERIFY( has_facet
<u16_codecvt
>(loc13
) );
71 VERIFY( has_facet
<u32_codecvt
>(loc13
) );
72 #ifdef _GLIBCXX_USE_CHAR8_T
73 VERIFY( has_facet
<u16u8_codecvt
>(loc13
) );
74 VERIFY( has_facet
<u32u8_codecvt
>(loc13
) );
76 VERIFY( has_facet
<unicode_codecvt
>(loc13
) );
82 { (void) use_facet
<gnu_facet
>(loc13
); }