__locale revision 253159
1227825Stheraven// -*- C++ -*-
2227825Stheraven//===----------------------------------------------------------------------===//
3227825Stheraven//
4227825Stheraven//                     The LLVM Compiler Infrastructure
5227825Stheraven//
6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open
7227825Stheraven// Source Licenses. See LICENSE.TXT for details.
8227825Stheraven//
9227825Stheraven//===----------------------------------------------------------------------===//
10227825Stheraven
11227825Stheraven#ifndef _LIBCPP___LOCALE
12227825Stheraven#define _LIBCPP___LOCALE
13227825Stheraven
14227825Stheraven#include <__config>
15227825Stheraven#include <string>
16227825Stheraven#include <memory>
17227825Stheraven#include <utility>
18227825Stheraven#include <mutex>
19227825Stheraven#include <cstdint>
20227825Stheraven#include <cctype>
21227825Stheraven#include <locale.h>
22249998Sdim#ifdef _WIN32
23227825Stheraven# include <support/win32/locale_win32.h>
24249998Sdim#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)) || defined(EMSCRIPTEN)
25227825Stheraven# include <xlocale.h>
26249998Sdim#endif  // _WIN32 || __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || EMSCRIPTEN
27227825Stheraven
28227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29227825Stheraven#pragma GCC system_header
30227825Stheraven#endif
31227825Stheraven
32227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
33227825Stheraven
34249998Sdimclass _LIBCPP_TYPE_VIS locale;
35227825Stheraven
36241903Sdimtemplate <class _Facet>
37241903Sdim_LIBCPP_INLINE_VISIBILITY
38241903Sdimbool
39241903Sdimhas_facet(const locale&) _NOEXCEPT;
40227825Stheraven
41241903Sdimtemplate <class _Facet>
42241903Sdim_LIBCPP_INLINE_VISIBILITY
43241903Sdimconst _Facet&
44241903Sdimuse_facet(const locale&);
45241903Sdim
46249998Sdimclass _LIBCPP_TYPE_VIS locale
47227825Stheraven{
48227825Stheravenpublic:
49227825Stheraven    // types:
50249998Sdim    class _LIBCPP_TYPE_VIS facet;
51249998Sdim    class _LIBCPP_TYPE_VIS id;
52227825Stheraven
53227825Stheraven    typedef int category;
54227825Stheraven    static const category // values assigned here are for exposition only
55227825Stheraven        none     = 0,
56227825Stheraven        collate  = LC_COLLATE_MASK,
57227825Stheraven        ctype    = LC_CTYPE_MASK,
58227825Stheraven        monetary = LC_MONETARY_MASK,
59227825Stheraven        numeric  = LC_NUMERIC_MASK,
60227825Stheraven        time     = LC_TIME_MASK,
61227825Stheraven        messages = LC_MESSAGES_MASK,
62227825Stheraven        all = collate | ctype | monetary | numeric | time | messages;
63227825Stheraven
64227825Stheraven    // construct/copy/destroy:
65227825Stheraven    locale()  _NOEXCEPT;
66227825Stheraven    locale(const locale&)  _NOEXCEPT;
67227825Stheraven    explicit locale(const char*);
68227825Stheraven    explicit locale(const string&);
69227825Stheraven    locale(const locale&, const char*, category);
70227825Stheraven    locale(const locale&, const string&, category);
71227825Stheraven    template <class _Facet>
72227825Stheraven        _LIBCPP_INLINE_VISIBILITY locale(const locale&, _Facet*);
73227825Stheraven    locale(const locale&, const locale&, category);
74227825Stheraven
75227825Stheraven    ~locale();
76227825Stheraven
77227825Stheraven    const locale& operator=(const locale&)  _NOEXCEPT;
78227825Stheraven
79227825Stheraven    template <class _Facet> locale combine(const locale&) const;
80227825Stheraven
81227825Stheraven    // locale operations:
82227825Stheraven    string name() const;
83227825Stheraven    bool operator==(const locale&) const;
84227825Stheraven    bool operator!=(const locale& __y) const {return !(*this == __y);}
85227825Stheraven    template <class _CharT, class _Traits, class _Allocator>
86227825Stheraven      bool operator()(const basic_string<_CharT, _Traits, _Allocator>&,
87227825Stheraven                      const basic_string<_CharT, _Traits, _Allocator>&) const;
88227825Stheraven
89227825Stheraven    // global locale objects:
90227825Stheraven    static locale global(const locale&);
91227825Stheraven    static const locale& classic();
92227825Stheraven
93227825Stheravenprivate:
94227825Stheraven    class __imp;
95227825Stheraven    __imp* __locale_;
96227825Stheraven
97227825Stheraven    void __install_ctor(const locale&, facet*, long);
98227825Stheraven    static locale& __global();
99227825Stheraven    bool has_facet(id&) const;
100227825Stheraven    const facet* use_facet(id&) const;
101227825Stheraven
102227825Stheraven    template <class _Facet> friend bool has_facet(const locale&)  _NOEXCEPT;
103227825Stheraven    template <class _Facet> friend const _Facet& use_facet(const locale&);
104227825Stheraven};
105227825Stheraven
106249998Sdimclass _LIBCPP_TYPE_VIS locale::facet
107227825Stheraven    : public __shared_count
108227825Stheraven{
109227825Stheravenprotected:
110227825Stheraven    _LIBCPP_INLINE_VISIBILITY
111227825Stheraven    explicit facet(size_t __refs = 0)
112227825Stheraven        : __shared_count(static_cast<long>(__refs)-1) {}
113227825Stheraven
114227825Stheraven    virtual ~facet();
115227825Stheraven
116227825Stheraven//    facet(const facet&) = delete;     // effectively done in __shared_count
117227825Stheraven//    void operator=(const facet&) = delete;
118227825Stheravenprivate:
119227825Stheraven    virtual void __on_zero_shared() _NOEXCEPT;
120227825Stheraven};
121227825Stheraven
122249998Sdimclass _LIBCPP_TYPE_VIS locale::id
123227825Stheraven{
124227825Stheraven    once_flag      __flag_;
125227825Stheraven    int32_t        __id_;
126227825Stheraven
127227825Stheraven    static int32_t __next_id;
128227825Stheravenpublic:
129241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {}
130227825Stheravenprivate:
131227825Stheraven    void __init();
132227825Stheraven    void operator=(const id&); // = delete;
133227825Stheraven    id(const id&); // = delete;
134227825Stheravenpublic:  // only needed for tests
135227825Stheraven    long __get();
136227825Stheraven
137227825Stheraven    friend class locale;
138227825Stheraven    friend class locale::__imp;
139227825Stheraven};
140227825Stheraven
141227825Stheraventemplate <class _Facet>
142227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
143227825Stheravenlocale::locale(const locale& __other, _Facet* __f)
144227825Stheraven{
145227825Stheraven    __install_ctor(__other, __f, __f ? __f->id.__get() : 0);
146227825Stheraven}
147227825Stheraven
148227825Stheraventemplate <class _Facet>
149227825Stheravenlocale
150227825Stheravenlocale::combine(const locale& __other) const
151227825Stheraven{
152227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS
153227825Stheraven    if (!_VSTD::has_facet<_Facet>(__other))
154227825Stheraven        throw runtime_error("locale::combine: locale missing facet");
155227825Stheraven#endif  // _LIBCPP_NO_EXCEPTIONS
156227825Stheraven    return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other)));
157227825Stheraven}
158227825Stheraven
159227825Stheraventemplate <class _Facet>
160227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
161227825Stheravenbool
162227825Stheravenhas_facet(const locale& __l)  _NOEXCEPT
163227825Stheraven{
164227825Stheraven    return __l.has_facet(_Facet::id);
165227825Stheraven}
166227825Stheraven
167227825Stheraventemplate <class _Facet>
168227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
169227825Stheravenconst _Facet&
170227825Stheravenuse_facet(const locale& __l)
171227825Stheraven{
172227825Stheraven    return static_cast<const _Facet&>(*__l.use_facet(_Facet::id));
173227825Stheraven}
174227825Stheraven
175227825Stheraven// template <class _CharT> class collate;
176227825Stheraven
177227825Stheraventemplate <class _CharT>
178249998Sdimclass _LIBCPP_TYPE_VIS collate
179227825Stheraven    : public locale::facet
180227825Stheraven{
181227825Stheravenpublic:
182227825Stheraven    typedef _CharT char_type;
183227825Stheraven    typedef basic_string<char_type> string_type;
184227825Stheraven
185227825Stheraven    _LIBCPP_INLINE_VISIBILITY
186227825Stheraven    explicit collate(size_t __refs = 0)
187227825Stheraven        : locale::facet(__refs) {}
188227825Stheraven
189227825Stheraven    _LIBCPP_INLINE_VISIBILITY
190227825Stheraven    int compare(const char_type* __lo1, const char_type* __hi1,
191227825Stheraven                const char_type* __lo2, const char_type* __hi2) const
192227825Stheraven    {
193227825Stheraven        return do_compare(__lo1, __hi1, __lo2, __hi2);
194227825Stheraven    }
195227825Stheraven
196227825Stheraven    _LIBCPP_INLINE_VISIBILITY
197227825Stheraven    string_type transform(const char_type* __lo, const char_type* __hi) const
198227825Stheraven    {
199227825Stheraven        return do_transform(__lo, __hi);
200227825Stheraven    }
201227825Stheraven
202227825Stheraven    _LIBCPP_INLINE_VISIBILITY
203227825Stheraven    long hash(const char_type* __lo, const char_type* __hi) const
204227825Stheraven    {
205227825Stheraven        return do_hash(__lo, __hi);
206227825Stheraven    }
207227825Stheraven
208227825Stheraven    static locale::id id;
209227825Stheraven
210227825Stheravenprotected:
211227825Stheraven    ~collate();
212227825Stheraven    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
213227825Stheraven                           const char_type* __lo2, const char_type* __hi2) const;
214227825Stheraven    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const
215227825Stheraven        {return string_type(__lo, __hi);}
216227825Stheraven    virtual long do_hash(const char_type* __lo, const char_type* __hi) const;
217227825Stheraven};
218227825Stheraven
219227825Stheraventemplate <class _CharT> locale::id collate<_CharT>::id;
220227825Stheraven
221227825Stheraventemplate <class _CharT>
222227825Stheravencollate<_CharT>::~collate()
223227825Stheraven{
224227825Stheraven}
225227825Stheraven
226227825Stheraventemplate <class _CharT>
227227825Stheravenint
228227825Stheravencollate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1,
229227825Stheraven                            const char_type* __lo2, const char_type* __hi2) const
230227825Stheraven{
231227825Stheraven    for (; __lo2 != __hi2; ++__lo1, ++__lo2)
232227825Stheraven    {
233227825Stheraven        if (__lo1 == __hi1 || *__lo1 < *__lo2)
234227825Stheraven            return -1;
235227825Stheraven        if (*__lo2 < *__lo1)
236227825Stheraven            return 1;
237227825Stheraven    }
238227825Stheraven    return __lo1 != __hi1;
239227825Stheraven}
240227825Stheraven
241227825Stheraventemplate <class _CharT>
242227825Stheravenlong
243227825Stheravencollate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
244227825Stheraven{
245227825Stheraven    size_t __h = 0;
246227825Stheraven    const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8;
247227825Stheraven    const size_t __mask = size_t(0xF) << (__sr + 4);
248227825Stheraven    for(const char_type* __p = __lo; __p != __hi; ++__p)
249227825Stheraven    {
250232950Stheraven        __h = (__h << 4) + static_cast<size_t>(*__p);
251227825Stheraven        size_t __g = __h & __mask;
252227825Stheraven        __h ^= __g | (__g >> __sr);
253227825Stheraven    }
254227825Stheraven    return static_cast<long>(__h);
255227825Stheraven}
256227825Stheraven
257249998Sdim_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS collate<char>)
258249998Sdim_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS collate<wchar_t>)
259227825Stheraven
260227825Stheraven// template <class CharT> class collate_byname;
261227825Stheraven
262249998Sdimtemplate <class _CharT> class _LIBCPP_TYPE_VIS collate_byname;
263227825Stheraven
264227825Stheraventemplate <>
265249998Sdimclass _LIBCPP_TYPE_VIS collate_byname<char>
266227825Stheraven    : public collate<char>
267227825Stheraven{
268227825Stheraven    locale_t __l;
269227825Stheravenpublic:
270227825Stheraven    typedef char char_type;
271227825Stheraven    typedef basic_string<char_type> string_type;
272227825Stheraven
273227825Stheraven    explicit collate_byname(const char* __n, size_t __refs = 0);
274227825Stheraven    explicit collate_byname(const string& __n, size_t __refs = 0);
275227825Stheraven
276227825Stheravenprotected:
277227825Stheraven    ~collate_byname();
278227825Stheraven    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
279227825Stheraven                           const char_type* __lo2, const char_type* __hi2) const;
280227825Stheraven    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
281227825Stheraven};
282227825Stheraven
283227825Stheraventemplate <>
284249998Sdimclass _LIBCPP_TYPE_VIS collate_byname<wchar_t>
285227825Stheraven    : public collate<wchar_t>
286227825Stheraven{
287227825Stheraven    locale_t __l;
288227825Stheravenpublic:
289227825Stheraven    typedef wchar_t char_type;
290227825Stheraven    typedef basic_string<char_type> string_type;
291227825Stheraven
292227825Stheraven    explicit collate_byname(const char* __n, size_t __refs = 0);
293227825Stheraven    explicit collate_byname(const string& __n, size_t __refs = 0);
294227825Stheraven
295227825Stheravenprotected:
296227825Stheraven    ~collate_byname();
297227825Stheraven
298227825Stheraven    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
299227825Stheraven                           const char_type* __lo2, const char_type* __hi2) const;
300227825Stheraven    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
301227825Stheraven};
302227825Stheraven
303227825Stheraventemplate <class _CharT, class _Traits, class _Allocator>
304227825Stheravenbool
305227825Stheravenlocale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
306227825Stheraven                   const basic_string<_CharT, _Traits, _Allocator>& __y) const
307227825Stheraven{
308227825Stheraven    return _VSTD::use_facet<_VSTD::collate<_CharT> >(*this).compare(
309227825Stheraven                                       __x.data(), __x.data() + __x.size(),
310227825Stheraven                                       __y.data(), __y.data() + __y.size()) < 0;
311227825Stheraven}
312227825Stheraven
313227825Stheraven// template <class charT> class ctype
314227825Stheraven
315249998Sdimclass _LIBCPP_TYPE_VIS ctype_base
316227825Stheraven{
317227825Stheravenpublic:
318249998Sdim#ifdef __GLIBC__
319227825Stheraven    typedef unsigned short mask;
320227825Stheraven    static const mask space  = _ISspace;
321227825Stheraven    static const mask print  = _ISprint;
322227825Stheraven    static const mask cntrl  = _IScntrl;
323227825Stheraven    static const mask upper  = _ISupper;
324227825Stheraven    static const mask lower  = _ISlower;
325227825Stheraven    static const mask alpha  = _ISalpha;
326227825Stheraven    static const mask digit  = _ISdigit;
327227825Stheraven    static const mask punct  = _ISpunct;
328227825Stheraven    static const mask xdigit = _ISxdigit;
329227825Stheraven    static const mask blank  = _ISblank;
330249998Sdim#elif defined(_WIN32)
331227825Stheraven    typedef unsigned short mask;
332227825Stheraven    static const mask space  = _SPACE;
333227825Stheraven    static const mask print  = _BLANK|_PUNCT|_ALPHA|_DIGIT;
334227825Stheraven    static const mask cntrl  = _CONTROL;
335227825Stheraven    static const mask upper  = _UPPER;
336227825Stheraven    static const mask lower  = _LOWER;
337227825Stheraven    static const mask alpha  = _ALPHA;
338227825Stheraven    static const mask digit  = _DIGIT;
339227825Stheraven    static const mask punct  = _PUNCT;
340227825Stheraven    static const mask xdigit = _HEX;
341227825Stheraven    static const mask blank  = _BLANK;
342253159Stheraven#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(EMSCRIPTEN) || defined(__NetBSD__)
343249998Sdim#ifdef __APPLE__
344227825Stheraven    typedef __uint32_t mask;
345249998Sdim#elif defined(__FreeBSD__)
346227825Stheraven    typedef unsigned long mask;
347253159Stheraven#elif defined(EMSCRIPTEN) ||  defined(__NetBSD__)
348249998Sdim    typedef unsigned short mask;
349227825Stheraven#endif
350227825Stheraven    static const mask space  = _CTYPE_S;
351227825Stheraven    static const mask print  = _CTYPE_R;
352227825Stheraven    static const mask cntrl  = _CTYPE_C;
353227825Stheraven    static const mask upper  = _CTYPE_U;
354227825Stheraven    static const mask lower  = _CTYPE_L;
355227825Stheraven    static const mask alpha  = _CTYPE_A;
356227825Stheraven    static const mask digit  = _CTYPE_D;
357227825Stheraven    static const mask punct  = _CTYPE_P;
358227825Stheraven    static const mask xdigit = _CTYPE_X;
359253159Stheraven# if defined(__NetBSD__)
360253159Stheraven    static const mask blank  = _CTYPE_BL;
361253159Stheraven# else
362227825Stheraven    static const mask blank  = _CTYPE_B;
363253159Stheraven# endif
364249998Sdim#elif defined(__sun__)
365232950Stheraven    typedef unsigned int mask;
366232950Stheraven    static const mask space  = _ISSPACE;
367232950Stheraven    static const mask print  = _ISPRINT;
368232950Stheraven    static const mask cntrl  = _ISCNTRL;
369232950Stheraven    static const mask upper  = _ISUPPER;
370232950Stheraven    static const mask lower  = _ISLOWER;
371232950Stheraven    static const mask alpha  = _ISALPHA;
372232950Stheraven    static const mask digit  = _ISDIGIT;
373232950Stheraven    static const mask punct  = _ISPUNCT;
374232950Stheraven    static const mask xdigit = _ISXDIGIT;
375232950Stheraven    static const mask blank  = _ISBLANK;
376249998Sdim#else  // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__ || EMSCRIPTEN || __sun__
377227825Stheraven    typedef unsigned long mask;
378227825Stheraven    static const mask space  = 1<<0;
379227825Stheraven    static const mask print  = 1<<1;
380227825Stheraven    static const mask cntrl  = 1<<2;
381227825Stheraven    static const mask upper  = 1<<3;
382227825Stheraven    static const mask lower  = 1<<4;
383227825Stheraven    static const mask alpha  = 1<<5;
384227825Stheraven    static const mask digit  = 1<<6;
385227825Stheraven    static const mask punct  = 1<<7;
386227825Stheraven    static const mask xdigit = 1<<8;
387227825Stheraven    static const mask blank  = 1<<9;
388227825Stheraven#endif  // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__
389227825Stheraven    static const mask alnum  = alpha | digit;
390227825Stheraven    static const mask graph  = alnum | punct;
391227825Stheraven
392227825Stheraven    _LIBCPP_ALWAYS_INLINE ctype_base() {}
393227825Stheraven};
394227825Stheraven
395249998Sdimtemplate <class _CharT> class _LIBCPP_TYPE_VIS ctype;
396227825Stheraven
397227825Stheraventemplate <>
398249998Sdimclass _LIBCPP_TYPE_VIS ctype<wchar_t>
399227825Stheraven    : public locale::facet,
400227825Stheraven      public ctype_base
401227825Stheraven{
402227825Stheravenpublic:
403227825Stheraven    typedef wchar_t char_type;
404227825Stheraven
405227825Stheraven    _LIBCPP_ALWAYS_INLINE
406227825Stheraven    explicit ctype(size_t __refs = 0)
407227825Stheraven        : locale::facet(__refs) {}
408227825Stheraven
409227825Stheraven    _LIBCPP_ALWAYS_INLINE
410227825Stheraven    bool is(mask __m, char_type __c) const
411227825Stheraven    {
412227825Stheraven        return do_is(__m, __c);
413227825Stheraven    }
414227825Stheraven
415227825Stheraven    _LIBCPP_ALWAYS_INLINE
416227825Stheraven    const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
417227825Stheraven    {
418227825Stheraven        return do_is(__low, __high, __vec);
419227825Stheraven    }
420227825Stheraven
421227825Stheraven    _LIBCPP_ALWAYS_INLINE
422227825Stheraven    const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const
423227825Stheraven    {
424227825Stheraven        return do_scan_is(__m, __low, __high);
425227825Stheraven    }
426227825Stheraven
427227825Stheraven    _LIBCPP_ALWAYS_INLINE
428227825Stheraven    const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
429227825Stheraven    {
430227825Stheraven        return do_scan_not(__m, __low, __high);
431227825Stheraven    }
432227825Stheraven
433227825Stheraven    _LIBCPP_ALWAYS_INLINE
434227825Stheraven    char_type toupper(char_type __c) const
435227825Stheraven    {
436227825Stheraven        return do_toupper(__c);
437227825Stheraven    }
438227825Stheraven
439227825Stheraven    _LIBCPP_ALWAYS_INLINE
440227825Stheraven    const char_type* toupper(char_type* __low, const char_type* __high) const
441227825Stheraven    {
442227825Stheraven        return do_toupper(__low, __high);
443227825Stheraven    }
444227825Stheraven
445227825Stheraven    _LIBCPP_ALWAYS_INLINE
446227825Stheraven    char_type tolower(char_type __c) const
447227825Stheraven    {
448227825Stheraven        return do_tolower(__c);
449227825Stheraven    }
450227825Stheraven
451227825Stheraven    _LIBCPP_ALWAYS_INLINE
452227825Stheraven    const char_type* tolower(char_type* __low, const char_type* __high) const
453227825Stheraven    {
454227825Stheraven        return do_tolower(__low, __high);
455227825Stheraven    }
456227825Stheraven
457227825Stheraven    _LIBCPP_ALWAYS_INLINE
458227825Stheraven    char_type widen(char __c) const
459227825Stheraven    {
460227825Stheraven        return do_widen(__c);
461227825Stheraven    }
462227825Stheraven
463227825Stheraven    _LIBCPP_ALWAYS_INLINE
464227825Stheraven    const char* widen(const char* __low, const char* __high, char_type* __to) const
465227825Stheraven    {
466227825Stheraven        return do_widen(__low, __high, __to);
467227825Stheraven    }
468227825Stheraven
469227825Stheraven    _LIBCPP_ALWAYS_INLINE
470227825Stheraven    char narrow(char_type __c, char __dfault) const
471227825Stheraven    {
472227825Stheraven        return do_narrow(__c, __dfault);
473227825Stheraven    }
474227825Stheraven
475227825Stheraven    _LIBCPP_ALWAYS_INLINE
476227825Stheraven    const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
477227825Stheraven    {
478227825Stheraven        return do_narrow(__low, __high, __dfault, __to);
479227825Stheraven    }
480227825Stheraven
481227825Stheraven    static locale::id id;
482227825Stheraven
483227825Stheravenprotected:
484227825Stheraven    ~ctype();
485227825Stheraven    virtual bool do_is(mask __m, char_type __c) const;
486227825Stheraven    virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
487227825Stheraven    virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
488227825Stheraven    virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
489227825Stheraven    virtual char_type do_toupper(char_type) const;
490227825Stheraven    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
491227825Stheraven    virtual char_type do_tolower(char_type) const;
492227825Stheraven    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
493227825Stheraven    virtual char_type do_widen(char) const;
494227825Stheraven    virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
495227825Stheraven    virtual char do_narrow(char_type, char __dfault) const;
496227825Stheraven    virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
497227825Stheraven};
498227825Stheraven
499227825Stheraventemplate <>
500249998Sdimclass _LIBCPP_TYPE_VIS ctype<char>
501227825Stheraven    : public locale::facet, public ctype_base
502227825Stheraven{
503227825Stheraven    const mask* __tab_;
504227825Stheraven    bool        __del_;
505227825Stheravenpublic:
506227825Stheraven    typedef char char_type;
507227825Stheraven
508227825Stheraven    explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);
509227825Stheraven
510227825Stheraven    _LIBCPP_ALWAYS_INLINE
511227825Stheraven    bool is(mask __m, char_type __c) const
512227825Stheraven    {
513232950Stheraven        return isascii(__c) ? __tab_[static_cast<int>(__c)] & __m : false;
514227825Stheraven    }
515227825Stheraven
516227825Stheraven    _LIBCPP_ALWAYS_INLINE
517227825Stheraven    const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
518227825Stheraven    {
519227825Stheraven        for (; __low != __high; ++__low, ++__vec)
520232950Stheraven            *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;
521227825Stheraven        return __low;
522227825Stheraven    }
523227825Stheraven
524227825Stheraven    _LIBCPP_ALWAYS_INLINE
525227825Stheraven    const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const
526227825Stheraven    {
527227825Stheraven        for (; __low != __high; ++__low)
528232950Stheraven            if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))
529227825Stheraven                break;
530227825Stheraven        return __low;
531227825Stheraven    }
532227825Stheraven
533227825Stheraven    _LIBCPP_ALWAYS_INLINE
534227825Stheraven    const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
535227825Stheraven    {
536227825Stheraven        for (; __low != __high; ++__low)
537232950Stheraven            if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))
538227825Stheraven                break;
539227825Stheraven        return __low;
540227825Stheraven    }
541227825Stheraven
542227825Stheraven    _LIBCPP_ALWAYS_INLINE
543227825Stheraven    char_type toupper(char_type __c) const
544227825Stheraven    {
545227825Stheraven        return do_toupper(__c);
546227825Stheraven    }
547227825Stheraven
548227825Stheraven    _LIBCPP_ALWAYS_INLINE
549227825Stheraven    const char_type* toupper(char_type* __low, const char_type* __high) const
550227825Stheraven    {
551227825Stheraven        return do_toupper(__low, __high);
552227825Stheraven    }
553227825Stheraven
554227825Stheraven    _LIBCPP_ALWAYS_INLINE
555227825Stheraven    char_type tolower(char_type __c) const
556227825Stheraven    {
557227825Stheraven        return do_tolower(__c);
558227825Stheraven    }
559227825Stheraven
560227825Stheraven    _LIBCPP_ALWAYS_INLINE
561227825Stheraven    const char_type* tolower(char_type* __low, const char_type* __high) const
562227825Stheraven    {
563227825Stheraven        return do_tolower(__low, __high);
564227825Stheraven    }
565227825Stheraven
566227825Stheraven    _LIBCPP_ALWAYS_INLINE
567227825Stheraven    char_type widen(char __c) const
568227825Stheraven    {
569227825Stheraven        return do_widen(__c);
570227825Stheraven    }
571227825Stheraven
572227825Stheraven    _LIBCPP_ALWAYS_INLINE
573227825Stheraven    const char* widen(const char* __low, const char* __high, char_type* __to) const
574227825Stheraven    {
575227825Stheraven        return do_widen(__low, __high, __to);
576227825Stheraven    }
577227825Stheraven
578227825Stheraven    _LIBCPP_ALWAYS_INLINE
579227825Stheraven    char narrow(char_type __c, char __dfault) const
580227825Stheraven    {
581227825Stheraven        return do_narrow(__c, __dfault);
582227825Stheraven    }
583227825Stheraven
584227825Stheraven    _LIBCPP_ALWAYS_INLINE
585227825Stheraven    const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
586227825Stheraven    {
587227825Stheraven        return do_narrow(__low, __high, __dfault, __to);
588227825Stheraven    }
589227825Stheraven
590227825Stheraven    static locale::id id;
591227825Stheraven
592227825Stheraven#ifdef _CACHED_RUNES
593227825Stheraven    static const size_t table_size = _CACHED_RUNES;
594227825Stheraven#else
595227825Stheraven    static const size_t table_size = 256;  // FIXME: Don't hardcode this.
596227825Stheraven#endif
597227825Stheraven    _LIBCPP_ALWAYS_INLINE const mask* table() const  _NOEXCEPT {return __tab_;}
598227825Stheraven    static const mask* classic_table()  _NOEXCEPT;
599249998Sdim#if defined(__GLIBC__) || defined(EMSCRIPTEN)
600227825Stheraven    static const int* __classic_upper_table() _NOEXCEPT;
601227825Stheraven    static const int* __classic_lower_table() _NOEXCEPT;
602227825Stheraven#endif
603253159Stheraven#if defined(__NetBSD__)
604253159Stheraven    static const short* __classic_upper_table() _NOEXCEPT;
605253159Stheraven    static const short* __classic_lower_table() _NOEXCEPT;
606253159Stheraven#endif
607227825Stheraven
608227825Stheravenprotected:
609227825Stheraven    ~ctype();
610227825Stheraven    virtual char_type do_toupper(char_type __c) const;
611227825Stheraven    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
612227825Stheraven    virtual char_type do_tolower(char_type __c) const;
613227825Stheraven    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
614227825Stheraven    virtual char_type do_widen(char __c) const;
615227825Stheraven    virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const;
616227825Stheraven    virtual char do_narrow(char_type __c, char __dfault) const;
617227825Stheraven    virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const;
618227825Stheraven};
619227825Stheraven
620227825Stheraven// template <class CharT> class ctype_byname;
621227825Stheraven
622249998Sdimtemplate <class _CharT> class _LIBCPP_TYPE_VIS ctype_byname;
623227825Stheraven
624227825Stheraventemplate <>
625249998Sdimclass _LIBCPP_TYPE_VIS ctype_byname<char>
626227825Stheraven    : public ctype<char>
627227825Stheraven{
628227825Stheraven    locale_t __l;
629227825Stheraven
630227825Stheravenpublic:
631227825Stheraven    explicit ctype_byname(const char*, size_t = 0);
632227825Stheraven    explicit ctype_byname(const string&, size_t = 0);
633227825Stheraven
634227825Stheravenprotected:
635227825Stheraven    ~ctype_byname();
636227825Stheraven    virtual char_type do_toupper(char_type) const;
637227825Stheraven    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
638227825Stheraven    virtual char_type do_tolower(char_type) const;
639227825Stheraven    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
640227825Stheraven};
641227825Stheraven
642227825Stheraventemplate <>
643249998Sdimclass _LIBCPP_TYPE_VIS ctype_byname<wchar_t>
644227825Stheraven    : public ctype<wchar_t>
645227825Stheraven{
646227825Stheraven    locale_t __l;
647227825Stheraven
648227825Stheravenpublic:
649227825Stheraven    explicit ctype_byname(const char*, size_t = 0);
650227825Stheraven    explicit ctype_byname(const string&, size_t = 0);
651227825Stheraven
652227825Stheravenprotected:
653227825Stheraven    ~ctype_byname();
654227825Stheraven    virtual bool do_is(mask __m, char_type __c) const;
655227825Stheraven    virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
656227825Stheraven    virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
657227825Stheraven    virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
658227825Stheraven    virtual char_type do_toupper(char_type) const;
659227825Stheraven    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
660227825Stheraven    virtual char_type do_tolower(char_type) const;
661227825Stheraven    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
662227825Stheraven    virtual char_type do_widen(char) const;
663227825Stheraven    virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
664227825Stheraven    virtual char do_narrow(char_type, char __dfault) const;
665227825Stheraven    virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
666227825Stheraven};
667227825Stheraven
668227825Stheraventemplate <class _CharT>
669227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
670227825Stheravenbool
671227825Stheravenisspace(_CharT __c, const locale& __loc)
672227825Stheraven{
673227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);
674227825Stheraven}
675227825Stheraven
676227825Stheraventemplate <class _CharT>
677227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
678227825Stheravenbool
679227825Stheravenisprint(_CharT __c, const locale& __loc)
680227825Stheraven{
681227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);
682227825Stheraven}
683227825Stheraven
684227825Stheraventemplate <class _CharT>
685227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
686227825Stheravenbool
687227825Stheraveniscntrl(_CharT __c, const locale& __loc)
688227825Stheraven{
689227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);
690227825Stheraven}
691227825Stheraven
692227825Stheraventemplate <class _CharT>
693227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
694227825Stheravenbool
695227825Stheravenisupper(_CharT __c, const locale& __loc)
696227825Stheraven{
697227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);
698227825Stheraven}
699227825Stheraven
700227825Stheraventemplate <class _CharT>
701227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
702227825Stheravenbool
703227825Stheravenislower(_CharT __c, const locale& __loc)
704227825Stheraven{
705227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);
706227825Stheraven}
707227825Stheraven
708227825Stheraventemplate <class _CharT>
709227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
710227825Stheravenbool
711227825Stheravenisalpha(_CharT __c, const locale& __loc)
712227825Stheraven{
713227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);
714227825Stheraven}
715227825Stheraven
716227825Stheraventemplate <class _CharT>
717227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
718227825Stheravenbool
719227825Stheravenisdigit(_CharT __c, const locale& __loc)
720227825Stheraven{
721227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);
722227825Stheraven}
723227825Stheraven
724227825Stheraventemplate <class _CharT>
725227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
726227825Stheravenbool
727227825Stheravenispunct(_CharT __c, const locale& __loc)
728227825Stheraven{
729227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);
730227825Stheraven}
731227825Stheraven
732227825Stheraventemplate <class _CharT>
733227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
734227825Stheravenbool
735227825Stheravenisxdigit(_CharT __c, const locale& __loc)
736227825Stheraven{
737227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);
738227825Stheraven}
739227825Stheraven
740227825Stheraventemplate <class _CharT>
741227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
742227825Stheravenbool
743227825Stheravenisalnum(_CharT __c, const locale& __loc)
744227825Stheraven{
745227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);
746227825Stheraven}
747227825Stheraven
748227825Stheraventemplate <class _CharT>
749227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
750227825Stheravenbool
751227825Stheravenisgraph(_CharT __c, const locale& __loc)
752227825Stheraven{
753227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
754227825Stheraven}
755227825Stheraven
756227825Stheraventemplate <class _CharT>
757227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
758227825Stheraven_CharT
759227825Stheraventoupper(_CharT __c, const locale& __loc)
760227825Stheraven{
761227825Stheraven    return use_facet<ctype<_CharT> >(__loc).toupper(__c);
762227825Stheraven}
763227825Stheraven
764227825Stheraventemplate <class _CharT>
765227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
766227825Stheraven_CharT
767227825Stheraventolower(_CharT __c, const locale& __loc)
768227825Stheraven{
769227825Stheraven    return use_facet<ctype<_CharT> >(__loc).tolower(__c);
770227825Stheraven}
771227825Stheraven
772227825Stheraven// codecvt_base
773227825Stheraven
774249998Sdimclass _LIBCPP_TYPE_VIS codecvt_base
775227825Stheraven{
776227825Stheravenpublic:
777227825Stheraven    _LIBCPP_ALWAYS_INLINE codecvt_base() {}
778227825Stheraven    enum result {ok, partial, error, noconv};
779227825Stheraven};
780227825Stheraven
781227825Stheraven// template <class internT, class externT, class stateT> class codecvt;
782227825Stheraven
783249998Sdimtemplate <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TYPE_VIS codecvt;
784227825Stheraven
785227825Stheraven// template <> class codecvt<char, char, mbstate_t>
786227825Stheraven
787227825Stheraventemplate <>
788249998Sdimclass _LIBCPP_TYPE_VIS codecvt<char, char, mbstate_t>
789227825Stheraven    : public locale::facet,
790227825Stheraven      public codecvt_base
791227825Stheraven{
792227825Stheravenpublic:
793227825Stheraven    typedef char      intern_type;
794227825Stheraven    typedef char      extern_type;
795227825Stheraven    typedef mbstate_t state_type;
796227825Stheraven
797227825Stheraven    _LIBCPP_ALWAYS_INLINE
798227825Stheraven    explicit codecvt(size_t __refs = 0)
799227825Stheraven        : locale::facet(__refs) {}
800227825Stheraven
801227825Stheraven    _LIBCPP_ALWAYS_INLINE
802227825Stheraven    result out(state_type& __st,
803227825Stheraven               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
804227825Stheraven               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
805227825Stheraven    {
806227825Stheraven        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
807227825Stheraven    }
808227825Stheraven
809227825Stheraven    _LIBCPP_ALWAYS_INLINE
810227825Stheraven    result unshift(state_type& __st,
811227825Stheraven                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
812227825Stheraven    {
813227825Stheraven        return do_unshift(__st, __to, __to_end, __to_nxt);
814227825Stheraven    }
815227825Stheraven
816227825Stheraven    _LIBCPP_ALWAYS_INLINE
817227825Stheraven    result in(state_type& __st,
818227825Stheraven              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
819227825Stheraven              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
820227825Stheraven    {
821227825Stheraven        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
822227825Stheraven    }
823227825Stheraven
824227825Stheraven    _LIBCPP_ALWAYS_INLINE
825227825Stheraven    int encoding() const  _NOEXCEPT
826227825Stheraven    {
827227825Stheraven        return do_encoding();
828227825Stheraven    }
829227825Stheraven
830227825Stheraven    _LIBCPP_ALWAYS_INLINE
831227825Stheraven    bool always_noconv() const  _NOEXCEPT
832227825Stheraven    {
833227825Stheraven        return do_always_noconv();
834227825Stheraven    }
835227825Stheraven
836227825Stheraven    _LIBCPP_ALWAYS_INLINE
837227825Stheraven    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
838227825Stheraven    {
839227825Stheraven        return do_length(__st, __frm, __end, __mx);
840227825Stheraven    }
841227825Stheraven
842227825Stheraven    _LIBCPP_ALWAYS_INLINE
843227825Stheraven    int max_length() const  _NOEXCEPT
844227825Stheraven    {
845227825Stheraven        return do_max_length();
846227825Stheraven    }
847227825Stheraven
848227825Stheraven    static locale::id id;
849227825Stheraven
850227825Stheravenprotected:
851227825Stheraven    _LIBCPP_ALWAYS_INLINE
852227825Stheraven    explicit codecvt(const char*, size_t __refs = 0)
853227825Stheraven        : locale::facet(__refs) {}
854227825Stheraven
855227825Stheraven    ~codecvt();
856227825Stheraven
857227825Stheraven    virtual result do_out(state_type& __st,
858227825Stheraven                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
859227825Stheraven                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
860227825Stheraven    virtual result do_in(state_type& __st,
861227825Stheraven                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
862227825Stheraven                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
863227825Stheraven    virtual result do_unshift(state_type& __st,
864227825Stheraven                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
865227825Stheraven    virtual int do_encoding() const  _NOEXCEPT;
866227825Stheraven    virtual bool do_always_noconv() const  _NOEXCEPT;
867227825Stheraven    virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
868227825Stheraven    virtual int do_max_length() const  _NOEXCEPT;
869227825Stheraven};
870227825Stheraven
871227825Stheraven// template <> class codecvt<wchar_t, char, mbstate_t>
872227825Stheraven
873227825Stheraventemplate <>
874249998Sdimclass _LIBCPP_TYPE_VIS codecvt<wchar_t, char, mbstate_t>
875227825Stheraven    : public locale::facet,
876227825Stheraven      public codecvt_base
877227825Stheraven{
878227825Stheraven    locale_t __l;
879227825Stheravenpublic:
880227825Stheraven    typedef wchar_t   intern_type;
881227825Stheraven    typedef char      extern_type;
882227825Stheraven    typedef mbstate_t state_type;
883227825Stheraven
884227825Stheraven    explicit codecvt(size_t __refs = 0);
885227825Stheraven
886227825Stheraven    _LIBCPP_ALWAYS_INLINE
887227825Stheraven    result out(state_type& __st,
888227825Stheraven               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
889227825Stheraven               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
890227825Stheraven    {
891227825Stheraven        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
892227825Stheraven    }
893227825Stheraven
894227825Stheraven    _LIBCPP_ALWAYS_INLINE
895227825Stheraven    result unshift(state_type& __st,
896227825Stheraven                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
897227825Stheraven    {
898227825Stheraven        return do_unshift(__st, __to, __to_end, __to_nxt);
899227825Stheraven    }
900227825Stheraven
901227825Stheraven    _LIBCPP_ALWAYS_INLINE
902227825Stheraven    result in(state_type& __st,
903227825Stheraven              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
904227825Stheraven              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
905227825Stheraven    {
906227825Stheraven        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
907227825Stheraven    }
908227825Stheraven
909227825Stheraven    _LIBCPP_ALWAYS_INLINE
910227825Stheraven    int encoding() const  _NOEXCEPT
911227825Stheraven    {
912227825Stheraven        return do_encoding();
913227825Stheraven    }
914227825Stheraven
915227825Stheraven    _LIBCPP_ALWAYS_INLINE
916227825Stheraven    bool always_noconv() const  _NOEXCEPT
917227825Stheraven    {
918227825Stheraven        return do_always_noconv();
919227825Stheraven    }
920227825Stheraven
921227825Stheraven    _LIBCPP_ALWAYS_INLINE
922227825Stheraven    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
923227825Stheraven    {
924227825Stheraven        return do_length(__st, __frm, __end, __mx);
925227825Stheraven    }
926227825Stheraven
927227825Stheraven    _LIBCPP_ALWAYS_INLINE
928227825Stheraven    int max_length() const  _NOEXCEPT
929227825Stheraven    {
930227825Stheraven        return do_max_length();
931227825Stheraven    }
932227825Stheraven
933227825Stheraven    static locale::id id;
934227825Stheraven
935227825Stheravenprotected:
936227825Stheraven    explicit codecvt(const char*, size_t __refs = 0);
937227825Stheraven
938227825Stheraven    ~codecvt();
939227825Stheraven
940227825Stheraven    virtual result do_out(state_type& __st,
941227825Stheraven                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
942227825Stheraven                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
943227825Stheraven    virtual result do_in(state_type& __st,
944227825Stheraven                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
945227825Stheraven                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
946227825Stheraven    virtual result do_unshift(state_type& __st,
947227825Stheraven                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
948227825Stheraven    virtual int do_encoding() const  _NOEXCEPT;
949227825Stheraven    virtual bool do_always_noconv() const  _NOEXCEPT;
950227825Stheraven    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
951227825Stheraven    virtual int do_max_length() const  _NOEXCEPT;
952227825Stheraven};
953227825Stheraven
954227825Stheraven// template <> class codecvt<char16_t, char, mbstate_t>
955227825Stheraven
956227825Stheraventemplate <>
957249998Sdimclass _LIBCPP_TYPE_VIS codecvt<char16_t, char, mbstate_t>
958227825Stheraven    : public locale::facet,
959227825Stheraven      public codecvt_base
960227825Stheraven{
961227825Stheravenpublic:
962227825Stheraven    typedef char16_t  intern_type;
963227825Stheraven    typedef char      extern_type;
964227825Stheraven    typedef mbstate_t state_type;
965227825Stheraven
966227825Stheraven    _LIBCPP_ALWAYS_INLINE
967227825Stheraven    explicit codecvt(size_t __refs = 0)
968227825Stheraven        : locale::facet(__refs) {}
969227825Stheraven
970227825Stheraven    _LIBCPP_ALWAYS_INLINE
971227825Stheraven    result out(state_type& __st,
972227825Stheraven               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
973227825Stheraven               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
974227825Stheraven    {
975227825Stheraven        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
976227825Stheraven    }
977227825Stheraven
978227825Stheraven    _LIBCPP_ALWAYS_INLINE
979227825Stheraven    result unshift(state_type& __st,
980227825Stheraven                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
981227825Stheraven    {
982227825Stheraven        return do_unshift(__st, __to, __to_end, __to_nxt);
983227825Stheraven    }
984227825Stheraven
985227825Stheraven    _LIBCPP_ALWAYS_INLINE
986227825Stheraven    result in(state_type& __st,
987227825Stheraven              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
988227825Stheraven              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
989227825Stheraven    {
990227825Stheraven        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
991227825Stheraven    }
992227825Stheraven
993227825Stheraven    _LIBCPP_ALWAYS_INLINE
994227825Stheraven    int encoding() const  _NOEXCEPT
995227825Stheraven    {
996227825Stheraven        return do_encoding();
997227825Stheraven    }
998227825Stheraven
999227825Stheraven    _LIBCPP_ALWAYS_INLINE
1000227825Stheraven    bool always_noconv() const  _NOEXCEPT
1001227825Stheraven    {
1002227825Stheraven        return do_always_noconv();
1003227825Stheraven    }
1004227825Stheraven
1005227825Stheraven    _LIBCPP_ALWAYS_INLINE
1006227825Stheraven    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
1007227825Stheraven    {
1008227825Stheraven        return do_length(__st, __frm, __end, __mx);
1009227825Stheraven    }
1010227825Stheraven
1011227825Stheraven    _LIBCPP_ALWAYS_INLINE
1012227825Stheraven    int max_length() const  _NOEXCEPT
1013227825Stheraven    {
1014227825Stheraven        return do_max_length();
1015227825Stheraven    }
1016227825Stheraven
1017227825Stheraven    static locale::id id;
1018227825Stheraven
1019227825Stheravenprotected:
1020227825Stheraven    _LIBCPP_ALWAYS_INLINE
1021227825Stheraven    explicit codecvt(const char*, size_t __refs = 0)
1022227825Stheraven        : locale::facet(__refs) {}
1023227825Stheraven
1024227825Stheraven    ~codecvt();
1025227825Stheraven
1026227825Stheraven    virtual result do_out(state_type& __st,
1027227825Stheraven                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1028227825Stheraven                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1029227825Stheraven    virtual result do_in(state_type& __st,
1030227825Stheraven                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1031227825Stheraven                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1032227825Stheraven    virtual result do_unshift(state_type& __st,
1033227825Stheraven                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1034227825Stheraven    virtual int do_encoding() const  _NOEXCEPT;
1035227825Stheraven    virtual bool do_always_noconv() const  _NOEXCEPT;
1036227825Stheraven    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
1037227825Stheraven    virtual int do_max_length() const  _NOEXCEPT;
1038227825Stheraven};
1039227825Stheraven
1040227825Stheraven// template <> class codecvt<char32_t, char, mbstate_t>
1041227825Stheraven
1042227825Stheraventemplate <>
1043249998Sdimclass _LIBCPP_TYPE_VIS codecvt<char32_t, char, mbstate_t>
1044227825Stheraven    : public locale::facet,
1045227825Stheraven      public codecvt_base
1046227825Stheraven{
1047227825Stheravenpublic:
1048227825Stheraven    typedef char32_t  intern_type;
1049227825Stheraven    typedef char      extern_type;
1050227825Stheraven    typedef mbstate_t state_type;
1051227825Stheraven
1052227825Stheraven    _LIBCPP_ALWAYS_INLINE
1053227825Stheraven    explicit codecvt(size_t __refs = 0)
1054227825Stheraven        : locale::facet(__refs) {}
1055227825Stheraven
1056227825Stheraven    _LIBCPP_ALWAYS_INLINE
1057227825Stheraven    result out(state_type& __st,
1058227825Stheraven               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1059227825Stheraven               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1060227825Stheraven    {
1061227825Stheraven        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1062227825Stheraven    }
1063227825Stheraven
1064227825Stheraven    _LIBCPP_ALWAYS_INLINE
1065227825Stheraven    result unshift(state_type& __st,
1066227825Stheraven                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1067227825Stheraven    {
1068227825Stheraven        return do_unshift(__st, __to, __to_end, __to_nxt);
1069227825Stheraven    }
1070227825Stheraven
1071227825Stheraven    _LIBCPP_ALWAYS_INLINE
1072227825Stheraven    result in(state_type& __st,
1073227825Stheraven              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1074227825Stheraven              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
1075227825Stheraven    {
1076227825Stheraven        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1077227825Stheraven    }
1078227825Stheraven
1079227825Stheraven    _LIBCPP_ALWAYS_INLINE
1080227825Stheraven    int encoding() const  _NOEXCEPT
1081227825Stheraven    {
1082227825Stheraven        return do_encoding();
1083227825Stheraven    }
1084227825Stheraven
1085227825Stheraven    _LIBCPP_ALWAYS_INLINE
1086227825Stheraven    bool always_noconv() const  _NOEXCEPT
1087227825Stheraven    {
1088227825Stheraven        return do_always_noconv();
1089227825Stheraven    }
1090227825Stheraven
1091227825Stheraven    _LIBCPP_ALWAYS_INLINE
1092227825Stheraven    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
1093227825Stheraven    {
1094227825Stheraven        return do_length(__st, __frm, __end, __mx);
1095227825Stheraven    }
1096227825Stheraven
1097227825Stheraven    _LIBCPP_ALWAYS_INLINE
1098227825Stheraven    int max_length() const  _NOEXCEPT
1099227825Stheraven    {
1100227825Stheraven        return do_max_length();
1101227825Stheraven    }
1102227825Stheraven
1103227825Stheraven    static locale::id id;
1104227825Stheraven
1105227825Stheravenprotected:
1106227825Stheraven    _LIBCPP_ALWAYS_INLINE
1107227825Stheraven    explicit codecvt(const char*, size_t __refs = 0)
1108227825Stheraven        : locale::facet(__refs) {}
1109227825Stheraven
1110227825Stheraven    ~codecvt();
1111227825Stheraven
1112227825Stheraven    virtual result do_out(state_type& __st,
1113227825Stheraven                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1114227825Stheraven                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1115227825Stheraven    virtual result do_in(state_type& __st,
1116227825Stheraven                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1117227825Stheraven                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1118227825Stheraven    virtual result do_unshift(state_type& __st,
1119227825Stheraven                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1120227825Stheraven    virtual int do_encoding() const  _NOEXCEPT;
1121227825Stheraven    virtual bool do_always_noconv() const  _NOEXCEPT;
1122227825Stheraven    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
1123227825Stheraven    virtual int do_max_length() const  _NOEXCEPT;
1124227825Stheraven};
1125227825Stheraven
1126227825Stheraven// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname
1127227825Stheraven
1128227825Stheraventemplate <class _InternT, class _ExternT, class _StateT>
1129249998Sdimclass _LIBCPP_TYPE_VIS codecvt_byname
1130227825Stheraven    : public codecvt<_InternT, _ExternT, _StateT>
1131227825Stheraven{
1132227825Stheravenpublic:
1133227825Stheraven    _LIBCPP_ALWAYS_INLINE
1134227825Stheraven    explicit codecvt_byname(const char* __nm, size_t __refs = 0)
1135227825Stheraven        : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {}
1136227825Stheraven    _LIBCPP_ALWAYS_INLINE
1137227825Stheraven    explicit codecvt_byname(const string& __nm, size_t __refs = 0)
1138227825Stheraven        : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}
1139227825Stheravenprotected:
1140227825Stheraven    ~codecvt_byname();
1141227825Stheraven};
1142227825Stheraven
1143227825Stheraventemplate <class _InternT, class _ExternT, class _StateT>
1144227825Stheravencodecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
1145227825Stheraven{
1146227825Stheraven}
1147227825Stheraven
1148242945Stheraven_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char, char, mbstate_t>)
1149242945Stheraven_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<wchar_t, char, mbstate_t>)
1150242945Stheraven_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char16_t, char, mbstate_t>)
1151242945Stheraven_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char32_t, char, mbstate_t>)
1152227825Stheraven
1153249998Sdim_LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
1154227825Stheraven
1155232950Stheraventemplate <size_t _Np>
1156227825Stheravenstruct __narrow_to_utf8
1157227825Stheraven{
1158227825Stheraven    template <class _OutputIterator, class _CharT>
1159227825Stheraven    _OutputIterator
1160227825Stheraven    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const;
1161227825Stheraven};
1162227825Stheraven
1163227825Stheraventemplate <>
1164227825Stheravenstruct __narrow_to_utf8<8>
1165227825Stheraven{
1166227825Stheraven    template <class _OutputIterator, class _CharT>
1167227825Stheraven    _LIBCPP_ALWAYS_INLINE
1168227825Stheraven    _OutputIterator
1169227825Stheraven    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
1170227825Stheraven    {
1171227825Stheraven        for (; __wb < __we; ++__wb, ++__s)
1172227825Stheraven            *__s = *__wb;
1173227825Stheraven        return __s;
1174227825Stheraven    }
1175227825Stheraven};
1176227825Stheraven
1177227825Stheraventemplate <>
1178227825Stheravenstruct __narrow_to_utf8<16>
1179227825Stheraven    : public codecvt<char16_t, char, mbstate_t>
1180227825Stheraven{
1181227825Stheraven    _LIBCPP_ALWAYS_INLINE
1182227825Stheraven    __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
1183227825Stheraven
1184227825Stheraven    ~__narrow_to_utf8();
1185227825Stheraven
1186227825Stheraven    template <class _OutputIterator, class _CharT>
1187227825Stheraven    _LIBCPP_ALWAYS_INLINE
1188227825Stheraven    _OutputIterator
1189227825Stheraven    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
1190227825Stheraven    {
1191227825Stheraven        result __r = ok;
1192227825Stheraven        mbstate_t __mb;
1193227825Stheraven        while (__wb < __we && __r != error)
1194227825Stheraven        {
1195227825Stheraven            const int __sz = 32;
1196227825Stheraven            char __buf[__sz];
1197227825Stheraven            char* __bn;
1198227825Stheraven            const char16_t* __wn = (const char16_t*)__wb;
1199227825Stheraven            __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn,
1200227825Stheraven                         __buf, __buf+__sz, __bn);
1201227825Stheraven            if (__r == codecvt_base::error || __wn == (const char16_t*)__wb)
1202227825Stheraven                __throw_runtime_error("locale not supported");
1203227825Stheraven            for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
1204227825Stheraven                *__s = *__p;
1205227825Stheraven            __wb = (const _CharT*)__wn;
1206227825Stheraven        }
1207227825Stheraven        return __s;
1208227825Stheraven    }
1209227825Stheraven};
1210227825Stheraven
1211227825Stheraventemplate <>
1212227825Stheravenstruct __narrow_to_utf8<32>
1213227825Stheraven    : public codecvt<char32_t, char, mbstate_t>
1214227825Stheraven{
1215227825Stheraven    _LIBCPP_ALWAYS_INLINE
1216227825Stheraven    __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
1217227825Stheraven
1218227825Stheraven    ~__narrow_to_utf8();
1219227825Stheraven
1220227825Stheraven    template <class _OutputIterator, class _CharT>
1221227825Stheraven    _LIBCPP_ALWAYS_INLINE
1222227825Stheraven    _OutputIterator
1223227825Stheraven    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
1224227825Stheraven    {
1225227825Stheraven        result __r = ok;
1226227825Stheraven        mbstate_t __mb;
1227227825Stheraven        while (__wb < __we && __r != error)
1228227825Stheraven        {
1229227825Stheraven            const int __sz = 32;
1230227825Stheraven            char __buf[__sz];
1231227825Stheraven            char* __bn;
1232227825Stheraven            const char32_t* __wn = (const char32_t*)__wb;
1233227825Stheraven            __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn,
1234227825Stheraven                         __buf, __buf+__sz, __bn);
1235227825Stheraven            if (__r == codecvt_base::error || __wn == (const char32_t*)__wb)
1236227825Stheraven                __throw_runtime_error("locale not supported");
1237227825Stheraven            for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
1238227825Stheraven                *__s = *__p;
1239227825Stheraven            __wb = (const _CharT*)__wn;
1240227825Stheraven        }
1241227825Stheraven        return __s;
1242227825Stheraven    }
1243227825Stheraven};
1244227825Stheraven
1245232950Stheraventemplate <size_t _Np>
1246227825Stheravenstruct __widen_from_utf8
1247227825Stheraven{
1248227825Stheraven    template <class _OutputIterator>
1249227825Stheraven    _OutputIterator
1250227825Stheraven    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const;
1251227825Stheraven};
1252227825Stheraven
1253227825Stheraventemplate <>
1254227825Stheravenstruct __widen_from_utf8<8>
1255227825Stheraven{
1256227825Stheraven    template <class _OutputIterator>
1257227825Stheraven    _LIBCPP_ALWAYS_INLINE
1258227825Stheraven    _OutputIterator
1259227825Stheraven    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
1260227825Stheraven    {
1261227825Stheraven        for (; __nb < __ne; ++__nb, ++__s)
1262227825Stheraven            *__s = *__nb;
1263227825Stheraven        return __s;
1264227825Stheraven    }
1265227825Stheraven};
1266227825Stheraven
1267227825Stheraventemplate <>
1268227825Stheravenstruct __widen_from_utf8<16>
1269227825Stheraven    : public codecvt<char16_t, char, mbstate_t>
1270227825Stheraven{
1271227825Stheraven    _LIBCPP_ALWAYS_INLINE
1272227825Stheraven    __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
1273227825Stheraven
1274227825Stheraven    ~__widen_from_utf8();
1275227825Stheraven
1276227825Stheraven    template <class _OutputIterator>
1277227825Stheraven    _LIBCPP_ALWAYS_INLINE
1278227825Stheraven    _OutputIterator
1279227825Stheraven    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
1280227825Stheraven    {
1281227825Stheraven        result __r = ok;
1282227825Stheraven        mbstate_t __mb;
1283227825Stheraven        while (__nb < __ne && __r != error)
1284227825Stheraven        {
1285227825Stheraven            const int __sz = 32;
1286227825Stheraven            char16_t __buf[__sz];
1287227825Stheraven            char16_t* __bn;
1288227825Stheraven            const char* __nn = __nb;
1289227825Stheraven            __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
1290227825Stheraven                        __buf, __buf+__sz, __bn);
1291227825Stheraven            if (__r == codecvt_base::error || __nn == __nb)
1292227825Stheraven                __throw_runtime_error("locale not supported");
1293227825Stheraven            for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)
1294227825Stheraven                *__s = (wchar_t)*__p;
1295227825Stheraven            __nb = __nn;
1296227825Stheraven        }
1297227825Stheraven        return __s;
1298227825Stheraven    }
1299227825Stheraven};
1300227825Stheraven
1301227825Stheraventemplate <>
1302227825Stheravenstruct __widen_from_utf8<32>
1303227825Stheraven    : public codecvt<char32_t, char, mbstate_t>
1304227825Stheraven{
1305227825Stheraven    _LIBCPP_ALWAYS_INLINE
1306227825Stheraven    __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
1307227825Stheraven
1308227825Stheraven    ~__widen_from_utf8();
1309227825Stheraven
1310227825Stheraven    template <class _OutputIterator>
1311227825Stheraven    _LIBCPP_ALWAYS_INLINE
1312227825Stheraven    _OutputIterator
1313227825Stheraven    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
1314227825Stheraven    {
1315227825Stheraven        result __r = ok;
1316227825Stheraven        mbstate_t __mb;
1317227825Stheraven        while (__nb < __ne && __r != error)
1318227825Stheraven        {
1319227825Stheraven            const int __sz = 32;
1320227825Stheraven            char32_t __buf[__sz];
1321227825Stheraven            char32_t* __bn;
1322227825Stheraven            const char* __nn = __nb;
1323227825Stheraven            __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
1324227825Stheraven                        __buf, __buf+__sz, __bn);
1325227825Stheraven            if (__r == codecvt_base::error || __nn == __nb)
1326227825Stheraven                __throw_runtime_error("locale not supported");
1327227825Stheraven            for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)
1328227825Stheraven                *__s = (wchar_t)*__p;
1329227825Stheraven            __nb = __nn;
1330227825Stheraven        }
1331227825Stheraven        return __s;
1332227825Stheraven    }
1333227825Stheraven};
1334227825Stheraven
1335227825Stheraven// template <class charT> class numpunct
1336227825Stheraven
1337249998Sdimtemplate <class _CharT> class _LIBCPP_TYPE_VIS numpunct;
1338227825Stheraven
1339227825Stheraventemplate <>
1340249998Sdimclass _LIBCPP_TYPE_VIS numpunct<char>
1341227825Stheraven    : public locale::facet
1342227825Stheraven{
1343227825Stheravenpublic:
1344227825Stheraven    typedef char char_type;
1345227825Stheraven    typedef basic_string<char_type> string_type;
1346227825Stheraven
1347227825Stheraven    explicit numpunct(size_t __refs = 0);
1348227825Stheraven
1349227825Stheraven    _LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();}
1350227825Stheraven    _LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();}
1351227825Stheraven    _LIBCPP_ALWAYS_INLINE string grouping() const         {return do_grouping();}
1352227825Stheraven    _LIBCPP_ALWAYS_INLINE string_type truename() const    {return do_truename();}
1353227825Stheraven    _LIBCPP_ALWAYS_INLINE string_type falsename() const   {return do_falsename();}
1354227825Stheraven
1355227825Stheraven    static locale::id id;
1356227825Stheraven
1357227825Stheravenprotected:
1358227825Stheraven    ~numpunct();
1359227825Stheraven    virtual char_type do_decimal_point() const;
1360227825Stheraven    virtual char_type do_thousands_sep() const;
1361227825Stheraven    virtual string do_grouping() const;
1362227825Stheraven    virtual string_type do_truename() const;
1363227825Stheraven    virtual string_type do_falsename() const;
1364227825Stheraven
1365227825Stheraven    char_type __decimal_point_;
1366227825Stheraven    char_type __thousands_sep_;
1367227825Stheraven    string __grouping_;
1368227825Stheraven};
1369227825Stheraven
1370227825Stheraventemplate <>
1371249998Sdimclass _LIBCPP_TYPE_VIS numpunct<wchar_t>
1372227825Stheraven    : public locale::facet
1373227825Stheraven{
1374227825Stheravenpublic:
1375227825Stheraven    typedef wchar_t char_type;
1376227825Stheraven    typedef basic_string<char_type> string_type;
1377227825Stheraven
1378227825Stheraven    explicit numpunct(size_t __refs = 0);
1379227825Stheraven
1380227825Stheraven    _LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();}
1381227825Stheraven    _LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();}
1382227825Stheraven    _LIBCPP_ALWAYS_INLINE string grouping() const         {return do_grouping();}
1383227825Stheraven    _LIBCPP_ALWAYS_INLINE string_type truename() const    {return do_truename();}
1384227825Stheraven    _LIBCPP_ALWAYS_INLINE string_type falsename() const   {return do_falsename();}
1385227825Stheraven
1386227825Stheraven    static locale::id id;
1387227825Stheraven
1388227825Stheravenprotected:
1389227825Stheraven    ~numpunct();
1390227825Stheraven    virtual char_type do_decimal_point() const;
1391227825Stheraven    virtual char_type do_thousands_sep() const;
1392227825Stheraven    virtual string do_grouping() const;
1393227825Stheraven    virtual string_type do_truename() const;
1394227825Stheraven    virtual string_type do_falsename() const;
1395227825Stheraven
1396227825Stheraven    char_type __decimal_point_;
1397227825Stheraven    char_type __thousands_sep_;
1398227825Stheraven    string __grouping_;
1399227825Stheraven};
1400227825Stheraven
1401227825Stheraven// template <class charT> class numpunct_byname
1402227825Stheraven
1403249998Sdimtemplate <class charT> class _LIBCPP_TYPE_VIS numpunct_byname;
1404227825Stheraven
1405227825Stheraventemplate <>
1406249998Sdimclass _LIBCPP_TYPE_VIS numpunct_byname<char>
1407227825Stheraven: public numpunct<char>
1408227825Stheraven{
1409227825Stheravenpublic:
1410227825Stheraven    typedef char char_type;
1411227825Stheraven    typedef basic_string<char_type> string_type;
1412227825Stheraven
1413227825Stheraven    explicit numpunct_byname(const char* __nm, size_t __refs = 0);
1414227825Stheraven    explicit numpunct_byname(const string& __nm, size_t __refs = 0);
1415227825Stheraven
1416227825Stheravenprotected:
1417227825Stheraven    ~numpunct_byname();
1418227825Stheraven
1419227825Stheravenprivate:
1420227825Stheraven    void __init(const char*);
1421227825Stheraven};
1422227825Stheraven
1423227825Stheraventemplate <>
1424249998Sdimclass _LIBCPP_TYPE_VIS numpunct_byname<wchar_t>
1425227825Stheraven: public numpunct<wchar_t>
1426227825Stheraven{
1427227825Stheravenpublic:
1428227825Stheraven    typedef wchar_t char_type;
1429227825Stheraven    typedef basic_string<char_type> string_type;
1430227825Stheraven
1431227825Stheraven    explicit numpunct_byname(const char* __nm, size_t __refs = 0);
1432227825Stheraven    explicit numpunct_byname(const string& __nm, size_t __refs = 0);
1433227825Stheraven
1434227825Stheravenprotected:
1435227825Stheraven    ~numpunct_byname();
1436227825Stheraven
1437227825Stheravenprivate:
1438227825Stheraven    void __init(const char*);
1439227825Stheraven};
1440227825Stheraven
1441227825Stheraven_LIBCPP_END_NAMESPACE_STD
1442227825Stheraven
1443227825Stheraven#endif  // _LIBCPP___LOCALE
1444