9bdc310aaaf32ffdb2e025d988e96ed8bfbf9e97
[platform/upstream/gcc48.git] / libstdc++-v3 / testsuite / 22_locale / codecvt_byname / 50714.cc
1 // { dg-require-namedlocale "de_DE" }
2
3 // Copyright (C) 2011 Free Software Foundation
4 //
5 // This file is part of the GNU ISO C++ Library.  This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3.  If not see
18 // <http://www.gnu.org/licenses/>.
19
20 #include <locale>
21 #include <ext/pod_char_traits.h>
22
23 #define mychar __gnu_cxx::character<unsigned short, int>
24
25 namespace std
26 {
27   template<> codecvt<mychar, char, mbstate_t>::~codecvt()
28   { }
29
30   template<>
31   codecvt<mychar, char, mbstate_t>::result
32   codecvt<mychar, char, mbstate_t>::
33   do_out(state_type&, const intern_type*, const intern_type*,
34          const intern_type*&, extern_type*, extern_type*,
35          extern_type*&) const
36   { return codecvt_base::ok; }
37
38   template<>
39   codecvt<mychar, char, mbstate_t>::result
40   codecvt<mychar, char, mbstate_t>::
41   do_in(state_type&, const extern_type*, const extern_type*,
42         const extern_type*&, intern_type*, intern_type*,
43         intern_type*&) const
44   { return codecvt_base::ok; }
45
46   template<>
47   codecvt<mychar, char, mbstate_t>::result
48   codecvt<mychar, char, mbstate_t>::
49   do_unshift(state_type&, extern_type*, extern_type*,
50              extern_type*&) const
51   { return noconv; }
52
53   template<>
54   int
55   codecvt<mychar, char, mbstate_t>::do_encoding() const
56   { return 0; }
57
58   template<>
59   bool
60   codecvt<mychar, char, mbstate_t>::do_always_noconv() const
61   { return false; }
62
63   template<>
64   int
65   codecvt<mychar, char, mbstate_t>::
66   do_length(state_type&, const extern_type*, const extern_type*,
67             size_t) const
68   { return 0; }
69
70   template<>
71   int
72   codecvt<mychar, char, mbstate_t>::do_max_length() const
73   { return 4; }
74 }
75
76 // libstdc++/50714
77 void test01()
78 {
79   using namespace std;
80
81   {
82     locale loc(locale::classic(),
83                new codecvt<mychar, char, mbstate_t>());
84   }
85   {
86     locale loc2(locale::classic(),
87                 new codecvt_byname<mychar, char, mbstate_t>("de_DE"));
88   }
89 }
90
91 int main()
92 {
93   test01();
94   return 0;
95 }