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>
22262801Sdim#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
23227825Stheraven# include <support/win32/locale_win32.h>
24278724Sdim#elif defined(_AIX)
25262801Sdim# include <support/ibm/xlocale.h>
26278724Sdim#elif defined(__ANDROID__)
27278724Sdim// Android gained the locale aware functions in L (API level 21)
28278724Sdim# include <android/api-level.h>
29278724Sdim# if __ANDROID_API__ <= 20
30278724Sdim#  include <support/android/locale_bionic.h>
31278724Sdim# endif
32278724Sdim#elif defined(__sun__)
33278724Sdim# include <support/solaris/xlocale.h>
34278724Sdim#elif defined(_NEWLIB_VERSION)
35278724Sdim# include <support/newlib/xlocale.h>
36278724Sdim#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
37278724Sdim    || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
38227825Stheraven# include <xlocale.h>
39278724Sdim#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
40227825Stheraven
41227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
42227825Stheraven#pragma GCC system_header
43227825Stheraven#endif
44227825Stheraven
45227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
46227825Stheraven
47249998Sdimclass _LIBCPP_TYPE_VIS locale;
48227825Stheraven
49241903Sdimtemplate <class _Facet>
50241903Sdim_LIBCPP_INLINE_VISIBILITY
51241903Sdimbool
52241903Sdimhas_facet(const locale&) _NOEXCEPT;
53227825Stheraven
54241903Sdimtemplate <class _Facet>
55241903Sdim_LIBCPP_INLINE_VISIBILITY
56241903Sdimconst _Facet&
57241903Sdimuse_facet(const locale&);
58241903Sdim
59249998Sdimclass _LIBCPP_TYPE_VIS locale
60227825Stheraven{
61227825Stheravenpublic:
62227825Stheraven    // types:
63249998Sdim    class _LIBCPP_TYPE_VIS facet;
64249998Sdim    class _LIBCPP_TYPE_VIS id;
65227825Stheraven
66227825Stheraven    typedef int category;
67227825Stheraven    static const category // values assigned here are for exposition only
68227825Stheraven        none     = 0,
69227825Stheraven        collate  = LC_COLLATE_MASK,
70227825Stheraven        ctype    = LC_CTYPE_MASK,
71227825Stheraven        monetary = LC_MONETARY_MASK,
72227825Stheraven        numeric  = LC_NUMERIC_MASK,
73227825Stheraven        time     = LC_TIME_MASK,
74227825Stheraven        messages = LC_MESSAGES_MASK,
75227825Stheraven        all = collate | ctype | monetary | numeric | time | messages;
76227825Stheraven
77227825Stheraven    // construct/copy/destroy:
78227825Stheraven    locale()  _NOEXCEPT;
79227825Stheraven    locale(const locale&)  _NOEXCEPT;
80227825Stheraven    explicit locale(const char*);
81227825Stheraven    explicit locale(const string&);
82227825Stheraven    locale(const locale&, const char*, category);
83227825Stheraven    locale(const locale&, const string&, category);
84227825Stheraven    template <class _Facet>
85227825Stheraven        _LIBCPP_INLINE_VISIBILITY locale(const locale&, _Facet*);
86227825Stheraven    locale(const locale&, const locale&, category);
87227825Stheraven
88227825Stheraven    ~locale();
89227825Stheraven
90227825Stheraven    const locale& operator=(const locale&)  _NOEXCEPT;
91227825Stheraven
92227825Stheraven    template <class _Facet> locale combine(const locale&) const;
93227825Stheraven
94227825Stheraven    // locale operations:
95227825Stheraven    string name() const;
96227825Stheraven    bool operator==(const locale&) const;
97227825Stheraven    bool operator!=(const locale& __y) const {return !(*this == __y);}
98227825Stheraven    template <class _CharT, class _Traits, class _Allocator>
99227825Stheraven      bool operator()(const basic_string<_CharT, _Traits, _Allocator>&,
100227825Stheraven                      const basic_string<_CharT, _Traits, _Allocator>&) const;
101227825Stheraven
102227825Stheraven    // global locale objects:
103227825Stheraven    static locale global(const locale&);
104227825Stheraven    static const locale& classic();
105227825Stheraven
106227825Stheravenprivate:
107227825Stheraven    class __imp;
108227825Stheraven    __imp* __locale_;
109227825Stheraven
110227825Stheraven    void __install_ctor(const locale&, facet*, long);
111227825Stheraven    static locale& __global();
112227825Stheraven    bool has_facet(id&) const;
113227825Stheraven    const facet* use_facet(id&) const;
114227825Stheraven
115227825Stheraven    template <class _Facet> friend bool has_facet(const locale&)  _NOEXCEPT;
116227825Stheraven    template <class _Facet> friend const _Facet& use_facet(const locale&);
117227825Stheraven};
118227825Stheraven
119249998Sdimclass _LIBCPP_TYPE_VIS locale::facet
120227825Stheraven    : public __shared_count
121227825Stheraven{
122227825Stheravenprotected:
123227825Stheraven    _LIBCPP_INLINE_VISIBILITY
124227825Stheraven    explicit facet(size_t __refs = 0)
125227825Stheraven        : __shared_count(static_cast<long>(__refs)-1) {}
126227825Stheraven
127227825Stheraven    virtual ~facet();
128227825Stheraven
129227825Stheraven//    facet(const facet&) = delete;     // effectively done in __shared_count
130227825Stheraven//    void operator=(const facet&) = delete;
131227825Stheravenprivate:
132227825Stheraven    virtual void __on_zero_shared() _NOEXCEPT;
133227825Stheraven};
134227825Stheraven
135249998Sdimclass _LIBCPP_TYPE_VIS locale::id
136227825Stheraven{
137227825Stheraven    once_flag      __flag_;
138227825Stheraven    int32_t        __id_;
139227825Stheraven
140227825Stheraven    static int32_t __next_id;
141227825Stheravenpublic:
142241903Sdim    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {}
143227825Stheravenprivate:
144227825Stheraven    void __init();
145227825Stheraven    void operator=(const id&); // = delete;
146227825Stheraven    id(const id&); // = delete;
147227825Stheravenpublic:  // only needed for tests
148227825Stheraven    long __get();
149227825Stheraven
150227825Stheraven    friend class locale;
151227825Stheraven    friend class locale::__imp;
152227825Stheraven};
153227825Stheraven
154227825Stheraventemplate <class _Facet>
155227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
156227825Stheravenlocale::locale(const locale& __other, _Facet* __f)
157227825Stheraven{
158227825Stheraven    __install_ctor(__other, __f, __f ? __f->id.__get() : 0);
159227825Stheraven}
160227825Stheraven
161227825Stheraventemplate <class _Facet>
162227825Stheravenlocale
163227825Stheravenlocale::combine(const locale& __other) const
164227825Stheraven{
165227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS
166227825Stheraven    if (!_VSTD::has_facet<_Facet>(__other))
167227825Stheraven        throw runtime_error("locale::combine: locale missing facet");
168227825Stheraven#endif  // _LIBCPP_NO_EXCEPTIONS
169227825Stheraven    return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other)));
170227825Stheraven}
171227825Stheraven
172227825Stheraventemplate <class _Facet>
173227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
174227825Stheravenbool
175227825Stheravenhas_facet(const locale& __l)  _NOEXCEPT
176227825Stheraven{
177227825Stheraven    return __l.has_facet(_Facet::id);
178227825Stheraven}
179227825Stheraven
180227825Stheraventemplate <class _Facet>
181227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
182227825Stheravenconst _Facet&
183227825Stheravenuse_facet(const locale& __l)
184227825Stheraven{
185227825Stheraven    return static_cast<const _Facet&>(*__l.use_facet(_Facet::id));
186227825Stheraven}
187227825Stheraven
188227825Stheraven// template <class _CharT> class collate;
189227825Stheraven
190227825Stheraventemplate <class _CharT>
191262801Sdimclass _LIBCPP_TYPE_VIS_ONLY collate
192227825Stheraven    : public locale::facet
193227825Stheraven{
194227825Stheravenpublic:
195227825Stheraven    typedef _CharT char_type;
196227825Stheraven    typedef basic_string<char_type> string_type;
197227825Stheraven
198227825Stheraven    _LIBCPP_INLINE_VISIBILITY
199227825Stheraven    explicit collate(size_t __refs = 0)
200227825Stheraven        : locale::facet(__refs) {}
201227825Stheraven
202227825Stheraven    _LIBCPP_INLINE_VISIBILITY
203227825Stheraven    int compare(const char_type* __lo1, const char_type* __hi1,
204227825Stheraven                const char_type* __lo2, const char_type* __hi2) const
205227825Stheraven    {
206227825Stheraven        return do_compare(__lo1, __hi1, __lo2, __hi2);
207227825Stheraven    }
208227825Stheraven
209227825Stheraven    _LIBCPP_INLINE_VISIBILITY
210227825Stheraven    string_type transform(const char_type* __lo, const char_type* __hi) const
211227825Stheraven    {
212227825Stheraven        return do_transform(__lo, __hi);
213227825Stheraven    }
214227825Stheraven
215227825Stheraven    _LIBCPP_INLINE_VISIBILITY
216227825Stheraven    long hash(const char_type* __lo, const char_type* __hi) const
217227825Stheraven    {
218227825Stheraven        return do_hash(__lo, __hi);
219227825Stheraven    }
220227825Stheraven
221227825Stheraven    static locale::id id;
222227825Stheraven
223227825Stheravenprotected:
224227825Stheraven    ~collate();
225227825Stheraven    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
226227825Stheraven                           const char_type* __lo2, const char_type* __hi2) const;
227227825Stheraven    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const
228227825Stheraven        {return string_type(__lo, __hi);}
229227825Stheraven    virtual long do_hash(const char_type* __lo, const char_type* __hi) const;
230227825Stheraven};
231227825Stheraven
232227825Stheraventemplate <class _CharT> locale::id collate<_CharT>::id;
233227825Stheraven
234227825Stheraventemplate <class _CharT>
235227825Stheravencollate<_CharT>::~collate()
236227825Stheraven{
237227825Stheraven}
238227825Stheraven
239227825Stheraventemplate <class _CharT>
240227825Stheravenint
241227825Stheravencollate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1,
242227825Stheraven                            const char_type* __lo2, const char_type* __hi2) const
243227825Stheraven{
244227825Stheraven    for (; __lo2 != __hi2; ++__lo1, ++__lo2)
245227825Stheraven    {
246227825Stheraven        if (__lo1 == __hi1 || *__lo1 < *__lo2)
247227825Stheraven            return -1;
248227825Stheraven        if (*__lo2 < *__lo1)
249227825Stheraven            return 1;
250227825Stheraven    }
251227825Stheraven    return __lo1 != __hi1;
252227825Stheraven}
253227825Stheraven
254227825Stheraventemplate <class _CharT>
255227825Stheravenlong
256227825Stheravencollate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
257227825Stheraven{
258227825Stheraven    size_t __h = 0;
259227825Stheraven    const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8;
260227825Stheraven    const size_t __mask = size_t(0xF) << (__sr + 4);
261227825Stheraven    for(const char_type* __p = __lo; __p != __hi; ++__p)
262227825Stheraven    {
263232950Stheraven        __h = (__h << 4) + static_cast<size_t>(*__p);
264227825Stheraven        size_t __g = __h & __mask;
265227825Stheraven        __h ^= __g | (__g >> __sr);
266227825Stheraven    }
267227825Stheraven    return static_cast<long>(__h);
268227825Stheraven}
269227825Stheraven
270262801Sdim_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<char>)
271262801Sdim_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<wchar_t>)
272227825Stheraven
273227825Stheraven// template <class CharT> class collate_byname;
274227825Stheraven
275262801Sdimtemplate <class _CharT> class _LIBCPP_TYPE_VIS_ONLY collate_byname;
276227825Stheraven
277227825Stheraventemplate <>
278249998Sdimclass _LIBCPP_TYPE_VIS collate_byname<char>
279227825Stheraven    : public collate<char>
280227825Stheraven{
281227825Stheraven    locale_t __l;
282227825Stheravenpublic:
283227825Stheraven    typedef char char_type;
284227825Stheraven    typedef basic_string<char_type> string_type;
285227825Stheraven
286227825Stheraven    explicit collate_byname(const char* __n, size_t __refs = 0);
287227825Stheraven    explicit collate_byname(const string& __n, size_t __refs = 0);
288227825Stheraven
289227825Stheravenprotected:
290227825Stheraven    ~collate_byname();
291227825Stheraven    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
292227825Stheraven                           const char_type* __lo2, const char_type* __hi2) const;
293227825Stheraven    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
294227825Stheraven};
295227825Stheraven
296227825Stheraventemplate <>
297249998Sdimclass _LIBCPP_TYPE_VIS collate_byname<wchar_t>
298227825Stheraven    : public collate<wchar_t>
299227825Stheraven{
300227825Stheraven    locale_t __l;
301227825Stheravenpublic:
302227825Stheraven    typedef wchar_t char_type;
303227825Stheraven    typedef basic_string<char_type> string_type;
304227825Stheraven
305227825Stheraven    explicit collate_byname(const char* __n, size_t __refs = 0);
306227825Stheraven    explicit collate_byname(const string& __n, size_t __refs = 0);
307227825Stheraven
308227825Stheravenprotected:
309227825Stheraven    ~collate_byname();
310227825Stheraven
311227825Stheraven    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
312227825Stheraven                           const char_type* __lo2, const char_type* __hi2) const;
313227825Stheraven    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
314227825Stheraven};
315227825Stheraven
316227825Stheraventemplate <class _CharT, class _Traits, class _Allocator>
317227825Stheravenbool
318227825Stheravenlocale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
319227825Stheraven                   const basic_string<_CharT, _Traits, _Allocator>& __y) const
320227825Stheraven{
321227825Stheraven    return _VSTD::use_facet<_VSTD::collate<_CharT> >(*this).compare(
322227825Stheraven                                       __x.data(), __x.data() + __x.size(),
323227825Stheraven                                       __y.data(), __y.data() + __y.size()) < 0;
324227825Stheraven}
325227825Stheraven
326227825Stheraven// template <class charT> class ctype
327227825Stheraven
328249998Sdimclass _LIBCPP_TYPE_VIS ctype_base
329227825Stheraven{
330227825Stheravenpublic:
331249998Sdim#ifdef __GLIBC__
332227825Stheraven    typedef unsigned short mask;
333227825Stheraven    static const mask space  = _ISspace;
334227825Stheraven    static const mask print  = _ISprint;
335227825Stheraven    static const mask cntrl  = _IScntrl;
336227825Stheraven    static const mask upper  = _ISupper;
337227825Stheraven    static const mask lower  = _ISlower;
338227825Stheraven    static const mask alpha  = _ISalpha;
339227825Stheraven    static const mask digit  = _ISdigit;
340227825Stheraven    static const mask punct  = _ISpunct;
341227825Stheraven    static const mask xdigit = _ISxdigit;
342227825Stheraven    static const mask blank  = _ISblank;
343249998Sdim#elif defined(_WIN32)
344227825Stheraven    typedef unsigned short mask;
345227825Stheraven    static const mask space  = _SPACE;
346227825Stheraven    static const mask print  = _BLANK|_PUNCT|_ALPHA|_DIGIT;
347227825Stheraven    static const mask cntrl  = _CONTROL;
348227825Stheraven    static const mask upper  = _UPPER;
349227825Stheraven    static const mask lower  = _LOWER;
350227825Stheraven    static const mask alpha  = _ALPHA;
351227825Stheraven    static const mask digit  = _DIGIT;
352227825Stheraven    static const mask punct  = _PUNCT;
353227825Stheraven    static const mask xdigit = _HEX;
354227825Stheraven    static const mask blank  = _BLANK;
355278724Sdim#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__ANDROID__)
356249998Sdim#ifdef __APPLE__
357227825Stheraven    typedef __uint32_t mask;
358249998Sdim#elif defined(__FreeBSD__)
359227825Stheraven    typedef unsigned long mask;
360262801Sdim#elif defined(__EMSCRIPTEN__) ||  defined(__NetBSD__)
361249998Sdim    typedef unsigned short mask;
362278724Sdim#elif defined(__ANDROID__)
363278724Sdim    typedef unsigned char mask;
364227825Stheraven#endif
365227825Stheraven    static const mask space  = _CTYPE_S;
366227825Stheraven    static const mask print  = _CTYPE_R;
367227825Stheraven    static const mask cntrl  = _CTYPE_C;
368227825Stheraven    static const mask upper  = _CTYPE_U;
369227825Stheraven    static const mask lower  = _CTYPE_L;
370227825Stheraven    static const mask alpha  = _CTYPE_A;
371227825Stheraven    static const mask digit  = _CTYPE_D;
372227825Stheraven    static const mask punct  = _CTYPE_P;
373278724Sdim# if defined(__ANDROID__)
374278724Sdim    static const mask xdigit = _CTYPE_X | _CTYPE_D;
375278724Sdim# else
376227825Stheraven    static const mask xdigit = _CTYPE_X;
377278724Sdim# endif
378278724Sdim
379253159Stheraven# if defined(__NetBSD__)
380253159Stheraven    static const mask blank  = _CTYPE_BL;
381253159Stheraven# else
382227825Stheraven    static const mask blank  = _CTYPE_B;
383253159Stheraven# endif
384262801Sdim#elif defined(__sun__) || defined(_AIX)
385232950Stheraven    typedef unsigned int mask;
386232950Stheraven    static const mask space  = _ISSPACE;
387232950Stheraven    static const mask print  = _ISPRINT;
388232950Stheraven    static const mask cntrl  = _ISCNTRL;
389232950Stheraven    static const mask upper  = _ISUPPER;
390232950Stheraven    static const mask lower  = _ISLOWER;
391232950Stheraven    static const mask alpha  = _ISALPHA;
392232950Stheraven    static const mask digit  = _ISDIGIT;
393232950Stheraven    static const mask punct  = _ISPUNCT;
394232950Stheraven    static const mask xdigit = _ISXDIGIT;
395232950Stheraven    static const mask blank  = _ISBLANK;
396262801Sdim#else  // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__ || __EMSCRIPTEN__ || __sun__
397227825Stheraven    typedef unsigned long mask;
398227825Stheraven    static const mask space  = 1<<0;
399227825Stheraven    static const mask print  = 1<<1;
400227825Stheraven    static const mask cntrl  = 1<<2;
401227825Stheraven    static const mask upper  = 1<<3;
402227825Stheraven    static const mask lower  = 1<<4;
403227825Stheraven    static const mask alpha  = 1<<5;
404227825Stheraven    static const mask digit  = 1<<6;
405227825Stheraven    static const mask punct  = 1<<7;
406227825Stheraven    static const mask xdigit = 1<<8;
407227825Stheraven    static const mask blank  = 1<<9;
408227825Stheraven#endif  // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__
409227825Stheraven    static const mask alnum  = alpha | digit;
410227825Stheraven    static const mask graph  = alnum | punct;
411227825Stheraven
412227825Stheraven    _LIBCPP_ALWAYS_INLINE ctype_base() {}
413227825Stheraven};
414227825Stheraven
415262801Sdimtemplate <class _CharT> class _LIBCPP_TYPE_VIS_ONLY ctype;
416227825Stheraven
417227825Stheraventemplate <>
418249998Sdimclass _LIBCPP_TYPE_VIS ctype<wchar_t>
419227825Stheraven    : public locale::facet,
420227825Stheraven      public ctype_base
421227825Stheraven{
422227825Stheravenpublic:
423227825Stheraven    typedef wchar_t char_type;
424227825Stheraven
425227825Stheraven    _LIBCPP_ALWAYS_INLINE
426227825Stheraven    explicit ctype(size_t __refs = 0)
427227825Stheraven        : locale::facet(__refs) {}
428227825Stheraven
429227825Stheraven    _LIBCPP_ALWAYS_INLINE
430227825Stheraven    bool is(mask __m, char_type __c) const
431227825Stheraven    {
432227825Stheraven        return do_is(__m, __c);
433227825Stheraven    }
434227825Stheraven
435227825Stheraven    _LIBCPP_ALWAYS_INLINE
436227825Stheraven    const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
437227825Stheraven    {
438227825Stheraven        return do_is(__low, __high, __vec);
439227825Stheraven    }
440227825Stheraven
441227825Stheraven    _LIBCPP_ALWAYS_INLINE
442227825Stheraven    const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const
443227825Stheraven    {
444227825Stheraven        return do_scan_is(__m, __low, __high);
445227825Stheraven    }
446227825Stheraven
447227825Stheraven    _LIBCPP_ALWAYS_INLINE
448227825Stheraven    const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
449227825Stheraven    {
450227825Stheraven        return do_scan_not(__m, __low, __high);
451227825Stheraven    }
452227825Stheraven
453227825Stheraven    _LIBCPP_ALWAYS_INLINE
454227825Stheraven    char_type toupper(char_type __c) const
455227825Stheraven    {
456227825Stheraven        return do_toupper(__c);
457227825Stheraven    }
458227825Stheraven
459227825Stheraven    _LIBCPP_ALWAYS_INLINE
460227825Stheraven    const char_type* toupper(char_type* __low, const char_type* __high) const
461227825Stheraven    {
462227825Stheraven        return do_toupper(__low, __high);
463227825Stheraven    }
464227825Stheraven
465227825Stheraven    _LIBCPP_ALWAYS_INLINE
466227825Stheraven    char_type tolower(char_type __c) const
467227825Stheraven    {
468227825Stheraven        return do_tolower(__c);
469227825Stheraven    }
470227825Stheraven
471227825Stheraven    _LIBCPP_ALWAYS_INLINE
472227825Stheraven    const char_type* tolower(char_type* __low, const char_type* __high) const
473227825Stheraven    {
474227825Stheraven        return do_tolower(__low, __high);
475227825Stheraven    }
476227825Stheraven
477227825Stheraven    _LIBCPP_ALWAYS_INLINE
478227825Stheraven    char_type widen(char __c) const
479227825Stheraven    {
480227825Stheraven        return do_widen(__c);
481227825Stheraven    }
482227825Stheraven
483227825Stheraven    _LIBCPP_ALWAYS_INLINE
484227825Stheraven    const char* widen(const char* __low, const char* __high, char_type* __to) const
485227825Stheraven    {
486227825Stheraven        return do_widen(__low, __high, __to);
487227825Stheraven    }
488227825Stheraven
489227825Stheraven    _LIBCPP_ALWAYS_INLINE
490227825Stheraven    char narrow(char_type __c, char __dfault) const
491227825Stheraven    {
492227825Stheraven        return do_narrow(__c, __dfault);
493227825Stheraven    }
494227825Stheraven
495227825Stheraven    _LIBCPP_ALWAYS_INLINE
496227825Stheraven    const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
497227825Stheraven    {
498227825Stheraven        return do_narrow(__low, __high, __dfault, __to);
499227825Stheraven    }
500227825Stheraven
501227825Stheraven    static locale::id id;
502227825Stheraven
503227825Stheravenprotected:
504227825Stheraven    ~ctype();
505227825Stheraven    virtual bool do_is(mask __m, char_type __c) const;
506227825Stheraven    virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
507227825Stheraven    virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
508227825Stheraven    virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
509227825Stheraven    virtual char_type do_toupper(char_type) const;
510227825Stheraven    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
511227825Stheraven    virtual char_type do_tolower(char_type) const;
512227825Stheraven    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
513227825Stheraven    virtual char_type do_widen(char) const;
514227825Stheraven    virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
515227825Stheraven    virtual char do_narrow(char_type, char __dfault) const;
516227825Stheraven    virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
517227825Stheraven};
518227825Stheraven
519227825Stheraventemplate <>
520249998Sdimclass _LIBCPP_TYPE_VIS ctype<char>
521227825Stheraven    : public locale::facet, public ctype_base
522227825Stheraven{
523227825Stheraven    const mask* __tab_;
524227825Stheraven    bool        __del_;
525227825Stheravenpublic:
526227825Stheraven    typedef char char_type;
527227825Stheraven
528227825Stheraven    explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);
529227825Stheraven
530227825Stheraven    _LIBCPP_ALWAYS_INLINE
531227825Stheraven    bool is(mask __m, char_type __c) const
532227825Stheraven    {
533262801Sdim        return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false;
534227825Stheraven    }
535227825Stheraven
536227825Stheraven    _LIBCPP_ALWAYS_INLINE
537227825Stheraven    const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
538227825Stheraven    {
539227825Stheraven        for (; __low != __high; ++__low, ++__vec)
540232950Stheraven            *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;
541227825Stheraven        return __low;
542227825Stheraven    }
543227825Stheraven
544227825Stheraven    _LIBCPP_ALWAYS_INLINE
545227825Stheraven    const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const
546227825Stheraven    {
547227825Stheraven        for (; __low != __high; ++__low)
548232950Stheraven            if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))
549227825Stheraven                break;
550227825Stheraven        return __low;
551227825Stheraven    }
552227825Stheraven
553227825Stheraven    _LIBCPP_ALWAYS_INLINE
554227825Stheraven    const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
555227825Stheraven    {
556227825Stheraven        for (; __low != __high; ++__low)
557232950Stheraven            if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))
558227825Stheraven                break;
559227825Stheraven        return __low;
560227825Stheraven    }
561227825Stheraven
562227825Stheraven    _LIBCPP_ALWAYS_INLINE
563227825Stheraven    char_type toupper(char_type __c) const
564227825Stheraven    {
565227825Stheraven        return do_toupper(__c);
566227825Stheraven    }
567227825Stheraven
568227825Stheraven    _LIBCPP_ALWAYS_INLINE
569227825Stheraven    const char_type* toupper(char_type* __low, const char_type* __high) const
570227825Stheraven    {
571227825Stheraven        return do_toupper(__low, __high);
572227825Stheraven    }
573227825Stheraven
574227825Stheraven    _LIBCPP_ALWAYS_INLINE
575227825Stheraven    char_type tolower(char_type __c) const
576227825Stheraven    {
577227825Stheraven        return do_tolower(__c);
578227825Stheraven    }
579227825Stheraven
580227825Stheraven    _LIBCPP_ALWAYS_INLINE
581227825Stheraven    const char_type* tolower(char_type* __low, const char_type* __high) const
582227825Stheraven    {
583227825Stheraven        return do_tolower(__low, __high);
584227825Stheraven    }
585227825Stheraven
586227825Stheraven    _LIBCPP_ALWAYS_INLINE
587227825Stheraven    char_type widen(char __c) const
588227825Stheraven    {
589227825Stheraven        return do_widen(__c);
590227825Stheraven    }
591227825Stheraven
592227825Stheraven    _LIBCPP_ALWAYS_INLINE
593227825Stheraven    const char* widen(const char* __low, const char* __high, char_type* __to) const
594227825Stheraven    {
595227825Stheraven        return do_widen(__low, __high, __to);
596227825Stheraven    }
597227825Stheraven
598227825Stheraven    _LIBCPP_ALWAYS_INLINE
599227825Stheraven    char narrow(char_type __c, char __dfault) const
600227825Stheraven    {
601227825Stheraven        return do_narrow(__c, __dfault);
602227825Stheraven    }
603227825Stheraven
604227825Stheraven    _LIBCPP_ALWAYS_INLINE
605227825Stheraven    const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
606227825Stheraven    {
607227825Stheraven        return do_narrow(__low, __high, __dfault, __to);
608227825Stheraven    }
609227825Stheraven
610227825Stheraven    static locale::id id;
611227825Stheraven
612227825Stheraven#ifdef _CACHED_RUNES
613227825Stheraven    static const size_t table_size = _CACHED_RUNES;
614227825Stheraven#else
615227825Stheraven    static const size_t table_size = 256;  // FIXME: Don't hardcode this.
616227825Stheraven#endif
617227825Stheraven    _LIBCPP_ALWAYS_INLINE const mask* table() const  _NOEXCEPT {return __tab_;}
618227825Stheraven    static const mask* classic_table()  _NOEXCEPT;
619262801Sdim#if defined(__GLIBC__) || defined(__EMSCRIPTEN__)
620227825Stheraven    static const int* __classic_upper_table() _NOEXCEPT;
621227825Stheraven    static const int* __classic_lower_table() _NOEXCEPT;
622227825Stheraven#endif
623253159Stheraven#if defined(__NetBSD__)
624253159Stheraven    static const short* __classic_upper_table() _NOEXCEPT;
625253159Stheraven    static const short* __classic_lower_table() _NOEXCEPT;
626253159Stheraven#endif
627227825Stheraven
628227825Stheravenprotected:
629227825Stheraven    ~ctype();
630227825Stheraven    virtual char_type do_toupper(char_type __c) const;
631227825Stheraven    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
632227825Stheraven    virtual char_type do_tolower(char_type __c) const;
633227825Stheraven    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
634227825Stheraven    virtual char_type do_widen(char __c) const;
635227825Stheraven    virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const;
636227825Stheraven    virtual char do_narrow(char_type __c, char __dfault) const;
637227825Stheraven    virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const;
638227825Stheraven};
639227825Stheraven
640227825Stheraven// template <class CharT> class ctype_byname;
641227825Stheraven
642262801Sdimtemplate <class _CharT> class _LIBCPP_TYPE_VIS_ONLY ctype_byname;
643227825Stheraven
644227825Stheraventemplate <>
645249998Sdimclass _LIBCPP_TYPE_VIS ctype_byname<char>
646227825Stheraven    : public ctype<char>
647227825Stheraven{
648227825Stheraven    locale_t __l;
649227825Stheraven
650227825Stheravenpublic:
651227825Stheraven    explicit ctype_byname(const char*, size_t = 0);
652227825Stheraven    explicit ctype_byname(const string&, size_t = 0);
653227825Stheraven
654227825Stheravenprotected:
655227825Stheraven    ~ctype_byname();
656227825Stheraven    virtual char_type do_toupper(char_type) const;
657227825Stheraven    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
658227825Stheraven    virtual char_type do_tolower(char_type) const;
659227825Stheraven    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
660227825Stheraven};
661227825Stheraven
662227825Stheraventemplate <>
663249998Sdimclass _LIBCPP_TYPE_VIS ctype_byname<wchar_t>
664227825Stheraven    : public ctype<wchar_t>
665227825Stheraven{
666227825Stheraven    locale_t __l;
667227825Stheraven
668227825Stheravenpublic:
669227825Stheraven    explicit ctype_byname(const char*, size_t = 0);
670227825Stheraven    explicit ctype_byname(const string&, size_t = 0);
671227825Stheraven
672227825Stheravenprotected:
673227825Stheraven    ~ctype_byname();
674227825Stheraven    virtual bool do_is(mask __m, char_type __c) const;
675227825Stheraven    virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
676227825Stheraven    virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
677227825Stheraven    virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
678227825Stheraven    virtual char_type do_toupper(char_type) const;
679227825Stheraven    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
680227825Stheraven    virtual char_type do_tolower(char_type) const;
681227825Stheraven    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
682227825Stheraven    virtual char_type do_widen(char) const;
683227825Stheraven    virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
684227825Stheraven    virtual char do_narrow(char_type, char __dfault) const;
685227825Stheraven    virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
686227825Stheraven};
687227825Stheraven
688227825Stheraventemplate <class _CharT>
689227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
690227825Stheravenbool
691227825Stheravenisspace(_CharT __c, const locale& __loc)
692227825Stheraven{
693227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);
694227825Stheraven}
695227825Stheraven
696227825Stheraventemplate <class _CharT>
697227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
698227825Stheravenbool
699227825Stheravenisprint(_CharT __c, const locale& __loc)
700227825Stheraven{
701227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);
702227825Stheraven}
703227825Stheraven
704227825Stheraventemplate <class _CharT>
705227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
706227825Stheravenbool
707227825Stheraveniscntrl(_CharT __c, const locale& __loc)
708227825Stheraven{
709227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);
710227825Stheraven}
711227825Stheraven
712227825Stheraventemplate <class _CharT>
713227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
714227825Stheravenbool
715227825Stheravenisupper(_CharT __c, const locale& __loc)
716227825Stheraven{
717227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);
718227825Stheraven}
719227825Stheraven
720227825Stheraventemplate <class _CharT>
721227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
722227825Stheravenbool
723227825Stheravenislower(_CharT __c, const locale& __loc)
724227825Stheraven{
725227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);
726227825Stheraven}
727227825Stheraven
728227825Stheraventemplate <class _CharT>
729227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
730227825Stheravenbool
731227825Stheravenisalpha(_CharT __c, const locale& __loc)
732227825Stheraven{
733227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);
734227825Stheraven}
735227825Stheraven
736227825Stheraventemplate <class _CharT>
737227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
738227825Stheravenbool
739227825Stheravenisdigit(_CharT __c, const locale& __loc)
740227825Stheraven{
741227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);
742227825Stheraven}
743227825Stheraven
744227825Stheraventemplate <class _CharT>
745227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
746227825Stheravenbool
747227825Stheravenispunct(_CharT __c, const locale& __loc)
748227825Stheraven{
749227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);
750227825Stheraven}
751227825Stheraven
752227825Stheraventemplate <class _CharT>
753227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
754227825Stheravenbool
755227825Stheravenisxdigit(_CharT __c, const locale& __loc)
756227825Stheraven{
757227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);
758227825Stheraven}
759227825Stheraven
760227825Stheraventemplate <class _CharT>
761227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
762227825Stheravenbool
763227825Stheravenisalnum(_CharT __c, const locale& __loc)
764227825Stheraven{
765227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);
766227825Stheraven}
767227825Stheraven
768227825Stheraventemplate <class _CharT>
769227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
770227825Stheravenbool
771227825Stheravenisgraph(_CharT __c, const locale& __loc)
772227825Stheraven{
773227825Stheraven    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
774227825Stheraven}
775227825Stheraven
776227825Stheraventemplate <class _CharT>
777227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
778227825Stheraven_CharT
779227825Stheraventoupper(_CharT __c, const locale& __loc)
780227825Stheraven{
781227825Stheraven    return use_facet<ctype<_CharT> >(__loc).toupper(__c);
782227825Stheraven}
783227825Stheraven
784227825Stheraventemplate <class _CharT>
785227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
786227825Stheraven_CharT
787227825Stheraventolower(_CharT __c, const locale& __loc)
788227825Stheraven{
789227825Stheraven    return use_facet<ctype<_CharT> >(__loc).tolower(__c);
790227825Stheraven}
791227825Stheraven
792227825Stheraven// codecvt_base
793227825Stheraven
794249998Sdimclass _LIBCPP_TYPE_VIS codecvt_base
795227825Stheraven{
796227825Stheravenpublic:
797227825Stheraven    _LIBCPP_ALWAYS_INLINE codecvt_base() {}
798227825Stheraven    enum result {ok, partial, error, noconv};
799227825Stheraven};
800227825Stheraven
801227825Stheraven// template <class internT, class externT, class stateT> class codecvt;
802227825Stheraven
803262801Sdimtemplate <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TYPE_VIS_ONLY codecvt;
804227825Stheraven
805227825Stheraven// template <> class codecvt<char, char, mbstate_t>
806227825Stheraven
807227825Stheraventemplate <>
808249998Sdimclass _LIBCPP_TYPE_VIS codecvt<char, char, mbstate_t>
809227825Stheraven    : public locale::facet,
810227825Stheraven      public codecvt_base
811227825Stheraven{
812227825Stheravenpublic:
813227825Stheraven    typedef char      intern_type;
814227825Stheraven    typedef char      extern_type;
815227825Stheraven    typedef mbstate_t state_type;
816227825Stheraven
817227825Stheraven    _LIBCPP_ALWAYS_INLINE
818227825Stheraven    explicit codecvt(size_t __refs = 0)
819227825Stheraven        : locale::facet(__refs) {}
820227825Stheraven
821227825Stheraven    _LIBCPP_ALWAYS_INLINE
822227825Stheraven    result out(state_type& __st,
823227825Stheraven               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
824227825Stheraven               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
825227825Stheraven    {
826227825Stheraven        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
827227825Stheraven    }
828227825Stheraven
829227825Stheraven    _LIBCPP_ALWAYS_INLINE
830227825Stheraven    result unshift(state_type& __st,
831227825Stheraven                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
832227825Stheraven    {
833227825Stheraven        return do_unshift(__st, __to, __to_end, __to_nxt);
834227825Stheraven    }
835227825Stheraven
836227825Stheraven    _LIBCPP_ALWAYS_INLINE
837227825Stheraven    result in(state_type& __st,
838227825Stheraven              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
839227825Stheraven              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
840227825Stheraven    {
841227825Stheraven        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
842227825Stheraven    }
843227825Stheraven
844227825Stheraven    _LIBCPP_ALWAYS_INLINE
845227825Stheraven    int encoding() const  _NOEXCEPT
846227825Stheraven    {
847227825Stheraven        return do_encoding();
848227825Stheraven    }
849227825Stheraven
850227825Stheraven    _LIBCPP_ALWAYS_INLINE
851227825Stheraven    bool always_noconv() const  _NOEXCEPT
852227825Stheraven    {
853227825Stheraven        return do_always_noconv();
854227825Stheraven    }
855227825Stheraven
856227825Stheraven    _LIBCPP_ALWAYS_INLINE
857227825Stheraven    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
858227825Stheraven    {
859227825Stheraven        return do_length(__st, __frm, __end, __mx);
860227825Stheraven    }
861227825Stheraven
862227825Stheraven    _LIBCPP_ALWAYS_INLINE
863227825Stheraven    int max_length() const  _NOEXCEPT
864227825Stheraven    {
865227825Stheraven        return do_max_length();
866227825Stheraven    }
867227825Stheraven
868227825Stheraven    static locale::id id;
869227825Stheraven
870227825Stheravenprotected:
871227825Stheraven    _LIBCPP_ALWAYS_INLINE
872227825Stheraven    explicit codecvt(const char*, size_t __refs = 0)
873227825Stheraven        : locale::facet(__refs) {}
874227825Stheraven
875227825Stheraven    ~codecvt();
876227825Stheraven
877227825Stheraven    virtual result do_out(state_type& __st,
878227825Stheraven                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
879227825Stheraven                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
880227825Stheraven    virtual result do_in(state_type& __st,
881227825Stheraven                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
882227825Stheraven                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
883227825Stheraven    virtual result do_unshift(state_type& __st,
884227825Stheraven                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
885227825Stheraven    virtual int do_encoding() const  _NOEXCEPT;
886227825Stheraven    virtual bool do_always_noconv() const  _NOEXCEPT;
887227825Stheraven    virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
888227825Stheraven    virtual int do_max_length() const  _NOEXCEPT;
889227825Stheraven};
890227825Stheraven
891227825Stheraven// template <> class codecvt<wchar_t, char, mbstate_t>
892227825Stheraven
893227825Stheraventemplate <>
894249998Sdimclass _LIBCPP_TYPE_VIS codecvt<wchar_t, char, mbstate_t>
895227825Stheraven    : public locale::facet,
896227825Stheraven      public codecvt_base
897227825Stheraven{
898227825Stheraven    locale_t __l;
899227825Stheravenpublic:
900227825Stheraven    typedef wchar_t   intern_type;
901227825Stheraven    typedef char      extern_type;
902227825Stheraven    typedef mbstate_t state_type;
903227825Stheraven
904227825Stheraven    explicit codecvt(size_t __refs = 0);
905227825Stheraven
906227825Stheraven    _LIBCPP_ALWAYS_INLINE
907227825Stheraven    result out(state_type& __st,
908227825Stheraven               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
909227825Stheraven               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
910227825Stheraven    {
911227825Stheraven        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
912227825Stheraven    }
913227825Stheraven
914227825Stheraven    _LIBCPP_ALWAYS_INLINE
915227825Stheraven    result unshift(state_type& __st,
916227825Stheraven                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
917227825Stheraven    {
918227825Stheraven        return do_unshift(__st, __to, __to_end, __to_nxt);
919227825Stheraven    }
920227825Stheraven
921227825Stheraven    _LIBCPP_ALWAYS_INLINE
922227825Stheraven    result in(state_type& __st,
923227825Stheraven              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
924227825Stheraven              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
925227825Stheraven    {
926227825Stheraven        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
927227825Stheraven    }
928227825Stheraven
929227825Stheraven    _LIBCPP_ALWAYS_INLINE
930227825Stheraven    int encoding() const  _NOEXCEPT
931227825Stheraven    {
932227825Stheraven        return do_encoding();
933227825Stheraven    }
934227825Stheraven
935227825Stheraven    _LIBCPP_ALWAYS_INLINE
936227825Stheraven    bool always_noconv() const  _NOEXCEPT
937227825Stheraven    {
938227825Stheraven        return do_always_noconv();
939227825Stheraven    }
940227825Stheraven
941227825Stheraven    _LIBCPP_ALWAYS_INLINE
942227825Stheraven    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
943227825Stheraven    {
944227825Stheraven        return do_length(__st, __frm, __end, __mx);
945227825Stheraven    }
946227825Stheraven
947227825Stheraven    _LIBCPP_ALWAYS_INLINE
948227825Stheraven    int max_length() const  _NOEXCEPT
949227825Stheraven    {
950227825Stheraven        return do_max_length();
951227825Stheraven    }
952227825Stheraven
953227825Stheraven    static locale::id id;
954227825Stheraven
955227825Stheravenprotected:
956227825Stheraven    explicit codecvt(const char*, size_t __refs = 0);
957227825Stheraven
958227825Stheraven    ~codecvt();
959227825Stheraven
960227825Stheraven    virtual result do_out(state_type& __st,
961227825Stheraven                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
962227825Stheraven                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
963227825Stheraven    virtual result do_in(state_type& __st,
964227825Stheraven                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
965227825Stheraven                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
966227825Stheraven    virtual result do_unshift(state_type& __st,
967227825Stheraven                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
968227825Stheraven    virtual int do_encoding() const  _NOEXCEPT;
969227825Stheraven    virtual bool do_always_noconv() const  _NOEXCEPT;
970227825Stheraven    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
971227825Stheraven    virtual int do_max_length() const  _NOEXCEPT;
972227825Stheraven};
973227825Stheraven
974227825Stheraven// template <> class codecvt<char16_t, char, mbstate_t>
975227825Stheraven
976227825Stheraventemplate <>
977249998Sdimclass _LIBCPP_TYPE_VIS codecvt<char16_t, char, mbstate_t>
978227825Stheraven    : public locale::facet,
979227825Stheraven      public codecvt_base
980227825Stheraven{
981227825Stheravenpublic:
982227825Stheraven    typedef char16_t  intern_type;
983227825Stheraven    typedef char      extern_type;
984227825Stheraven    typedef mbstate_t state_type;
985227825Stheraven
986227825Stheraven    _LIBCPP_ALWAYS_INLINE
987227825Stheraven    explicit codecvt(size_t __refs = 0)
988227825Stheraven        : locale::facet(__refs) {}
989227825Stheraven
990227825Stheraven    _LIBCPP_ALWAYS_INLINE
991227825Stheraven    result out(state_type& __st,
992227825Stheraven               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
993227825Stheraven               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
994227825Stheraven    {
995227825Stheraven        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
996227825Stheraven    }
997227825Stheraven
998227825Stheraven    _LIBCPP_ALWAYS_INLINE
999227825Stheraven    result unshift(state_type& __st,
1000227825Stheraven                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1001227825Stheraven    {
1002227825Stheraven        return do_unshift(__st, __to, __to_end, __to_nxt);
1003227825Stheraven    }
1004227825Stheraven
1005227825Stheraven    _LIBCPP_ALWAYS_INLINE
1006227825Stheraven    result in(state_type& __st,
1007227825Stheraven              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1008227825Stheraven              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
1009227825Stheraven    {
1010227825Stheraven        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1011227825Stheraven    }
1012227825Stheraven
1013227825Stheraven    _LIBCPP_ALWAYS_INLINE
1014227825Stheraven    int encoding() const  _NOEXCEPT
1015227825Stheraven    {
1016227825Stheraven        return do_encoding();
1017227825Stheraven    }
1018227825Stheraven
1019227825Stheraven    _LIBCPP_ALWAYS_INLINE
1020227825Stheraven    bool always_noconv() const  _NOEXCEPT
1021227825Stheraven    {
1022227825Stheraven        return do_always_noconv();
1023227825Stheraven    }
1024227825Stheraven
1025227825Stheraven    _LIBCPP_ALWAYS_INLINE
1026227825Stheraven    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
1027227825Stheraven    {
1028227825Stheraven        return do_length(__st, __frm, __end, __mx);
1029227825Stheraven    }
1030227825Stheraven
1031227825Stheraven    _LIBCPP_ALWAYS_INLINE
1032227825Stheraven    int max_length() const  _NOEXCEPT
1033227825Stheraven    {
1034227825Stheraven        return do_max_length();
1035227825Stheraven    }
1036227825Stheraven
1037227825Stheraven    static locale::id id;
1038227825Stheraven
1039227825Stheravenprotected:
1040227825Stheraven    _LIBCPP_ALWAYS_INLINE
1041227825Stheraven    explicit codecvt(const char*, size_t __refs = 0)
1042227825Stheraven        : locale::facet(__refs) {}
1043227825Stheraven
1044227825Stheraven    ~codecvt();
1045227825Stheraven
1046227825Stheraven    virtual result do_out(state_type& __st,
1047227825Stheraven                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1048227825Stheraven                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1049227825Stheraven    virtual result do_in(state_type& __st,
1050227825Stheraven                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1051227825Stheraven                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1052227825Stheraven    virtual result do_unshift(state_type& __st,
1053227825Stheraven                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1054227825Stheraven    virtual int do_encoding() const  _NOEXCEPT;
1055227825Stheraven    virtual bool do_always_noconv() const  _NOEXCEPT;
1056227825Stheraven    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
1057227825Stheraven    virtual int do_max_length() const  _NOEXCEPT;
1058227825Stheraven};
1059227825Stheraven
1060227825Stheraven// template <> class codecvt<char32_t, char, mbstate_t>
1061227825Stheraven
1062227825Stheraventemplate <>
1063249998Sdimclass _LIBCPP_TYPE_VIS codecvt<char32_t, char, mbstate_t>
1064227825Stheraven    : public locale::facet,
1065227825Stheraven      public codecvt_base
1066227825Stheraven{
1067227825Stheravenpublic:
1068227825Stheraven    typedef char32_t  intern_type;
1069227825Stheraven    typedef char      extern_type;
1070227825Stheraven    typedef mbstate_t state_type;
1071227825Stheraven
1072227825Stheraven    _LIBCPP_ALWAYS_INLINE
1073227825Stheraven    explicit codecvt(size_t __refs = 0)
1074227825Stheraven        : locale::facet(__refs) {}
1075227825Stheraven
1076227825Stheraven    _LIBCPP_ALWAYS_INLINE
1077227825Stheraven    result out(state_type& __st,
1078227825Stheraven               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1079227825Stheraven               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1080227825Stheraven    {
1081227825Stheraven        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1082227825Stheraven    }
1083227825Stheraven
1084227825Stheraven    _LIBCPP_ALWAYS_INLINE
1085227825Stheraven    result unshift(state_type& __st,
1086227825Stheraven                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1087227825Stheraven    {
1088227825Stheraven        return do_unshift(__st, __to, __to_end, __to_nxt);
1089227825Stheraven    }
1090227825Stheraven
1091227825Stheraven    _LIBCPP_ALWAYS_INLINE
1092227825Stheraven    result in(state_type& __st,
1093227825Stheraven              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1094227825Stheraven              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
1095227825Stheraven    {
1096227825Stheraven        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1097227825Stheraven    }
1098227825Stheraven
1099227825Stheraven    _LIBCPP_ALWAYS_INLINE
1100227825Stheraven    int encoding() const  _NOEXCEPT
1101227825Stheraven    {
1102227825Stheraven        return do_encoding();
1103227825Stheraven    }
1104227825Stheraven
1105227825Stheraven    _LIBCPP_ALWAYS_INLINE
1106227825Stheraven    bool always_noconv() const  _NOEXCEPT
1107227825Stheraven    {
1108227825Stheraven        return do_always_noconv();
1109227825Stheraven    }
1110227825Stheraven
1111227825Stheraven    _LIBCPP_ALWAYS_INLINE
1112227825Stheraven    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
1113227825Stheraven    {
1114227825Stheraven        return do_length(__st, __frm, __end, __mx);
1115227825Stheraven    }
1116227825Stheraven
1117227825Stheraven    _LIBCPP_ALWAYS_INLINE
1118227825Stheraven    int max_length() const  _NOEXCEPT
1119227825Stheraven    {
1120227825Stheraven        return do_max_length();
1121227825Stheraven    }
1122227825Stheraven
1123227825Stheraven    static locale::id id;
1124227825Stheraven
1125227825Stheravenprotected:
1126227825Stheraven    _LIBCPP_ALWAYS_INLINE
1127227825Stheraven    explicit codecvt(const char*, size_t __refs = 0)
1128227825Stheraven        : locale::facet(__refs) {}
1129227825Stheraven
1130227825Stheraven    ~codecvt();
1131227825Stheraven
1132227825Stheraven    virtual result do_out(state_type& __st,
1133227825Stheraven                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1134227825Stheraven                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1135227825Stheraven    virtual result do_in(state_type& __st,
1136227825Stheraven                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1137227825Stheraven                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1138227825Stheraven    virtual result do_unshift(state_type& __st,
1139227825Stheraven                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1140227825Stheraven    virtual int do_encoding() const  _NOEXCEPT;
1141227825Stheraven    virtual bool do_always_noconv() const  _NOEXCEPT;
1142227825Stheraven    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
1143227825Stheraven    virtual int do_max_length() const  _NOEXCEPT;
1144227825Stheraven};
1145227825Stheraven
1146227825Stheraven// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname
1147227825Stheraven
1148227825Stheraventemplate <class _InternT, class _ExternT, class _StateT>
1149262801Sdimclass _LIBCPP_TYPE_VIS_ONLY codecvt_byname
1150227825Stheraven    : public codecvt<_InternT, _ExternT, _StateT>
1151227825Stheraven{
1152227825Stheravenpublic:
1153227825Stheraven    _LIBCPP_ALWAYS_INLINE
1154227825Stheraven    explicit codecvt_byname(const char* __nm, size_t __refs = 0)
1155227825Stheraven        : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {}
1156227825Stheraven    _LIBCPP_ALWAYS_INLINE
1157227825Stheraven    explicit codecvt_byname(const string& __nm, size_t __refs = 0)
1158227825Stheraven        : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}
1159227825Stheravenprotected:
1160227825Stheraven    ~codecvt_byname();
1161227825Stheraven};
1162227825Stheraven
1163227825Stheraventemplate <class _InternT, class _ExternT, class _StateT>
1164227825Stheravencodecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
1165227825Stheraven{
1166227825Stheraven}
1167227825Stheraven
1168262801Sdim_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char, char, mbstate_t>)
1169262801Sdim_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
1170262801Sdim_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>)
1171262801Sdim_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>)
1172227825Stheraven
1173249998Sdim_LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
1174227825Stheraven
1175232950Stheraventemplate <size_t _Np>
1176227825Stheravenstruct __narrow_to_utf8
1177227825Stheraven{
1178227825Stheraven    template <class _OutputIterator, class _CharT>
1179227825Stheraven    _OutputIterator
1180227825Stheraven    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const;
1181227825Stheraven};
1182227825Stheraven
1183227825Stheraventemplate <>
1184227825Stheravenstruct __narrow_to_utf8<8>
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        for (; __wb < __we; ++__wb, ++__s)
1192227825Stheraven            *__s = *__wb;
1193227825Stheraven        return __s;
1194227825Stheraven    }
1195227825Stheraven};
1196227825Stheraven
1197227825Stheraventemplate <>
1198227825Stheravenstruct __narrow_to_utf8<16>
1199227825Stheraven    : public codecvt<char16_t, char, mbstate_t>
1200227825Stheraven{
1201227825Stheraven    _LIBCPP_ALWAYS_INLINE
1202227825Stheraven    __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
1203227825Stheraven
1204227825Stheraven    ~__narrow_to_utf8();
1205227825Stheraven
1206227825Stheraven    template <class _OutputIterator, class _CharT>
1207227825Stheraven    _LIBCPP_ALWAYS_INLINE
1208227825Stheraven    _OutputIterator
1209227825Stheraven    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
1210227825Stheraven    {
1211227825Stheraven        result __r = ok;
1212227825Stheraven        mbstate_t __mb;
1213227825Stheraven        while (__wb < __we && __r != error)
1214227825Stheraven        {
1215227825Stheraven            const int __sz = 32;
1216227825Stheraven            char __buf[__sz];
1217227825Stheraven            char* __bn;
1218227825Stheraven            const char16_t* __wn = (const char16_t*)__wb;
1219227825Stheraven            __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn,
1220227825Stheraven                         __buf, __buf+__sz, __bn);
1221227825Stheraven            if (__r == codecvt_base::error || __wn == (const char16_t*)__wb)
1222227825Stheraven                __throw_runtime_error("locale not supported");
1223227825Stheraven            for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
1224227825Stheraven                *__s = *__p;
1225227825Stheraven            __wb = (const _CharT*)__wn;
1226227825Stheraven        }
1227227825Stheraven        return __s;
1228227825Stheraven    }
1229227825Stheraven};
1230227825Stheraven
1231227825Stheraventemplate <>
1232227825Stheravenstruct __narrow_to_utf8<32>
1233227825Stheraven    : public codecvt<char32_t, char, mbstate_t>
1234227825Stheraven{
1235227825Stheraven    _LIBCPP_ALWAYS_INLINE
1236227825Stheraven    __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
1237227825Stheraven
1238227825Stheraven    ~__narrow_to_utf8();
1239227825Stheraven
1240227825Stheraven    template <class _OutputIterator, class _CharT>
1241227825Stheraven    _LIBCPP_ALWAYS_INLINE
1242227825Stheraven    _OutputIterator
1243227825Stheraven    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
1244227825Stheraven    {
1245227825Stheraven        result __r = ok;
1246227825Stheraven        mbstate_t __mb;
1247227825Stheraven        while (__wb < __we && __r != error)
1248227825Stheraven        {
1249227825Stheraven            const int __sz = 32;
1250227825Stheraven            char __buf[__sz];
1251227825Stheraven            char* __bn;
1252227825Stheraven            const char32_t* __wn = (const char32_t*)__wb;
1253227825Stheraven            __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn,
1254227825Stheraven                         __buf, __buf+__sz, __bn);
1255227825Stheraven            if (__r == codecvt_base::error || __wn == (const char32_t*)__wb)
1256227825Stheraven                __throw_runtime_error("locale not supported");
1257227825Stheraven            for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
1258227825Stheraven                *__s = *__p;
1259227825Stheraven            __wb = (const _CharT*)__wn;
1260227825Stheraven        }
1261227825Stheraven        return __s;
1262227825Stheraven    }
1263227825Stheraven};
1264227825Stheraven
1265232950Stheraventemplate <size_t _Np>
1266227825Stheravenstruct __widen_from_utf8
1267227825Stheraven{
1268227825Stheraven    template <class _OutputIterator>
1269227825Stheraven    _OutputIterator
1270227825Stheraven    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const;
1271227825Stheraven};
1272227825Stheraven
1273227825Stheraventemplate <>
1274227825Stheravenstruct __widen_from_utf8<8>
1275227825Stheraven{
1276227825Stheraven    template <class _OutputIterator>
1277227825Stheraven    _LIBCPP_ALWAYS_INLINE
1278227825Stheraven    _OutputIterator
1279227825Stheraven    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
1280227825Stheraven    {
1281227825Stheraven        for (; __nb < __ne; ++__nb, ++__s)
1282227825Stheraven            *__s = *__nb;
1283227825Stheraven        return __s;
1284227825Stheraven    }
1285227825Stheraven};
1286227825Stheraven
1287227825Stheraventemplate <>
1288227825Stheravenstruct __widen_from_utf8<16>
1289227825Stheraven    : public codecvt<char16_t, char, mbstate_t>
1290227825Stheraven{
1291227825Stheraven    _LIBCPP_ALWAYS_INLINE
1292227825Stheraven    __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
1293227825Stheraven
1294227825Stheraven    ~__widen_from_utf8();
1295227825Stheraven
1296227825Stheraven    template <class _OutputIterator>
1297227825Stheraven    _LIBCPP_ALWAYS_INLINE
1298227825Stheraven    _OutputIterator
1299227825Stheraven    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
1300227825Stheraven    {
1301227825Stheraven        result __r = ok;
1302227825Stheraven        mbstate_t __mb;
1303227825Stheraven        while (__nb < __ne && __r != error)
1304227825Stheraven        {
1305227825Stheraven            const int __sz = 32;
1306227825Stheraven            char16_t __buf[__sz];
1307227825Stheraven            char16_t* __bn;
1308227825Stheraven            const char* __nn = __nb;
1309227825Stheraven            __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
1310227825Stheraven                        __buf, __buf+__sz, __bn);
1311227825Stheraven            if (__r == codecvt_base::error || __nn == __nb)
1312227825Stheraven                __throw_runtime_error("locale not supported");
1313227825Stheraven            for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)
1314227825Stheraven                *__s = (wchar_t)*__p;
1315227825Stheraven            __nb = __nn;
1316227825Stheraven        }
1317227825Stheraven        return __s;
1318227825Stheraven    }
1319227825Stheraven};
1320227825Stheraven
1321227825Stheraventemplate <>
1322227825Stheravenstruct __widen_from_utf8<32>
1323227825Stheraven    : public codecvt<char32_t, char, mbstate_t>
1324227825Stheraven{
1325227825Stheraven    _LIBCPP_ALWAYS_INLINE
1326227825Stheraven    __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
1327227825Stheraven
1328227825Stheraven    ~__widen_from_utf8();
1329227825Stheraven
1330227825Stheraven    template <class _OutputIterator>
1331227825Stheraven    _LIBCPP_ALWAYS_INLINE
1332227825Stheraven    _OutputIterator
1333227825Stheraven    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
1334227825Stheraven    {
1335227825Stheraven        result __r = ok;
1336227825Stheraven        mbstate_t __mb;
1337227825Stheraven        while (__nb < __ne && __r != error)
1338227825Stheraven        {
1339227825Stheraven            const int __sz = 32;
1340227825Stheraven            char32_t __buf[__sz];
1341227825Stheraven            char32_t* __bn;
1342227825Stheraven            const char* __nn = __nb;
1343227825Stheraven            __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
1344227825Stheraven                        __buf, __buf+__sz, __bn);
1345227825Stheraven            if (__r == codecvt_base::error || __nn == __nb)
1346227825Stheraven                __throw_runtime_error("locale not supported");
1347227825Stheraven            for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)
1348227825Stheraven                *__s = (wchar_t)*__p;
1349227825Stheraven            __nb = __nn;
1350227825Stheraven        }
1351227825Stheraven        return __s;
1352227825Stheraven    }
1353227825Stheraven};
1354227825Stheraven
1355227825Stheraven// template <class charT> class numpunct
1356227825Stheraven
1357262801Sdimtemplate <class _CharT> class _LIBCPP_TYPE_VIS_ONLY numpunct;
1358227825Stheraven
1359227825Stheraventemplate <>
1360249998Sdimclass _LIBCPP_TYPE_VIS numpunct<char>
1361227825Stheraven    : public locale::facet
1362227825Stheraven{
1363227825Stheravenpublic:
1364227825Stheraven    typedef char char_type;
1365227825Stheraven    typedef basic_string<char_type> string_type;
1366227825Stheraven
1367227825Stheraven    explicit numpunct(size_t __refs = 0);
1368227825Stheraven
1369227825Stheraven    _LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();}
1370227825Stheraven    _LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();}
1371227825Stheraven    _LIBCPP_ALWAYS_INLINE string grouping() const         {return do_grouping();}
1372227825Stheraven    _LIBCPP_ALWAYS_INLINE string_type truename() const    {return do_truename();}
1373227825Stheraven    _LIBCPP_ALWAYS_INLINE string_type falsename() const   {return do_falsename();}
1374227825Stheraven
1375227825Stheraven    static locale::id id;
1376227825Stheraven
1377227825Stheravenprotected:
1378227825Stheraven    ~numpunct();
1379227825Stheraven    virtual char_type do_decimal_point() const;
1380227825Stheraven    virtual char_type do_thousands_sep() const;
1381227825Stheraven    virtual string do_grouping() const;
1382227825Stheraven    virtual string_type do_truename() const;
1383227825Stheraven    virtual string_type do_falsename() const;
1384227825Stheraven
1385227825Stheraven    char_type __decimal_point_;
1386227825Stheraven    char_type __thousands_sep_;
1387227825Stheraven    string __grouping_;
1388227825Stheraven};
1389227825Stheraven
1390227825Stheraventemplate <>
1391249998Sdimclass _LIBCPP_TYPE_VIS numpunct<wchar_t>
1392227825Stheraven    : public locale::facet
1393227825Stheraven{
1394227825Stheravenpublic:
1395227825Stheraven    typedef wchar_t char_type;
1396227825Stheraven    typedef basic_string<char_type> string_type;
1397227825Stheraven
1398227825Stheraven    explicit numpunct(size_t __refs = 0);
1399227825Stheraven
1400227825Stheraven    _LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();}
1401227825Stheraven    _LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();}
1402227825Stheraven    _LIBCPP_ALWAYS_INLINE string grouping() const         {return do_grouping();}
1403227825Stheraven    _LIBCPP_ALWAYS_INLINE string_type truename() const    {return do_truename();}
1404227825Stheraven    _LIBCPP_ALWAYS_INLINE string_type falsename() const   {return do_falsename();}
1405227825Stheraven
1406227825Stheraven    static locale::id id;
1407227825Stheraven
1408227825Stheravenprotected:
1409227825Stheraven    ~numpunct();
1410227825Stheraven    virtual char_type do_decimal_point() const;
1411227825Stheraven    virtual char_type do_thousands_sep() const;
1412227825Stheraven    virtual string do_grouping() const;
1413227825Stheraven    virtual string_type do_truename() const;
1414227825Stheraven    virtual string_type do_falsename() const;
1415227825Stheraven
1416227825Stheraven    char_type __decimal_point_;
1417227825Stheraven    char_type __thousands_sep_;
1418227825Stheraven    string __grouping_;
1419227825Stheraven};
1420227825Stheraven
1421227825Stheraven// template <class charT> class numpunct_byname
1422227825Stheraven
1423262801Sdimtemplate <class charT> class _LIBCPP_TYPE_VIS_ONLY numpunct_byname;
1424227825Stheraven
1425227825Stheraventemplate <>
1426249998Sdimclass _LIBCPP_TYPE_VIS numpunct_byname<char>
1427227825Stheraven: public numpunct<char>
1428227825Stheraven{
1429227825Stheravenpublic:
1430227825Stheraven    typedef char char_type;
1431227825Stheraven    typedef basic_string<char_type> string_type;
1432227825Stheraven
1433227825Stheraven    explicit numpunct_byname(const char* __nm, size_t __refs = 0);
1434227825Stheraven    explicit numpunct_byname(const string& __nm, size_t __refs = 0);
1435227825Stheraven
1436227825Stheravenprotected:
1437227825Stheraven    ~numpunct_byname();
1438227825Stheraven
1439227825Stheravenprivate:
1440227825Stheraven    void __init(const char*);
1441227825Stheraven};
1442227825Stheraven
1443227825Stheraventemplate <>
1444249998Sdimclass _LIBCPP_TYPE_VIS numpunct_byname<wchar_t>
1445227825Stheraven: public numpunct<wchar_t>
1446227825Stheraven{
1447227825Stheravenpublic:
1448227825Stheraven    typedef wchar_t char_type;
1449227825Stheraven    typedef basic_string<char_type> string_type;
1450227825Stheraven
1451227825Stheraven    explicit numpunct_byname(const char* __nm, size_t __refs = 0);
1452227825Stheraven    explicit numpunct_byname(const string& __nm, size_t __refs = 0);
1453227825Stheraven
1454227825Stheravenprotected:
1455227825Stheraven    ~numpunct_byname();
1456227825Stheraven
1457227825Stheravenprivate:
1458227825Stheraven    void __init(const char*);
1459227825Stheraven};
1460227825Stheraven
1461227825Stheraven_LIBCPP_END_NAMESPACE_STD
1462227825Stheraven
1463227825Stheraven#endif  // _LIBCPP___LOCALE
1464