wpkg test coverage results

Coverage test results of the Windows Packager by Made to Order Software Corporation.

LCOV - code coverage report
Current view: top level - usr/include/c++/4.6/bits - locale_facets.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 15 0.0 %
Date: 2013-06-17 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Locale support -*- C++ -*-
       2             : 
       3             : // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
       4             : // 2006, 2007, 2008, 2009, 2010, 2011
       5             : // Free Software Foundation, Inc.
       6             : //
       7             : // This file is part of the GNU ISO C++ Library.  This library is free
       8             : // software; you can redistribute it and/or modify it under the
       9             : // terms of the GNU General Public License as published by the
      10             : // Free Software Foundation; either version 3, or (at your option)
      11             : // any later version.
      12             : 
      13             : // This library is distributed in the hope that it will be useful,
      14             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             : // GNU General Public License for more details.
      17             : 
      18             : // Under Section 7 of GPL version 3, you are granted additional
      19             : // permissions described in the GCC Runtime Library Exception, version
      20             : // 3.1, as published by the Free Software Foundation.
      21             : 
      22             : // You should have received a copy of the GNU General Public License and
      23             : // a copy of the GCC Runtime Library Exception along with this program;
      24             : // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      25             : // <http://www.gnu.org/licenses/>.
      26             : 
      27             : /** @file bits/locale_facets.h
      28             :  *  This is an internal header file, included by other library headers.
      29             :  *  Do not attempt to use it directly. @headername{locale}
      30             :  */
      31             : 
      32             : //
      33             : // ISO C++ 14882: 22.1  Locales
      34             : //
      35             : 
      36             : #ifndef _LOCALE_FACETS_H
      37             : #define _LOCALE_FACETS_H 1
      38             : 
      39             : #pragma GCC system_header
      40             : 
      41             : #include <cwctype>        // For wctype_t
      42             : #include <cctype>
      43             : #include <bits/ctype_base.h>      
      44             : #include <iosfwd>
      45             : #include <bits/ios_base.h>  // For ios_base, ios_base::iostate
      46             : #include <streambuf>
      47             : #include <bits/cpp_type_traits.h>
      48             : #include <ext/type_traits.h>
      49             : #include <ext/numeric_traits.h>
      50             : #include <bits/streambuf_iterator.h>
      51             : 
      52             : namespace std _GLIBCXX_VISIBILITY(default)
      53             : {
      54             : _GLIBCXX_BEGIN_NAMESPACE_VERSION
      55             : 
      56             :   // NB: Don't instantiate required wchar_t facets if no wchar_t support.
      57             : #ifdef _GLIBCXX_USE_WCHAR_T
      58             : # define  _GLIBCXX_NUM_FACETS 28
      59             : #else
      60             : # define  _GLIBCXX_NUM_FACETS 14
      61             : #endif
      62             : 
      63             :   // Convert string to numeric value of type _Tp and store results.
      64             :   // NB: This is specialized for all required types, there is no
      65             :   // generic definition.
      66             :   template<typename _Tp>
      67             :     void
      68             :     __convert_to_v(const char*, _Tp&, ios_base::iostate&,
      69             :                    const __c_locale&) throw();
      70             : 
      71             :   // Explicit specializations for required types.
      72             :   template<>
      73             :     void
      74             :     __convert_to_v(const char*, float&, ios_base::iostate&,
      75             :                    const __c_locale&) throw();
      76             : 
      77             :   template<>
      78             :     void
      79             :     __convert_to_v(const char*, double&, ios_base::iostate&,
      80             :                    const __c_locale&) throw();
      81             : 
      82             :   template<>
      83             :     void
      84             :     __convert_to_v(const char*, long double&, ios_base::iostate&,
      85             :                    const __c_locale&) throw();
      86             : 
      87             :   // NB: __pad is a struct, rather than a function, so it can be
      88             :   // partially-specialized.
      89             :   template<typename _CharT, typename _Traits>
      90             :     struct __pad
      91             :     {
      92             :       static void
      93             :       _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
      94             :              const _CharT* __olds, streamsize __newlen, streamsize __oldlen);
      95             :     };
      96             : 
      97             :   // Used by both numeric and monetary facets.
      98             :   // Inserts "group separator" characters into an array of characters.
      99             :   // It's recursive, one iteration per group.  It moves the characters
     100             :   // in the buffer this way: "xxxx12345" -> "12,345xxx".  Call this
     101             :   // only with __gsize != 0.
     102             :   template<typename _CharT>
     103             :     _CharT*
     104             :     __add_grouping(_CharT* __s, _CharT __sep,
     105             :                    const char* __gbeg, size_t __gsize,
     106             :                    const _CharT* __first, const _CharT* __last);
     107             : 
     108             :   // This template permits specializing facet output code for
     109             :   // ostreambuf_iterator.  For ostreambuf_iterator, sputn is
     110             :   // significantly more efficient than incrementing iterators.
     111             :   template<typename _CharT>
     112             :     inline
     113             :     ostreambuf_iterator<_CharT>
     114             :     __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
     115             :     {
     116             :       __s._M_put(__ws, __len);
     117             :       return __s;
     118             :     }
     119             : 
     120             :   // This is the unspecialized form of the template.
     121             :   template<typename _CharT, typename _OutIter>
     122             :     inline
     123             :     _OutIter
     124             :     __write(_OutIter __s, const _CharT* __ws, int __len)
     125             :     {
     126             :       for (int __j = 0; __j < __len; __j++, ++__s)
     127             :         *__s = __ws[__j];
     128             :       return __s;
     129             :     }
     130             : 
     131             : 
     132             :   // 22.2.1.1  Template class ctype
     133             :   // Include host and configuration specific ctype enums for ctype_base.
     134             : 
     135             :   /**
     136             :    *  @brief  Common base for ctype facet
     137             :    *
     138             :    *  This template class provides implementations of the public functions
     139             :    *  that forward to the protected virtual functions.
     140             :    *
     141             :    *  This template also provides abstract stubs for the protected virtual
     142             :    *  functions.
     143             :   */
     144             :   template<typename _CharT>
     145             :     class __ctype_abstract_base : public locale::facet, public ctype_base
     146             :     {
     147             :     public:
     148             :       // Types:
     149             :       /// Typedef for the template parameter
     150             :       typedef _CharT char_type;
     151             : 
     152             :       /**
     153             :        *  @brief  Test char_type classification.
     154             :        *
     155             :        *  This function finds a mask M for @a c and compares it to mask @a m.
     156             :        *  It does so by returning the value of ctype<char_type>::do_is().
     157             :        *
     158             :        *  @param c  The char_type to compare the mask of.
     159             :        *  @param m  The mask to compare against.
     160             :        *  @return  (M & m) != 0.
     161             :       */
     162             :       bool
     163             :       is(mask __m, char_type __c) const
     164             :       { return this->do_is(__m, __c); }
     165             : 
     166             :       /**
     167             :        *  @brief  Return a mask array.
     168             :        *
     169             :        *  This function finds the mask for each char_type in the range [lo,hi)
     170             :        *  and successively writes it to vec.  vec must have as many elements
     171             :        *  as the char array.  It does so by returning the value of
     172             :        *  ctype<char_type>::do_is().
     173             :        *
     174             :        *  @param lo  Pointer to start of range.
     175             :        *  @param hi  Pointer to end of range.
     176             :        *  @param vec  Pointer to an array of mask storage.
     177             :        *  @return  @a hi.
     178             :       */
     179             :       const char_type*
     180             :       is(const char_type *__lo, const char_type *__hi, mask *__vec) const
     181             :       { return this->do_is(__lo, __hi, __vec); }
     182             : 
     183             :       /**
     184             :        *  @brief  Find char_type matching a mask
     185             :        *
     186             :        *  This function searches for and returns the first char_type c in
     187             :        *  [lo,hi) for which is(m,c) is true.  It does so by returning
     188             :        *  ctype<char_type>::do_scan_is().
     189             :        *
     190             :        *  @param m  The mask to compare against.
     191             :        *  @param lo  Pointer to start of range.
     192             :        *  @param hi  Pointer to end of range.
     193             :        *  @return  Pointer to matching char_type if found, else @a hi.
     194             :       */
     195             :       const char_type*
     196             :       scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
     197             :       { return this->do_scan_is(__m, __lo, __hi); }
     198             : 
     199             :       /**
     200             :        *  @brief  Find char_type not matching a mask
     201             :        *
     202             :        *  This function searches for and returns the first char_type c in
     203             :        *  [lo,hi) for which is(m,c) is false.  It does so by returning
     204             :        *  ctype<char_type>::do_scan_not().
     205             :        *
     206             :        *  @param m  The mask to compare against.
     207             :        *  @param lo  Pointer to first char in range.
     208             :        *  @param hi  Pointer to end of range.
     209             :        *  @return  Pointer to non-matching char if found, else @a hi.
     210             :       */
     211             :       const char_type*
     212             :       scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
     213             :       { return this->do_scan_not(__m, __lo, __hi); }
     214             : 
     215             :       /**
     216             :        *  @brief  Convert to uppercase.
     217             :        *
     218             :        *  This function converts the argument to uppercase if possible.
     219             :        *  If not possible (for example, '2'), returns the argument.  It does
     220             :        *  so by returning ctype<char_type>::do_toupper().
     221             :        *
     222             :        *  @param c  The char_type to convert.
     223             :        *  @return  The uppercase char_type if convertible, else @a c.
     224             :       */
     225             :       char_type
     226             :       toupper(char_type __c) const
     227             :       { return this->do_toupper(__c); }
     228             : 
     229             :       /**
     230             :        *  @brief  Convert array to uppercase.
     231             :        *
     232             :        *  This function converts each char_type in the range [lo,hi) to
     233             :        *  uppercase if possible.  Other elements remain untouched.  It does so
     234             :        *  by returning ctype<char_type>:: do_toupper(lo, hi).
     235             :        *
     236             :        *  @param lo  Pointer to start of range.
     237             :        *  @param hi  Pointer to end of range.
     238             :        *  @return  @a hi.
     239             :       */
     240             :       const char_type*
     241             :       toupper(char_type *__lo, const char_type* __hi) const
     242             :       { return this->do_toupper(__lo, __hi); }
     243             : 
     244             :       /**
     245             :        *  @brief  Convert to lowercase.
     246             :        *
     247             :        *  This function converts the argument to lowercase if possible.  If
     248             :        *  not possible (for example, '2'), returns the argument.  It does so
     249             :        *  by returning ctype<char_type>::do_tolower(c).
     250             :        *
     251             :        *  @param c  The char_type to convert.
     252             :        *  @return  The lowercase char_type if convertible, else @a c.
     253             :       */
     254             :       char_type
     255             :       tolower(char_type __c) const
     256             :       { return this->do_tolower(__c); }
     257             : 
     258             :       /**
     259             :        *  @brief  Convert array to lowercase.
     260             :        *
     261             :        *  This function converts each char_type in the range [lo,hi) to
     262             :        *  lowercase if possible.  Other elements remain untouched.  It does so
     263             :        *  by returning ctype<char_type>:: do_tolower(lo, hi).
     264             :        *
     265             :        *  @param lo  Pointer to start of range.
     266             :        *  @param hi  Pointer to end of range.
     267             :        *  @return  @a hi.
     268             :       */
     269             :       const char_type*
     270             :       tolower(char_type* __lo, const char_type* __hi) const
     271             :       { return this->do_tolower(__lo, __hi); }
     272             : 
     273             :       /**
     274             :        *  @brief  Widen char to char_type
     275             :        *
     276             :        *  This function converts the char argument to char_type using the
     277             :        *  simplest reasonable transformation.  It does so by returning
     278             :        *  ctype<char_type>::do_widen(c).
     279             :        *
     280             :        *  Note: this is not what you want for codepage conversions.  See
     281             :        *  codecvt for that.
     282             :        *
     283             :        *  @param c  The char to convert.
     284             :        *  @return  The converted char_type.
     285             :       */
     286             :       char_type
     287             :       widen(char __c) const
     288             :       { return this->do_widen(__c); }
     289             : 
     290             :       /**
     291             :        *  @brief  Widen array to char_type
     292             :        *
     293             :        *  This function converts each char in the input to char_type using the
     294             :        *  simplest reasonable transformation.  It does so by returning
     295             :        *  ctype<char_type>::do_widen(c).
     296             :        *
     297             :        *  Note: this is not what you want for codepage conversions.  See
     298             :        *  codecvt for that.
     299             :        *
     300             :        *  @param lo  Pointer to start of range.
     301             :        *  @param hi  Pointer to end of range.
     302             :        *  @param to  Pointer to the destination array.
     303             :        *  @return  @a hi.
     304             :       */
     305             :       const char*
     306             :       widen(const char* __lo, const char* __hi, char_type* __to) const
     307             :       { return this->do_widen(__lo, __hi, __to); }
     308             : 
     309             :       /**
     310             :        *  @brief  Narrow char_type to char
     311             :        *
     312             :        *  This function converts the char_type to char using the simplest
     313             :        *  reasonable transformation.  If the conversion fails, dfault is
     314             :        *  returned instead.  It does so by returning
     315             :        *  ctype<char_type>::do_narrow(c).
     316             :        *
     317             :        *  Note: this is not what you want for codepage conversions.  See
     318             :        *  codecvt for that.
     319             :        *
     320             :        *  @param c  The char_type to convert.
     321             :        *  @param dfault  Char to return if conversion fails.
     322             :        *  @return  The converted char.
     323             :       */
     324             :       char
     325             :       narrow(char_type __c, char __dfault) const
     326             :       { return this->do_narrow(__c, __dfault); }
     327             : 
     328             :       /**
     329             :        *  @brief  Narrow array to char array
     330             :        *
     331             :        *  This function converts each char_type in the input to char using the
     332             :        *  simplest reasonable transformation and writes the results to the
     333             :        *  destination array.  For any char_type in the input that cannot be
     334             :        *  converted, @a dfault is used instead.  It does so by returning
     335             :        *  ctype<char_type>::do_narrow(lo, hi, dfault, to).
     336             :        *
     337             :        *  Note: this is not what you want for codepage conversions.  See
     338             :        *  codecvt for that.
     339             :        *
     340             :        *  @param lo  Pointer to start of range.
     341             :        *  @param hi  Pointer to end of range.
     342             :        *  @param dfault  Char to use if conversion fails.
     343             :        *  @param to  Pointer to the destination array.
     344             :        *  @return  @a hi.
     345             :       */
     346             :       const char_type*
     347             :       narrow(const char_type* __lo, const char_type* __hi,
     348             :               char __dfault, char *__to) const
     349             :       { return this->do_narrow(__lo, __hi, __dfault, __to); }
     350             : 
     351             :     protected:
     352             :       explicit
     353             :       __ctype_abstract_base(size_t __refs = 0): facet(__refs) { }
     354             : 
     355             :       virtual
     356             :       ~__ctype_abstract_base() { }
     357             : 
     358             :       /**
     359             :        *  @brief  Test char_type classification.
     360             :        *
     361             :        *  This function finds a mask M for @a c and compares it to mask @a m.
     362             :        *
     363             :        *  do_is() is a hook for a derived facet to change the behavior of
     364             :        *  classifying.  do_is() must always return the same result for the
     365             :        *  same input.
     366             :        *
     367             :        *  @param c  The char_type to find the mask of.
     368             :        *  @param m  The mask to compare against.
     369             :        *  @return  (M & m) != 0.
     370             :       */
     371             :       virtual bool
     372             :       do_is(mask __m, char_type __c) const = 0;
     373             : 
     374             :       /**
     375             :        *  @brief  Return a mask array.
     376             :        *
     377             :        *  This function finds the mask for each char_type in the range [lo,hi)
     378             :        *  and successively writes it to vec.  vec must have as many elements
     379             :        *  as the input.
     380             :        *
     381             :        *  do_is() is a hook for a derived facet to change the behavior of
     382             :        *  classifying.  do_is() must always return the same result for the
     383             :        *  same input.
     384             :        *
     385             :        *  @param lo  Pointer to start of range.
     386             :        *  @param hi  Pointer to end of range.
     387             :        *  @param vec  Pointer to an array of mask storage.
     388             :        *  @return  @a hi.
     389             :       */
     390             :       virtual const char_type*
     391             :       do_is(const char_type* __lo, const char_type* __hi,
     392             :             mask* __vec) const = 0;
     393             : 
     394             :       /**
     395             :        *  @brief  Find char_type matching mask
     396             :        *
     397             :        *  This function searches for and returns the first char_type c in
     398             :        *  [lo,hi) for which is(m,c) is true.
     399             :        *
     400             :        *  do_scan_is() is a hook for a derived facet to change the behavior of
     401             :        *  match searching.  do_is() must always return the same result for the
     402             :        *  same input.
     403             :        *
     404             :        *  @param m  The mask to compare against.
     405             :        *  @param lo  Pointer to start of range.
     406             :        *  @param hi  Pointer to end of range.
     407             :        *  @return  Pointer to a matching char_type if found, else @a hi.
     408             :       */
     409             :       virtual const char_type*
     410             :       do_scan_is(mask __m, const char_type* __lo,
     411             :                  const char_type* __hi) const = 0;
     412             : 
     413             :       /**
     414             :        *  @brief  Find char_type not matching mask
     415             :        *
     416             :        *  This function searches for and returns a pointer to the first
     417             :        *  char_type c of [lo,hi) for which is(m,c) is false.
     418             :        *
     419             :        *  do_scan_is() is a hook for a derived facet to change the behavior of
     420             :        *  match searching.  do_is() must always return the same result for the
     421             :        *  same input.
     422             :        *
     423             :        *  @param m  The mask to compare against.
     424             :        *  @param lo  Pointer to start of range.
     425             :        *  @param hi  Pointer to end of range.
     426             :        *  @return  Pointer to a non-matching char_type if found, else @a hi.
     427             :       */
     428             :       virtual const char_type*
     429             :       do_scan_not(mask __m, const char_type* __lo,
     430             :                   const char_type* __hi) const = 0;
     431             : 
     432             :       /**
     433             :        *  @brief  Convert to uppercase.
     434             :        *
     435             :        *  This virtual function converts the char_type argument to uppercase
     436             :        *  if possible.  If not possible (for example, '2'), returns the
     437             :        *  argument.
     438             :        *
     439             :        *  do_toupper() is a hook for a derived facet to change the behavior of
     440             :        *  uppercasing.  do_toupper() must always return the same result for
     441             :        *  the same input.
     442             :        *
     443             :        *  @param c  The char_type to convert.
     444             :        *  @return  The uppercase char_type if convertible, else @a c.
     445             :       */
     446             :       virtual char_type
     447             :       do_toupper(char_type) const = 0;
     448             : 
     449             :       /**
     450             :        *  @brief  Convert array to uppercase.
     451             :        *
     452             :        *  This virtual function converts each char_type in the range [lo,hi)
     453             :        *  to uppercase if possible.  Other elements remain untouched.
     454             :        *
     455             :        *  do_toupper() is a hook for a derived facet to change the behavior of
     456             :        *  uppercasing.  do_toupper() must always return the same result for
     457             :        *  the same input.
     458             :        *
     459             :        *  @param lo  Pointer to start of range.
     460             :        *  @param hi  Pointer to end of range.
     461             :        *  @return  @a hi.
     462             :       */
     463             :       virtual const char_type*
     464             :       do_toupper(char_type* __lo, const char_type* __hi) const = 0;
     465             : 
     466             :       /**
     467             :        *  @brief  Convert to lowercase.
     468             :        *
     469             :        *  This virtual function converts the argument to lowercase if
     470             :        *  possible.  If not possible (for example, '2'), returns the argument.
     471             :        *
     472             :        *  do_tolower() is a hook for a derived facet to change the behavior of
     473             :        *  lowercasing.  do_tolower() must always return the same result for
     474             :        *  the same input.
     475             :        *
     476             :        *  @param c  The char_type to convert.
     477             :        *  @return  The lowercase char_type if convertible, else @a c.
     478             :       */
     479             :       virtual char_type
     480             :       do_tolower(char_type) const = 0;
     481             : 
     482             :       /**
     483             :        *  @brief  Convert array to lowercase.
     484             :        *
     485             :        *  This virtual function converts each char_type in the range [lo,hi)
     486             :        *  to lowercase if possible.  Other elements remain untouched.
     487             :        *
     488             :        *  do_tolower() is a hook for a derived facet to change the behavior of
     489             :        *  lowercasing.  do_tolower() must always return the same result for
     490             :        *  the same input.
     491             :        *
     492             :        *  @param lo  Pointer to start of range.
     493             :        *  @param hi  Pointer to end of range.
     494             :        *  @return  @a hi.
     495             :       */
     496             :       virtual const char_type*
     497             :       do_tolower(char_type* __lo, const char_type* __hi) const = 0;
     498             : 
     499             :       /**
     500             :        *  @brief  Widen char
     501             :        *
     502             :        *  This virtual function converts the char to char_type using the
     503             :        *  simplest reasonable transformation.
     504             :        *
     505             :        *  do_widen() is a hook for a derived facet to change the behavior of
     506             :        *  widening.  do_widen() must always return the same result for the
     507             :        *  same input.
     508             :        *
     509             :        *  Note: this is not what you want for codepage conversions.  See
     510             :        *  codecvt for that.
     511             :        *
     512             :        *  @param c  The char to convert.
     513             :        *  @return  The converted char_type
     514             :       */
     515             :       virtual char_type
     516             :       do_widen(char) const = 0;
     517             : 
     518             :       /**
     519             :        *  @brief  Widen char array
     520             :        *
     521             :        *  This function converts each char in the input to char_type using the
     522             :        *  simplest reasonable transformation.
     523             :        *
     524             :        *  do_widen() is a hook for a derived facet to change the behavior of
     525             :        *  widening.  do_widen() must always return the same result for the
     526             :        *  same input.
     527             :        *
     528             :        *  Note: this is not what you want for codepage conversions.  See
     529             :        *  codecvt for that.
     530             :        *
     531             :        *  @param lo  Pointer to start range.
     532             :        *  @param hi  Pointer to end of range.
     533             :        *  @param to  Pointer to the destination array.
     534             :        *  @return  @a hi.
     535             :       */
     536             :       virtual const char*
     537             :       do_widen(const char* __lo, const char* __hi,
     538             :                char_type* __dest) const = 0;
     539             : 
     540             :       /**
     541             :        *  @brief  Narrow char_type to char
     542             :        *
     543             :        *  This virtual function converts the argument to char using the
     544             :        *  simplest reasonable transformation.  If the conversion fails, dfault
     545             :        *  is returned instead.
     546             :        *
     547             :        *  do_narrow() is a hook for a derived facet to change the behavior of
     548             :        *  narrowing.  do_narrow() must always return the same result for the
     549             :        *  same input.
     550             :        *
     551             :        *  Note: this is not what you want for codepage conversions.  See
     552             :        *  codecvt for that.
     553             :        *
     554             :        *  @param c  The char_type to convert.
     555             :        *  @param dfault  Char to return if conversion fails.
     556             :        *  @return  The converted char.
     557             :       */
     558             :       virtual char
     559             :       do_narrow(char_type, char __dfault) const = 0;
     560             : 
     561             :       /**
     562             :        *  @brief  Narrow char_type array to char
     563             :        *
     564             :        *  This virtual function converts each char_type in the range [lo,hi) to
     565             :        *  char using the simplest reasonable transformation and writes the
     566             :        *  results to the destination array.  For any element in the input that
     567             :        *  cannot be converted, @a dfault is used instead.
     568             :        *
     569             :        *  do_narrow() is a hook for a derived facet to change the behavior of
     570             :        *  narrowing.  do_narrow() must always return the same result for the
     571             :        *  same input.
     572             :        *
     573             :        *  Note: this is not what you want for codepage conversions.  See
     574             :        *  codecvt for that.
     575             :        *
     576             :        *  @param lo  Pointer to start of range.
     577             :        *  @param hi  Pointer to end of range.
     578             :        *  @param dfault  Char to use if conversion fails.
     579             :        *  @param to  Pointer to the destination array.
     580             :        *  @return  @a hi.
     581             :       */
     582             :       virtual const char_type*
     583             :       do_narrow(const char_type* __lo, const char_type* __hi,
     584             :                 char __dfault, char* __dest) const = 0;
     585             :     };
     586             : 
     587             :   /**
     588             :    *  @brief  Primary class template ctype facet.
     589             :    *  @ingroup locales
     590             :    *
     591             :    *  This template class defines classification and conversion functions for
     592             :    *  character sets.  It wraps cctype functionality.  Ctype gets used by
     593             :    *  streams for many I/O operations.
     594             :    *
     595             :    *  This template provides the protected virtual functions the developer
     596             :    *  will have to replace in a derived class or specialization to make a
     597             :    *  working facet.  The public functions that access them are defined in
     598             :    *  __ctype_abstract_base, to allow for implementation flexibility.  See
     599             :    *  ctype<wchar_t> for an example.  The functions are documented in
     600             :    *  __ctype_abstract_base.
     601             :    *
     602             :    *  Note: implementations are provided for all the protected virtual
     603             :    *  functions, but will likely not be useful.
     604             :   */
     605             :   template<typename _CharT>
     606             :     class ctype : public __ctype_abstract_base<_CharT>
     607             :     {
     608             :     public:
     609             :       // Types:
     610             :       typedef _CharT                    char_type;
     611             :       typedef typename __ctype_abstract_base<_CharT>::mask mask;
     612             : 
     613             :       /// The facet id for ctype<char_type>
     614             :       static locale::id                 id;
     615             : 
     616             :       explicit
     617             :       ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
     618             : 
     619             :    protected:
     620             :       virtual
     621             :       ~ctype();
     622             : 
     623             :       virtual bool
     624             :       do_is(mask __m, char_type __c) const;
     625             : 
     626             :       virtual const char_type*
     627             :       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
     628             : 
     629             :       virtual const char_type*
     630             :       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
     631             : 
     632             :       virtual const char_type*
     633             :       do_scan_not(mask __m, const char_type* __lo,
     634             :                   const char_type* __hi) const;
     635             : 
     636             :       virtual char_type
     637             :       do_toupper(char_type __c) const;
     638             : 
     639             :       virtual const char_type*
     640             :       do_toupper(char_type* __lo, const char_type* __hi) const;
     641             : 
     642             :       virtual char_type
     643             :       do_tolower(char_type __c) const;
     644             : 
     645             :       virtual const char_type*
     646             :       do_tolower(char_type* __lo, const char_type* __hi) const;
     647             : 
     648             :       virtual char_type
     649             :       do_widen(char __c) const;
     650             : 
     651             :       virtual const char*
     652             :       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
     653             : 
     654             :       virtual char
     655             :       do_narrow(char_type, char __dfault) const;
     656             : 
     657             :       virtual const char_type*
     658             :       do_narrow(const char_type* __lo, const char_type* __hi,
     659             :                 char __dfault, char* __dest) const;
     660             :     };
     661             : 
     662             :   template<typename _CharT>
     663             :     locale::id ctype<_CharT>::id;
     664             : 
     665             :   /**
     666             :    *  @brief  The ctype<char> specialization.
     667             :    *  @ingroup locales
     668             :    *
     669             :    *  This class defines classification and conversion functions for
     670             :    *  the char type.  It gets used by char streams for many I/O
     671             :    *  operations.  The char specialization provides a number of
     672             :    *  optimizations as well.
     673             :   */
     674             :   template<>
     675             :     class ctype<char> : public locale::facet, public ctype_base
     676             :     {
     677             :     public:
     678             :       // Types:
     679             :       /// Typedef for the template parameter char.
     680             :       typedef char              char_type;
     681             : 
     682             :     protected:
     683             :       // Data Members:
     684             :       __c_locale                _M_c_locale_ctype;
     685             :       bool                      _M_del;
     686             :       __to_type                 _M_toupper;
     687             :       __to_type                 _M_tolower;
     688             :       const mask*               _M_table;
     689             :       mutable char              _M_widen_ok;
     690             :       mutable char              _M_widen[1 + static_cast<unsigned char>(-1)];
     691             :       mutable char              _M_narrow[1 + static_cast<unsigned char>(-1)];
     692             :       mutable char              _M_narrow_ok;   // 0 uninitialized, 1 init,
     693             :                                                 // 2 memcpy can't be used
     694             : 
     695             :     public:
     696             :       /// The facet id for ctype<char>
     697             :       static locale::id        id;
     698             :       /// The size of the mask table.  It is SCHAR_MAX + 1.
     699             :       static const size_t      table_size = 1 + static_cast<unsigned char>(-1);
     700             : 
     701             :       /**
     702             :        *  @brief  Constructor performs initialization.
     703             :        *
     704             :        *  This is the constructor provided by the standard.
     705             :        *
     706             :        *  @param table If non-zero, table is used as the per-char mask.
     707             :        *               Else classic_table() is used.
     708             :        *  @param del   If true, passes ownership of table to this facet.
     709             :        *  @param refs  Passed to the base facet class.
     710             :       */
     711             :       explicit
     712             :       ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
     713             : 
     714             :       /**
     715             :        *  @brief  Constructor performs static initialization.
     716             :        *
     717             :        *  This constructor is used to construct the initial C locale facet.
     718             :        *
     719             :        *  @param cloc  Handle to C locale data.
     720             :        *  @param table If non-zero, table is used as the per-char mask.
     721             :        *  @param del   If true, passes ownership of table to this facet.
     722             :        *  @param refs  Passed to the base facet class.
     723             :       */
     724             :       explicit
     725             :       ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false,
     726             :             size_t __refs = 0);
     727             : 
     728             :       /**
     729             :        *  @brief  Test char classification.
     730             :        *
     731             :        *  This function compares the mask table[c] to @a m.
     732             :        *
     733             :        *  @param c  The char to compare the mask of.
     734             :        *  @param m  The mask to compare against.
     735             :        *  @return  True if m & table[c] is true, false otherwise.
     736             :       */
     737             :       inline bool
     738             :       is(mask __m, char __c) const;
     739             : 
     740             :       /**
     741             :        *  @brief  Return a mask array.
     742             :        *
     743             :        *  This function finds the mask for each char in the range [lo, hi) and
     744             :        *  successively writes it to vec.  vec must have as many elements as
     745             :        *  the char array.
     746             :        *
     747             :        *  @param lo  Pointer to start of range.
     748             :        *  @param hi  Pointer to end of range.
     749             :        *  @param vec  Pointer to an array of mask storage.
     750             :        *  @return  @a hi.
     751             :       */
     752             :       inline const char*
     753             :       is(const char* __lo, const char* __hi, mask* __vec) const;
     754             : 
     755             :       /**
     756             :        *  @brief  Find char matching a mask
     757             :        *
     758             :        *  This function searches for and returns the first char in [lo,hi) for
     759             :        *  which is(m,char) is true.
     760             :        *
     761             :        *  @param m  The mask to compare against.
     762             :        *  @param lo  Pointer to start of range.
     763             :        *  @param hi  Pointer to end of range.
     764             :        *  @return  Pointer to a matching char if found, else @a hi.
     765             :       */
     766             :       inline const char*
     767             :       scan_is(mask __m, const char* __lo, const char* __hi) const;
     768             : 
     769             :       /**
     770             :        *  @brief  Find char not matching a mask
     771             :        *
     772             :        *  This function searches for and returns a pointer to the first char
     773             :        *  in [lo,hi) for which is(m,char) is false.
     774             :        *
     775             :        *  @param m  The mask to compare against.
     776             :        *  @param lo  Pointer to start of range.
     777             :        *  @param hi  Pointer to end of range.
     778             :        *  @return  Pointer to a non-matching char if found, else @a hi.
     779             :       */
     780             :       inline const char*
     781             :       scan_not(mask __m, const char* __lo, const char* __hi) const;
     782             : 
     783             :       /**
     784             :        *  @brief  Convert to uppercase.
     785             :        *
     786             :        *  This function converts the char argument to uppercase if possible.
     787             :        *  If not possible (for example, '2'), returns the argument.
     788             :        *
     789             :        *  toupper() acts as if it returns ctype<char>::do_toupper(c).
     790             :        *  do_toupper() must always return the same result for the same input.
     791             :        *
     792             :        *  @param c  The char to convert.
     793             :        *  @return  The uppercase char if convertible, else @a c.
     794             :       */
     795             :       char_type
     796             :       toupper(char_type __c) const
     797             :       { return this->do_toupper(__c); }
     798             : 
     799             :       /**
     800             :        *  @brief  Convert array to uppercase.
     801             :        *
     802             :        *  This function converts each char in the range [lo,hi) to uppercase
     803             :        *  if possible.  Other chars remain untouched.
     804             :        *
     805             :        *  toupper() acts as if it returns ctype<char>:: do_toupper(lo, hi).
     806             :        *  do_toupper() must always return the same result for the same input.
     807             :        *
     808             :        *  @param lo  Pointer to first char in range.
     809             :        *  @param hi  Pointer to end of range.
     810             :        *  @return  @a hi.
     811             :       */
     812             :       const char_type*
     813             :       toupper(char_type *__lo, const char_type* __hi) const
     814             :       { return this->do_toupper(__lo, __hi); }
     815             : 
     816             :       /**
     817             :        *  @brief  Convert to lowercase.
     818             :        *
     819             :        *  This function converts the char argument to lowercase if possible.
     820             :        *  If not possible (for example, '2'), returns the argument.
     821             :        *
     822             :        *  tolower() acts as if it returns ctype<char>::do_tolower(c).
     823             :        *  do_tolower() must always return the same result for the same input.
     824             :        *
     825             :        *  @param c  The char to convert.
     826             :        *  @return  The lowercase char if convertible, else @a c.
     827             :       */
     828             :       char_type
     829             :       tolower(char_type __c) const
     830             :       { return this->do_tolower(__c); }
     831             : 
     832             :       /**
     833             :        *  @brief  Convert array to lowercase.
     834             :        *
     835             :        *  This function converts each char in the range [lo,hi) to lowercase
     836             :        *  if possible.  Other chars remain untouched.
     837             :        *
     838             :        *  tolower() acts as if it returns ctype<char>:: do_tolower(lo, hi).
     839             :        *  do_tolower() must always return the same result for the same input.
     840             :        *
     841             :        *  @param lo  Pointer to first char in range.
     842             :        *  @param hi  Pointer to end of range.
     843             :        *  @return  @a hi.
     844             :       */
     845             :       const char_type*
     846             :       tolower(char_type* __lo, const char_type* __hi) const
     847             :       { return this->do_tolower(__lo, __hi); }
     848             : 
     849             :       /**
     850             :        *  @brief  Widen char
     851             :        *
     852             :        *  This function converts the char to char_type using the simplest
     853             :        *  reasonable transformation.  For an underived ctype<char> facet, the
     854             :        *  argument will be returned unchanged.
     855             :        *
     856             :        *  This function works as if it returns ctype<char>::do_widen(c).
     857             :        *  do_widen() must always return the same result for the same input.
     858             :        *
     859             :        *  Note: this is not what you want for codepage conversions.  See
     860             :        *  codecvt for that.
     861             :        *
     862             :        *  @param c  The char to convert.
     863             :        *  @return  The converted character.
     864             :       */
     865             :       char_type
     866           0 :       widen(char __c) const
     867             :       {
     868           0 :         if (_M_widen_ok)
     869           0 :           return _M_widen[static_cast<unsigned char>(__c)];
     870           0 :         this->_M_widen_init();
     871           0 :         return this->do_widen(__c);
     872             :       }
     873             : 
     874             :       /**
     875             :        *  @brief  Widen char array
     876             :        *
     877             :        *  This function converts each char in the input to char using the
     878             :        *  simplest reasonable transformation.  For an underived ctype<char>
     879             :        *  facet, the argument will be copied unchanged.
     880             :        *
     881             :        *  This function works as if it returns ctype<char>::do_widen(c).
     882             :        *  do_widen() must always return the same result for the same input.
     883             :        *
     884             :        *  Note: this is not what you want for codepage conversions.  See
     885             :        *  codecvt for that.
     886             :        *
     887             :        *  @param lo  Pointer to first char in range.
     888             :        *  @param hi  Pointer to end of range.
     889             :        *  @param to  Pointer to the destination array.
     890             :        *  @return  @a hi.
     891             :       */
     892             :       const char*
     893             :       widen(const char* __lo, const char* __hi, char_type* __to) const
     894             :       {
     895             :         if (_M_widen_ok == 1)
     896             :           {
     897             :             __builtin_memcpy(__to, __lo, __hi - __lo);
     898             :             return __hi;
     899             :           }
     900             :         if (!_M_widen_ok)
     901             :           _M_widen_init();
     902             :         return this->do_widen(__lo, __hi, __to);
     903             :       }
     904             : 
     905             :       /**
     906             :        *  @brief  Narrow char
     907             :        *
     908             :        *  This function converts the char to char using the simplest
     909             :        *  reasonable transformation.  If the conversion fails, dfault is
     910             :        *  returned instead.  For an underived ctype<char> facet, @a c
     911             :        *  will be returned unchanged.
     912             :        *
     913             :        *  This function works as if it returns ctype<char>::do_narrow(c).
     914             :        *  do_narrow() must always return the same result for the same input.
     915             :        *
     916             :        *  Note: this is not what you want for codepage conversions.  See
     917             :        *  codecvt for that.
     918             :        *
     919             :        *  @param c  The char to convert.
     920             :        *  @param dfault  Char to return if conversion fails.
     921             :        *  @return  The converted character.
     922             :       */
     923             :       char
     924             :       narrow(char_type __c, char __dfault) const
     925             :       {
     926             :         if (_M_narrow[static_cast<unsigned char>(__c)])
     927             :           return _M_narrow[static_cast<unsigned char>(__c)];
     928             :         const char __t = do_narrow(__c, __dfault);
     929             :         if (__t != __dfault)
     930             :           _M_narrow[static_cast<unsigned char>(__c)] = __t;
     931             :         return __t;
     932             :       }
     933             : 
     934             :       /**
     935             :        *  @brief  Narrow char array
     936             :        *
     937             :        *  This function converts each char in the input to char using the
     938             :        *  simplest reasonable transformation and writes the results to the
     939             :        *  destination array.  For any char in the input that cannot be
     940             :        *  converted, @a dfault is used instead.  For an underived ctype<char>
     941             :        *  facet, the argument will be copied unchanged.
     942             :        *
     943             :        *  This function works as if it returns ctype<char>::do_narrow(lo, hi,
     944             :        *  dfault, to).  do_narrow() must always return the same result for the
     945             :        *  same input.
     946             :        *
     947             :        *  Note: this is not what you want for codepage conversions.  See
     948             :        *  codecvt for that.
     949             :        *
     950             :        *  @param lo  Pointer to start of range.
     951             :        *  @param hi  Pointer to end of range.
     952             :        *  @param dfault  Char to use if conversion fails.
     953             :        *  @param to  Pointer to the destination array.
     954             :        *  @return  @a hi.
     955             :       */
     956             :       const char_type*
     957             :       narrow(const char_type* __lo, const char_type* __hi,
     958             :              char __dfault, char *__to) const
     959             :       {
     960             :         if (__builtin_expect(_M_narrow_ok == 1, true))
     961             :           {
     962             :             __builtin_memcpy(__to, __lo, __hi - __lo);
     963             :             return __hi;
     964             :           }
     965             :         if (!_M_narrow_ok)
     966             :           _M_narrow_init();
     967             :         return this->do_narrow(__lo, __hi, __dfault, __to);
     968             :       }
     969             : 
     970             :       // _GLIBCXX_RESOLVE_LIB_DEFECTS
     971             :       // DR 695. ctype<char>::classic_table() not accessible.
     972             :       /// Returns a pointer to the mask table provided to the constructor, or
     973             :       /// the default from classic_table() if none was provided.
     974             :       const mask*
     975             :       table() const throw()
     976             :       { return _M_table; }
     977             : 
     978             :       /// Returns a pointer to the C locale mask table.
     979             :       static const mask*
     980             :       classic_table() throw();
     981             :     protected:
     982             : 
     983             :       /**
     984             :        *  @brief  Destructor.
     985             :        *
     986             :        *  This function deletes table() if @a del was true in the
     987             :        *  constructor.
     988             :       */
     989             :       virtual
     990             :       ~ctype();
     991             : 
     992             :       /**
     993             :        *  @brief  Convert to uppercase.
     994             :        *
     995             :        *  This virtual function converts the char argument to uppercase if
     996             :        *  possible.  If not possible (for example, '2'), returns the argument.
     997             :        *
     998             :        *  do_toupper() is a hook for a derived facet to change the behavior of
     999             :        *  uppercasing.  do_toupper() must always return the same result for
    1000             :        *  the same input.
    1001             :        *
    1002             :        *  @param c  The char to convert.
    1003             :        *  @return  The uppercase char if convertible, else @a c.
    1004             :       */
    1005             :       virtual char_type
    1006             :       do_toupper(char_type) const;
    1007             : 
    1008             :       /**
    1009             :        *  @brief  Convert array to uppercase.
    1010             :        *
    1011             :        *  This virtual function converts each char in the range [lo,hi) to
    1012             :        *  uppercase if possible.  Other chars remain untouched.
    1013             :        *
    1014             :        *  do_toupper() is a hook for a derived facet to change the behavior of
    1015             :        *  uppercasing.  do_toupper() must always return the same result for
    1016             :        *  the same input.
    1017             :        *
    1018             :        *  @param lo  Pointer to start of range.
    1019             :        *  @param hi  Pointer to end of range.
    1020             :        *  @return  @a hi.
    1021             :       */
    1022             :       virtual const char_type*
    1023             :       do_toupper(char_type* __lo, const char_type* __hi) const;
    1024             : 
    1025             :       /**
    1026             :        *  @brief  Convert to lowercase.
    1027             :        *
    1028             :        *  This virtual function converts the char argument to lowercase if
    1029             :        *  possible.  If not possible (for example, '2'), returns the argument.
    1030             :        *
    1031             :        *  do_tolower() is a hook for a derived facet to change the behavior of
    1032             :        *  lowercasing.  do_tolower() must always return the same result for
    1033             :        *  the same input.
    1034             :        *
    1035             :        *  @param c  The char to convert.
    1036             :        *  @return  The lowercase char if convertible, else @a c.
    1037             :       */
    1038             :       virtual char_type
    1039             :       do_tolower(char_type) const;
    1040             : 
    1041             :       /**
    1042             :        *  @brief  Convert array to lowercase.
    1043             :        *
    1044             :        *  This virtual function converts each char in the range [lo,hi) to
    1045             :        *  lowercase if possible.  Other chars remain untouched.
    1046             :        *
    1047             :        *  do_tolower() is a hook for a derived facet to change the behavior of
    1048             :        *  lowercasing.  do_tolower() must always return the same result for
    1049             :        *  the same input.
    1050             :        *
    1051             :        *  @param lo  Pointer to first char in range.
    1052             :        *  @param hi  Pointer to end of range.
    1053             :        *  @return  @a hi.
    1054             :       */
    1055             :       virtual const char_type*
    1056             :       do_tolower(char_type* __lo, const char_type* __hi) const;
    1057             : 
    1058             :       /**
    1059             :        *  @brief  Widen char
    1060             :        *
    1061             :        *  This virtual function converts the char to char using the simplest
    1062             :        *  reasonable transformation.  For an underived ctype<char> facet, the
    1063             :        *  argument will be returned unchanged.
    1064             :        *
    1065             :        *  do_widen() is a hook for a derived facet to change the behavior of
    1066             :        *  widening.  do_widen() must always return the same result for the
    1067             :        *  same input.
    1068             :        *
    1069             :        *  Note: this is not what you want for codepage conversions.  See
    1070             :        *  codecvt for that.
    1071             :        *
    1072             :        *  @param c  The char to convert.
    1073             :        *  @return  The converted character.
    1074             :       */
    1075             :       virtual char_type
    1076           0 :       do_widen(char __c) const
    1077           0 :       { return __c; }
    1078             : 
    1079             :       /**
    1080             :        *  @brief  Widen char array
    1081             :        *
    1082             :        *  This function converts each char in the range [lo,hi) to char using
    1083             :        *  the simplest reasonable transformation.  For an underived
    1084             :        *  ctype<char> facet, the argument will be copied unchanged.
    1085             :        *
    1086             :        *  do_widen() is a hook for a derived facet to change the behavior of
    1087             :        *  widening.  do_widen() must always return the same result for the
    1088             :        *  same input.
    1089             :        *
    1090             :        *  Note: this is not what you want for codepage conversions.  See
    1091             :        *  codecvt for that.
    1092             :        *
    1093             :        *  @param lo  Pointer to start of range.
    1094             :        *  @param hi  Pointer to end of range.
    1095             :        *  @param to  Pointer to the destination array.
    1096             :        *  @return  @a hi.
    1097             :       */
    1098             :       virtual const char*
    1099           0 :       do_widen(const char* __lo, const char* __hi, char_type* __dest) const
    1100             :       {
    1101           0 :         __builtin_memcpy(__dest, __lo, __hi - __lo);
    1102           0 :         return __hi;
    1103             :       }
    1104             : 
    1105             :       /**
    1106             :        *  @brief  Narrow char
    1107             :        *
    1108             :        *  This virtual function converts the char to char using the simplest
    1109             :        *  reasonable transformation.  If the conversion fails, dfault is
    1110             :        *  returned instead.  For an underived ctype<char> facet, @a c will be
    1111             :        *  returned unchanged.
    1112             :        *
    1113             :        *  do_narrow() is a hook for a derived facet to change the behavior of
    1114             :        *  narrowing.  do_narrow() must always return the same result for the
    1115             :        *  same input.
    1116             :        *
    1117             :        *  Note: this is not what you want for codepage conversions.  See
    1118             :        *  codecvt for that.
    1119             :        *
    1120             :        *  @param c  The char to convert.
    1121             :        *  @param dfault  Char to return if conversion fails.
    1122             :        *  @return  The converted char.
    1123             :       */
    1124             :       virtual char
    1125           0 :       do_narrow(char_type __c, char) const
    1126           0 :       { return __c; }
    1127             : 
    1128             :       /**
    1129             :        *  @brief  Narrow char array to char array
    1130             :        *
    1131             :        *  This virtual function converts each char in the range [lo,hi) to
    1132             :        *  char using the simplest reasonable transformation and writes the
    1133             :        *  results to the destination array.  For any char in the input that
    1134             :        *  cannot be converted, @a dfault is used instead.  For an underived
    1135             :        *  ctype<char> facet, the argument will be copied unchanged.
    1136             :        *
    1137             :        *  do_narrow() is a hook for a derived facet to change the behavior of
    1138             :        *  narrowing.  do_narrow() must always return the same result for the
    1139             :        *  same input.
    1140             :        *
    1141             :        *  Note: this is not what you want for codepage conversions.  See
    1142             :        *  codecvt for that.
    1143             :        *
    1144             :        *  @param lo  Pointer to start of range.
    1145             :        *  @param hi  Pointer to end of range.
    1146             :        *  @param dfault  Char to use if conversion fails.
    1147             :        *  @param to  Pointer to the destination array.
    1148             :        *  @return  @a hi.
    1149             :       */
    1150             :       virtual const char_type*
    1151           0 :       do_narrow(const char_type* __lo, const char_type* __hi,
    1152             :                 char, char* __dest) const
    1153             :       {
    1154           0 :         __builtin_memcpy(__dest, __lo, __hi - __lo);
    1155           0 :         return __hi;
    1156             :       }
    1157             : 
    1158             :     private:
    1159             :       void _M_narrow_init() const;
    1160             :       void _M_widen_init() const;
    1161             :     };
    1162             : 
    1163             : #ifdef _GLIBCXX_USE_WCHAR_T
    1164             :   /**
    1165             :    *  @brief  The ctype<wchar_t> specialization.
    1166             :    *  @ingroup locales
    1167             :    *
    1168             :    *  This class defines classification and conversion functions for the
    1169             :    *  wchar_t type.  It gets used by wchar_t streams for many I/O operations.
    1170             :    *  The wchar_t specialization provides a number of optimizations as well.
    1171             :    *
    1172             :    *  ctype<wchar_t> inherits its public methods from
    1173             :    *  __ctype_abstract_base<wchar_t>.
    1174             :   */
    1175             :   template<>
    1176             :     class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
    1177             :     {
    1178             :     public:
    1179             :       // Types:
    1180             :       /// Typedef for the template parameter wchar_t.
    1181             :       typedef wchar_t           char_type;
    1182             :       typedef wctype_t          __wmask_type;
    1183             : 
    1184             :     protected:
    1185             :       __c_locale                _M_c_locale_ctype;
    1186             : 
    1187             :       // Pre-computed narrowed and widened chars.
    1188             :       bool                      _M_narrow_ok;
    1189             :       char                      _M_narrow[128];
    1190             :       wint_t                    _M_widen[1 + static_cast<unsigned char>(-1)];
    1191             : 
    1192             :       // Pre-computed elements for do_is.
    1193             :       mask                      _M_bit[16];
    1194             :       __wmask_type              _M_wmask[16];
    1195             : 
    1196             :     public:
    1197             :       // Data Members:
    1198             :       /// The facet id for ctype<wchar_t>
    1199             :       static locale::id         id;
    1200             : 
    1201             :       /**
    1202             :        *  @brief  Constructor performs initialization.
    1203             :        *
    1204             :        *  This is the constructor provided by the standard.
    1205             :        *
    1206             :        *  @param refs  Passed to the base facet class.
    1207             :       */
    1208             :       explicit
    1209             :       ctype(size_t __refs = 0);
    1210             : 
    1211             :       /**
    1212             :        *  @brief  Constructor performs static initialization.
    1213             :        *
    1214             :        *  This constructor is used to construct the initial C locale facet.
    1215             :        *
    1216             :        *  @param cloc  Handle to C locale data.
    1217             :        *  @param refs  Passed to the base facet class.
    1218             :       */
    1219             :       explicit
    1220             :       ctype(__c_locale __cloc, size_t __refs = 0);
    1221             : 
    1222             :     protected:
    1223             :       __wmask_type
    1224             :       _M_convert_to_wmask(const mask __m) const throw();
    1225             : 
    1226             :       /// Destructor
    1227             :       virtual
    1228             :       ~ctype();
    1229             : 
    1230             :       /**
    1231             :        *  @brief  Test wchar_t classification.
    1232             :        *
    1233             :        *  This function finds a mask M for @a c and compares it to mask @a m.
    1234             :        *
    1235             :        *  do_is() is a hook for a derived facet to change the behavior of
    1236             :        *  classifying.  do_is() must always return the same result for the
    1237             :        *  same input.
    1238             :        *
    1239             :        *  @param c  The wchar_t to find the mask of.
    1240             :        *  @param m  The mask to compare against.
    1241             :        *  @return  (M & m) != 0.
    1242             :       */
    1243             :       virtual bool
    1244             :       do_is(mask __m, char_type __c) const;
    1245             : 
    1246             :       /**
    1247             :        *  @brief  Return a mask array.
    1248             :        *
    1249             :        *  This function finds the mask for each wchar_t in the range [lo,hi)
    1250             :        *  and successively writes it to vec.  vec must have as many elements
    1251             :        *  as the input.
    1252             :        *
    1253             :        *  do_is() is a hook for a derived facet to change the behavior of
    1254             :        *  classifying.  do_is() must always return the same result for the
    1255             :        *  same input.
    1256             :        *
    1257             :        *  @param lo  Pointer to start of range.
    1258             :        *  @param hi  Pointer to end of range.
    1259             :        *  @param vec  Pointer to an array of mask storage.
    1260             :        *  @return  @a hi.
    1261             :       */
    1262             :       virtual const char_type*
    1263             :       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
    1264             : 
    1265             :       /**
    1266             :        *  @brief  Find wchar_t matching mask
    1267             :        *
    1268             :        *  This function searches for and returns the first wchar_t c in
    1269             :        *  [lo,hi) for which is(m,c) is true.
    1270             :        *
    1271             :        *  do_scan_is() is a hook for a derived facet to change the behavior of
    1272             :        *  match searching.  do_is() must always return the same result for the
    1273             :        *  same input.
    1274             :        *
    1275             :        *  @param m  The mask to compare against.
    1276             :        *  @param lo  Pointer to start of range.
    1277             :        *  @param hi  Pointer to end of range.
    1278             :        *  @return  Pointer to a matching wchar_t if found, else @a hi.
    1279             :       */
    1280             :       virtual const char_type*
    1281             :       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
    1282             : 
    1283             :       /**
    1284             :        *  @brief  Find wchar_t not matching mask
    1285             :        *
    1286             :        *  This function searches for and returns a pointer to the first
    1287             :        *  wchar_t c of [lo,hi) for which is(m,c) is false.
    1288             :        *
    1289             :        *  do_scan_is() is a hook for a derived facet to change the behavior of
    1290             :        *  match searching.  do_is() must always return the same result for the
    1291             :        *  same input.
    1292             :        *
    1293             :        *  @param m  The mask to compare against.
    1294             :        *  @param lo  Pointer to start of range.
    1295             :        *  @param hi  Pointer to end of range.
    1296             :        *  @return  Pointer to a non-matching wchar_t if found, else @a hi.
    1297             :       */
    1298             :       virtual const char_type*
    1299             :       do_scan_not(mask __m, const char_type* __lo,
    1300             :                   const char_type* __hi) const;
    1301             : 
    1302             :       /**
    1303             :        *  @brief  Convert to uppercase.
    1304             :        *
    1305             :        *  This virtual function converts the wchar_t argument to uppercase if
    1306             :        *  possible.  If not possible (for example, '2'), returns the argument.
    1307             :        *
    1308             :        *  do_toupper() is a hook for a derived facet to change the behavior of
    1309             :        *  uppercasing.  do_toupper() must always return the same result for
    1310             :        *  the same input.
    1311             :        *
    1312             :        *  @param c  The wchar_t to convert.
    1313             :        *  @return  The uppercase wchar_t if convertible, else @a c.
    1314             :       */
    1315             :       virtual char_type
    1316             :       do_toupper(char_type) const;
    1317             : 
    1318             :       /**
    1319             :        *  @brief  Convert array to uppercase.
    1320             :        *
    1321             :        *  This virtual function converts each wchar_t in the range [lo,hi) to
    1322             :        *  uppercase if possible.  Other elements remain untouched.
    1323             :        *
    1324             :        *  do_toupper() is a hook for a derived facet to change the behavior of
    1325             :        *  uppercasing.  do_toupper() must always return the same result for
    1326             :        *  the same input.
    1327             :        *
    1328             :        *  @param lo  Pointer to start of range.
    1329             :        *  @param hi  Pointer to end of range.
    1330             :        *  @return  @a hi.
    1331             :       */
    1332             :       virtual const char_type*
    1333             :       do_toupper(char_type* __lo, const char_type* __hi) const;
    1334             : 
    1335             :       /**
    1336             :        *  @brief  Convert to lowercase.
    1337             :        *
    1338             :        *  This virtual function converts the argument to lowercase if
    1339             :        *  possible.  If not possible (for example, '2'), returns the argument.
    1340             :        *
    1341             :        *  do_tolower() is a hook for a derived facet to change the behavior of
    1342             :        *  lowercasing.  do_tolower() must always return the same result for
    1343             :        *  the same input.
    1344             :        *
    1345             :        *  @param c  The wchar_t to convert.
    1346             :        *  @return  The lowercase wchar_t if convertible, else @a c.
    1347             :       */
    1348             :       virtual char_type
    1349             :       do_tolower(char_type) const;
    1350             : 
    1351             :       /**
    1352             :        *  @brief  Convert array to lowercase.
    1353             :        *
    1354             :        *  This virtual function converts each wchar_t in the range [lo,hi) to
    1355             :        *  lowercase if possible.  Other elements remain untouched.
    1356             :        *
    1357             :        *  do_tolower() is a hook for a derived facet to change the behavior of
    1358             :        *  lowercasing.  do_tolower() must always return the same result for
    1359             :        *  the same input.
    1360             :        *
    1361             :        *  @param lo  Pointer to start of range.
    1362             :        *  @param hi  Pointer to end of range.
    1363             :        *  @return  @a hi.
    1364             :       */
    1365             :       virtual const char_type*
    1366             :       do_tolower(char_type* __lo, const char_type* __hi) const;
    1367             : 
    1368             :       /**
    1369             :        *  @brief  Widen char to wchar_t
    1370             :        *
    1371             :        *  This virtual function converts the char to wchar_t using the
    1372             :        *  simplest reasonable transformation.  For an underived ctype<wchar_t>
    1373             :        *  facet, the argument will be cast to wchar_t.
    1374             :        *
    1375             :        *  do_widen() is a hook for a derived facet to change the behavior of
    1376             :        *  widening.  do_widen() must always return the same result for the
    1377             :        *  same input.
    1378             :        *
    1379             :        *  Note: this is not what you want for codepage conversions.  See
    1380             :        *  codecvt for that.
    1381             :        *
    1382             :        *  @param c  The char to convert.
    1383             :        *  @return  The converted wchar_t.
    1384             :       */
    1385             :       virtual char_type
    1386             :       do_widen(char) const;
    1387             : 
    1388             :       /**
    1389             :        *  @brief  Widen char array to wchar_t array
    1390             :        *
    1391             :        *  This function converts each char in the input to wchar_t using the
    1392             :        *  simplest reasonable transformation.  For an underived ctype<wchar_t>
    1393             :        *  facet, the argument will be copied, casting each element to wchar_t.
    1394             :        *
    1395             :        *  do_widen() is a hook for a derived facet to change the behavior of
    1396             :        *  widening.  do_widen() must always return the same result for the
    1397             :        *  same input.
    1398             :        *
    1399             :        *  Note: this is not what you want for codepage conversions.  See
    1400             :        *  codecvt for that.
    1401             :        *
    1402             :        *  @param lo  Pointer to start range.
    1403             :        *  @param hi  Pointer to end of range.
    1404             :        *  @param to  Pointer to the destination array.
    1405             :        *  @return  @a hi.
    1406             :       */
    1407             :       virtual const char*
    1408             :       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
    1409             : 
    1410             :       /**
    1411             :        *  @brief  Narrow wchar_t to char
    1412             :        *
    1413             :        *  This virtual function converts the argument to char using
    1414             :        *  the simplest reasonable transformation.  If the conversion
    1415             :        *  fails, dfault is returned instead.  For an underived
    1416             :        *  ctype<wchar_t> facet, @a c will be cast to char and
    1417             :        *  returned.
    1418             :        *
    1419             :        *  do_narrow() is a hook for a derived facet to change the
    1420             :        *  behavior of narrowing.  do_narrow() must always return the
    1421             :        *  same result for the same input.
    1422             :        *
    1423             :        *  Note: this is not what you want for codepage conversions.  See
    1424             :        *  codecvt for that.
    1425             :        *
    1426             :        *  @param c  The wchar_t to convert.
    1427             :        *  @param dfault  Char to return if conversion fails.
    1428             :        *  @return  The converted char.
    1429             :       */
    1430             :       virtual char
    1431             :       do_narrow(char_type, char __dfault) const;
    1432             : 
    1433             :       /**
    1434             :        *  @brief  Narrow wchar_t array to char array
    1435             :        *
    1436             :        *  This virtual function converts each wchar_t in the range [lo,hi) to
    1437             :        *  char using the simplest reasonable transformation and writes the
    1438             :        *  results to the destination array.  For any wchar_t in the input that
    1439             :        *  cannot be converted, @a dfault is used instead.  For an underived
    1440             :        *  ctype<wchar_t> facet, the argument will be copied, casting each
    1441             :        *  element to char.
    1442             :        *
    1443             :        *  do_narrow() is a hook for a derived facet to change the behavior of
    1444             :        *  narrowing.  do_narrow() must always return the same result for the
    1445             :        *  same input.
    1446             :        *
    1447             :        *  Note: this is not what you want for codepage conversions.  See
    1448             :        *  codecvt for that.
    1449             :        *
    1450             :        *  @param lo  Pointer to start of range.
    1451             :        *  @param hi  Pointer to end of range.
    1452             :        *  @param dfault  Char to use if conversion fails.
    1453             :        *  @param to  Pointer to the destination array.
    1454             :        *  @return  @a hi.
    1455             :       */
    1456             :       virtual const char_type*
    1457             :       do_narrow(const char_type* __lo, const char_type* __hi,
    1458             :                 char __dfault, char* __dest) const;
    1459             : 
    1460             :       // For use at construction time only.
    1461             :       void
    1462             :       _M_initialize_ctype() throw();
    1463             :     };
    1464             : #endif //_GLIBCXX_USE_WCHAR_T
    1465             : 
    1466             :   /// class ctype_byname [22.2.1.2].
    1467             :   template<typename _CharT>
    1468             :     class ctype_byname : public ctype<_CharT>
    1469             :     {
    1470             :     public:
    1471             :       typedef typename ctype<_CharT>::mask  mask;
    1472             : 
    1473             :       explicit
    1474             :       ctype_byname(const char* __s, size_t __refs = 0);
    1475             : 
    1476             :     protected:
    1477             :       virtual
    1478             :       ~ctype_byname() { };
    1479             :     };
    1480             : 
    1481             :   /// 22.2.1.4  Class ctype_byname specializations.
    1482             :   template<>
    1483             :     class ctype_byname<char> : public ctype<char>
    1484             :     {
    1485             :     public:
    1486             :       explicit
    1487             :       ctype_byname(const char* __s, size_t __refs = 0);
    1488             : 
    1489             :     protected:
    1490             :       virtual
    1491             :       ~ctype_byname();
    1492             :     };
    1493             : 
    1494             : #ifdef _GLIBCXX_USE_WCHAR_T
    1495             :   template<>
    1496             :     class ctype_byname<wchar_t> : public ctype<wchar_t>
    1497             :     {
    1498             :     public:
    1499             :       explicit
    1500             :       ctype_byname(const char* __s, size_t __refs = 0);
    1501             : 
    1502             :     protected:
    1503             :       virtual
    1504             :       ~ctype_byname();
    1505             :     };
    1506             : #endif
    1507             : 
    1508             : _GLIBCXX_END_NAMESPACE_VERSION
    1509             : } // namespace
    1510             : 
    1511             : // Include host and configuration specific ctype inlines.
    1512             : #include <bits/ctype_inline.h>
    1513             : 
    1514             : namespace std _GLIBCXX_VISIBILITY(default)
    1515             : {
    1516             : _GLIBCXX_BEGIN_NAMESPACE_VERSION
    1517             : 
    1518             :   // 22.2.2  The numeric category.
    1519             :   class __num_base
    1520             :   {
    1521             :   public:
    1522             :     // NB: Code depends on the order of _S_atoms_out elements.
    1523             :     // Below are the indices into _S_atoms_out.
    1524             :     enum
    1525             :       {
    1526             :         _S_ominus,
    1527             :         _S_oplus,
    1528             :         _S_ox,
    1529             :         _S_oX,
    1530             :         _S_odigits,
    1531             :         _S_odigits_end = _S_odigits + 16,
    1532             :         _S_oudigits = _S_odigits_end,
    1533             :         _S_oudigits_end = _S_oudigits + 16,
    1534             :         _S_oe = _S_odigits + 14,  // For scientific notation, 'e'
    1535             :         _S_oE = _S_oudigits + 14, // For scientific notation, 'E'
    1536             :         _S_oend = _S_oudigits_end
    1537             :       };
    1538             : 
    1539             :     // A list of valid numeric literals for output.  This array
    1540             :     // contains chars that will be passed through the current locale's
    1541             :     // ctype<_CharT>.widen() and then used to render numbers.
    1542             :     // For the standard "C" locale, this is
    1543             :     // "-+xX0123456789abcdef0123456789ABCDEF".
    1544             :     static const char* _S_atoms_out;
    1545             : 
    1546             :     // String literal of acceptable (narrow) input, for num_get.
    1547             :     // "-+xX0123456789abcdefABCDEF"
    1548             :     static const char* _S_atoms_in;
    1549             : 
    1550             :     enum
    1551             :     {
    1552             :       _S_iminus,
    1553             :       _S_iplus,
    1554             :       _S_ix,
    1555             :       _S_iX,
    1556             :       _S_izero,
    1557             :       _S_ie = _S_izero + 14,
    1558             :       _S_iE = _S_izero + 20,
    1559             :       _S_iend = 26
    1560             :     };
    1561             : 
    1562             :     // num_put
    1563             :     // Construct and return valid scanf format for floating point types.
    1564             :     static void
    1565             :     _S_format_float(const ios_base& __io, char* __fptr, char __mod) throw();
    1566             :   };
    1567             : 
    1568             :   template<typename _CharT>
    1569             :     struct __numpunct_cache : public locale::facet
    1570             :     {
    1571             :       const char*                       _M_grouping;
    1572             :       size_t                            _M_grouping_size;
    1573             :       bool                              _M_use_grouping;
    1574             :       const _CharT*                     _M_truename;
    1575             :       size_t                            _M_truename_size;
    1576             :       const _CharT*                     _M_falsename;
    1577             :       size_t                            _M_falsename_size;
    1578             :       _CharT                            _M_decimal_point;
    1579             :       _CharT                            _M_thousands_sep;
    1580             : 
    1581             :       // A list of valid numeric literals for output: in the standard
    1582             :       // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
    1583             :       // This array contains the chars after having been passed
    1584             :       // through the current locale's ctype<_CharT>.widen().
    1585             :       _CharT                            _M_atoms_out[__num_base::_S_oend];
    1586             : 
    1587             :       // A list of valid numeric literals for input: in the standard
    1588             :       // "C" locale, this is "-+xX0123456789abcdefABCDEF"
    1589             :       // This array contains the chars after having been passed
    1590             :       // through the current locale's ctype<_CharT>.widen().
    1591             :       _CharT                            _M_atoms_in[__num_base::_S_iend];
    1592             : 
    1593             :       bool                              _M_allocated;
    1594             : 
    1595             :       __numpunct_cache(size_t __refs = 0)
    1596             :       : facet(__refs), _M_grouping(0), _M_grouping_size(0),
    1597             :         _M_use_grouping(false),
    1598             :         _M_truename(0), _M_truename_size(0), _M_falsename(0),
    1599             :         _M_falsename_size(0), _M_decimal_point(_CharT()),
    1600             :         _M_thousands_sep(_CharT()), _M_allocated(false)
    1601             :         { }
    1602             : 
    1603             :       ~__numpunct_cache();
    1604             : 
    1605             :       void
    1606             :       _M_cache(const locale& __loc);
    1607             : 
    1608             :     private:
    1609             :       __numpunct_cache&
    1610             :       operator=(const __numpunct_cache&);
    1611             :       
    1612             :       explicit
    1613             :       __numpunct_cache(const __numpunct_cache&);
    1614             :     };
    1615             : 
    1616             :   template<typename _CharT>
    1617             :     __numpunct_cache<_CharT>::~__numpunct_cache()
    1618             :     {
    1619             :       if (_M_allocated)
    1620             :         {
    1621             :           delete [] _M_grouping;
    1622             :           delete [] _M_truename;
    1623             :           delete [] _M_falsename;
    1624             :         }
    1625             :     }
    1626             : 
    1627             :   /**
    1628             :    *  @brief  Primary class template numpunct.
    1629             :    *  @ingroup locales
    1630             :    *
    1631             :    *  This facet stores several pieces of information related to printing and
    1632             :    *  scanning numbers, such as the decimal point character.  It takes a
    1633             :    *  template parameter specifying the char type.  The numpunct facet is
    1634             :    *  used by streams for many I/O operations involving numbers.
    1635             :    *
    1636             :    *  The numpunct template uses protected virtual functions to provide the
    1637             :    *  actual results.  The public accessors forward the call to the virtual
    1638             :    *  functions.  These virtual functions are hooks for developers to
    1639             :    *  implement the behavior they require from a numpunct facet.
    1640             :   */
    1641             :   template<typename _CharT>
    1642             :     class numpunct : public locale::facet
    1643             :     {
    1644             :     public:
    1645             :       // Types:
    1646             :       //@{
    1647             :       /// Public typedefs
    1648             :       typedef _CharT                    char_type;
    1649             :       typedef basic_string<_CharT>        string_type;
    1650             :       //@}
    1651             :       typedef __numpunct_cache<_CharT>  __cache_type;
    1652             : 
    1653             :     protected:
    1654             :       __cache_type*                     _M_data;
    1655             : 
    1656             :     public:
    1657             :       /// Numpunct facet id.
    1658             :       static locale::id                 id;
    1659             : 
    1660             :       /**
    1661             :        *  @brief  Numpunct constructor.
    1662             :        *
    1663             :        *  @param  refs  Refcount to pass to the base class.
    1664             :        */
    1665             :       explicit
    1666             :       numpunct(size_t __refs = 0)
    1667             :       : facet(__refs), _M_data(0)
    1668             :       { _M_initialize_numpunct(); }
    1669             : 
    1670             :       /**
    1671             :        *  @brief  Internal constructor.  Not for general use.
    1672             :        *
    1673             :        *  This is a constructor for use by the library itself to set up the
    1674             :        *  predefined locale facets.
    1675             :        *
    1676             :        *  @param  cache  __numpunct_cache object.
    1677             :        *  @param  refs  Refcount to pass to the base class.
    1678             :        */
    1679             :       explicit
    1680             :       numpunct(__cache_type* __cache, size_t __refs = 0)
    1681             :       : facet(__refs), _M_data(__cache)
    1682             :       { _M_initialize_numpunct(); }
    1683             : 
    1684             :       /**
    1685             :        *  @brief  Internal constructor.  Not for general use.
    1686             :        *
    1687             :        *  This is a constructor for use by the library itself to set up new
    1688             :        *  locales.
    1689             :        *
    1690             :        *  @param  cloc  The C locale.
    1691             :        *  @param  refs  Refcount to pass to the base class.
    1692             :        */
    1693             :       explicit
    1694             :       numpunct(__c_locale __cloc, size_t __refs = 0)
    1695             :       : facet(__refs), _M_data(0)
    1696             :       { _M_initialize_numpunct(__cloc); }
    1697             : 
    1698             :       /**
    1699             :        *  @brief  Return decimal point character.
    1700             :        *
    1701             :        *  This function returns a char_type to use as a decimal point.  It
    1702             :        *  does so by returning returning
    1703             :        *  numpunct<char_type>::do_decimal_point().
    1704             :        *
    1705             :        *  @return  @a char_type representing a decimal point.
    1706             :       */
    1707             :       char_type
    1708             :       decimal_point() const
    1709             :       { return this->do_decimal_point(); }
    1710             : 
    1711             :       /**
    1712             :        *  @brief  Return thousands separator character.
    1713             :        *
    1714             :        *  This function returns a char_type to use as a thousands
    1715             :        *  separator.  It does so by returning returning
    1716             :        *  numpunct<char_type>::do_thousands_sep().
    1717             :        *
    1718             :        *  @return  char_type representing a thousands separator.
    1719             :       */
    1720             :       char_type
    1721             :       thousands_sep() const
    1722             :       { return this->do_thousands_sep(); }
    1723             : 
    1724             :       /**
    1725             :        *  @brief  Return grouping specification.
    1726             :        *
    1727             :        *  This function returns a string representing groupings for the
    1728             :        *  integer part of a number.  Groupings indicate where thousands
    1729             :        *  separators should be inserted in the integer part of a number.
    1730             :        *
    1731             :        *  Each char in the return string is interpret as an integer
    1732             :        *  rather than a character.  These numbers represent the number
    1733             :        *  of digits in a group.  The first char in the string
    1734             :        *  represents the number of digits in the least significant
    1735             :        *  group.  If a char is negative, it indicates an unlimited
    1736             :        *  number of digits for the group.  If more chars from the
    1737             :        *  string are required to group a number, the last char is used
    1738             :        *  repeatedly.
    1739             :        *
    1740             :        *  For example, if the grouping() returns "\003\002" and is
    1741             :        *  applied to the number 123456789, this corresponds to
    1742             :        *  12,34,56,789.  Note that if the string was "32", this would
    1743             :        *  put more than 50 digits into the least significant group if
    1744             :        *  the character set is ASCII.
    1745             :        *
    1746             :        *  The string is returned by calling
    1747             :        *  numpunct<char_type>::do_grouping().
    1748             :        *
    1749             :        *  @return  string representing grouping specification.
    1750             :       */
    1751             :       string
    1752             :       grouping() const
    1753             :       { return this->do_grouping(); }
    1754             : 
    1755             :       /**
    1756             :        *  @brief  Return string representation of bool true.
    1757             :        *
    1758             :        *  This function returns a string_type containing the text
    1759             :        *  representation for true bool variables.  It does so by calling
    1760             :        *  numpunct<char_type>::do_truename().
    1761             :        *
    1762             :        *  @return  string_type representing printed form of true.
    1763             :       */
    1764             :       string_type
    1765             :       truename() const
    1766             :       { return this->do_truename(); }
    1767             : 
    1768             :       /**
    1769             :        *  @brief  Return string representation of bool false.
    1770             :        *
    1771             :        *  This function returns a string_type containing the text
    1772             :        *  representation for false bool variables.  It does so by calling
    1773             :        *  numpunct<char_type>::do_falsename().
    1774             :        *
    1775             :        *  @return  string_type representing printed form of false.
    1776             :       */
    1777             :       string_type
    1778             :       falsename() const
    1779             :       { return this->do_falsename(); }
    1780             : 
    1781             :     protected:
    1782             :       /// Destructor.
    1783             :       virtual
    1784             :       ~numpunct();
    1785             : 
    1786             :       /**
    1787             :        *  @brief  Return decimal point character.
    1788             :        *
    1789             :        *  Returns a char_type to use as a decimal point.  This function is a
    1790             :        *  hook for derived classes to change the value returned.
    1791             :        *
    1792             :        *  @return  @a char_type representing a decimal point.
    1793             :       */
    1794             :       virtual char_type
    1795             :       do_decimal_point() const
    1796             :       { return _M_data->_M_decimal_point; }
    1797             : 
    1798             :       /**
    1799             :        *  @brief  Return thousands separator character.
    1800             :        *
    1801             :        *  Returns a char_type to use as a thousands separator.  This function
    1802             :        *  is a hook for derived classes to change the value returned.
    1803             :        *
    1804             :        *  @return  @a char_type representing a thousands separator.
    1805             :       */
    1806             :       virtual char_type
    1807             :       do_thousands_sep() const
    1808             :       { return _M_data->_M_thousands_sep; }
    1809             : 
    1810             :       /**
    1811             :        *  @brief  Return grouping specification.
    1812             :        *
    1813             :        *  Returns a string representing groupings for the integer part of a
    1814             :        *  number.  This function is a hook for derived classes to change the
    1815             :        *  value returned.  @see grouping() for details.
    1816             :        *
    1817             :        *  @return  String representing grouping specification.
    1818             :       */
    1819             :       virtual string
    1820             :       do_grouping() const
    1821             :       { return _M_data->_M_grouping; }
    1822             : 
    1823             :       /**
    1824             :        *  @brief  Return string representation of bool true.
    1825             :        *
    1826             :        *  Returns a string_type containing the text representation for true
    1827             :        *  bool variables.  This function is a hook for derived classes to
    1828             :        *  change the value returned.
    1829             :        *
    1830             :        *  @return  string_type representing printed form of true.
    1831             :       */
    1832             :       virtual string_type
    1833             :       do_truename() const
    1834             :       { return _M_data->_M_truename; }
    1835             : 
    1836             :       /**
    1837             :        *  @brief  Return string representation of bool false.
    1838             :        *
    1839             :        *  Returns a string_type containing the text representation for false
    1840             :        *  bool variables.  This function is a hook for derived classes to
    1841             :        *  change the value returned.
    1842             :        *
    1843             :        *  @return  string_type representing printed form of false.
    1844             :       */
    1845             :       virtual string_type
    1846             :       do_falsename() const
    1847             :       { return _M_data->_M_falsename; }
    1848             : 
    1849             :       // For use at construction time only.
    1850             :       void
    1851             :       _M_initialize_numpunct(__c_locale __cloc = 0);
    1852             :     };
    1853             : 
    1854             :   template<typename _CharT>
    1855             :     locale::id numpunct<_CharT>::id;
    1856             : 
    1857             :   template<>
    1858             :     numpunct<char>::~numpunct();
    1859             : 
    1860             :   template<>
    1861             :     void
    1862             :     numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
    1863             : 
    1864             : #ifdef _GLIBCXX_USE_WCHAR_T
    1865             :   template<>
    1866             :     numpunct<wchar_t>::~numpunct();
    1867             : 
    1868             :   template<>
    1869             :     void
    1870             :     numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
    1871             : #endif
    1872             : 
    1873             :   /// class numpunct_byname [22.2.3.2].
    1874             :   template<typename _CharT>
    1875             :     class numpunct_byname : public numpunct<_CharT>
    1876             :     {
    1877             :     public:
    1878             :       typedef _CharT                    char_type;
    1879             :       typedef basic_string<_CharT>        string_type;
    1880             : 
    1881             :       explicit
    1882             :       numpunct_byname(const char* __s, size_t __refs = 0)
    1883             :       : numpunct<_CharT>(__refs)
    1884             :       {
    1885             :         if (__builtin_strcmp(__s, "C") != 0
    1886             :             && __builtin_strcmp(__s, "POSIX") != 0)
    1887             :           {
    1888             :             __c_locale __tmp;
    1889             :             this->_S_create_c_locale(__tmp, __s);
    1890             :             this->_M_initialize_numpunct(__tmp);
    1891             :             this->_S_destroy_c_locale(__tmp);
    1892             :           }
    1893             :       }
    1894             : 
    1895             :     protected:
    1896             :       virtual
    1897             :       ~numpunct_byname() { }
    1898             :     };
    1899             : 
    1900             : _GLIBCXX_BEGIN_NAMESPACE_LDBL
    1901             : 
    1902             :   /**
    1903             :    *  @brief  Primary class template num_get.
    1904             :    *  @ingroup locales
    1905             :    *
    1906             :    *  This facet encapsulates the code to parse and return a number
    1907             :    *  from a string.  It is used by the istream numeric extraction
    1908             :    *  operators.
    1909             :    *
    1910             :    *  The num_get template uses protected virtual functions to provide the
    1911             :    *  actual results.  The public accessors forward the call to the virtual
    1912             :    *  functions.  These virtual functions are hooks for developers to
    1913             :    *  implement the behavior they require from the num_get facet.
    1914             :   */
    1915             :   template<typename _CharT, typename _InIter>
    1916             :     class num_get : public locale::facet
    1917             :     {
    1918             :     public:
    1919             :       // Types:
    1920             :       //@{
    1921             :       /// Public typedefs
    1922             :       typedef _CharT                    char_type;
    1923             :       typedef _InIter                   iter_type;
    1924             :       //@}
    1925             : 
    1926             :       /// Numpunct facet id.
    1927             :       static locale::id                 id;
    1928             : 
    1929             :       /**
    1930             :        *  @brief  Constructor performs initialization.
    1931             :        *
    1932             :        *  This is the constructor provided by the standard.
    1933             :        *
    1934             :        *  @param refs  Passed to the base facet class.
    1935             :       */
    1936             :       explicit
    1937             :       num_get(size_t __refs = 0) : facet(__refs) { }
    1938             : 
    1939             :       /**
    1940             :        *  @brief  Numeric parsing.
    1941             :        *
    1942             :        *  Parses the input stream into the bool @a v.  It does so by calling
    1943             :        *  num_get::do_get().
    1944             :        *
    1945             :        *  If ios_base::boolalpha is set, attempts to read
    1946             :        *  ctype<CharT>::truename() or ctype<CharT>::falsename().  Sets
    1947             :        *  @a v to true or false if successful.  Sets err to
    1948             :        *  ios_base::failbit if reading the string fails.  Sets err to
    1949             :        *  ios_base::eofbit if the stream is emptied.
    1950             :        *
    1951             :        *  If ios_base::boolalpha is not set, proceeds as with reading a long,
    1952             :        *  except if the value is 1, sets @a v to true, if the value is 0, sets
    1953             :        *  @a v to false, and otherwise set err to ios_base::failbit.
    1954             :        *
    1955             :        *  @param  in  Start of input stream.
    1956             :        *  @param  end  End of input stream.
    1957             :        *  @param  io  Source of locale and flags.
    1958             :        *  @param  err  Error flags to set.
    1959             :        *  @param  v  Value to format and insert.
    1960             :        *  @return  Iterator after reading.
    1961             :       */
    1962             :       iter_type
    1963             :       get(iter_type __in, iter_type __end, ios_base& __io,
    1964             :           ios_base::iostate& __err, bool& __v) const
    1965             :       { return this->do_get(__in, __end, __io, __err, __v); }
    1966             : 
    1967             :       //@{
    1968             :       /**
    1969             :        *  @brief  Numeric parsing.
    1970             :        *
    1971             :        *  Parses the input stream into the integral variable @a v.  It does so
    1972             :        *  by calling num_get::do_get().
    1973             :        *
    1974             :        *  Parsing is affected by the flag settings in @a io.
    1975             :        *
    1976             :        *  The basic parse is affected by the value of io.flags() &
    1977             :        *  ios_base::basefield.  If equal to ios_base::oct, parses like the
    1978             :        *  scanf %o specifier.  Else if equal to ios_base::hex, parses like %X
    1979             :        *  specifier.  Else if basefield equal to 0, parses like the %i
    1980             :        *  specifier.  Otherwise, parses like %d for signed and %u for unsigned
    1981             :        *  types.  The matching type length modifier is also used.
    1982             :        *
    1983             :        *  Digit grouping is interpreted according to numpunct::grouping() and
    1984             :        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
    1985             :        *  consistent, sets err to ios_base::failbit.
    1986             :        *
    1987             :        *  If parsing the string yields a valid value for @a v, @a v is set.
    1988             :        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
    1989             :        *  Sets err to ios_base::eofbit if the stream is emptied.
    1990             :        *
    1991             :        *  @param  in  Start of input stream.
    1992             :        *  @param  end  End of input stream.
    1993             :        *  @param  io  Source of locale and flags.
    1994             :        *  @param  err  Error flags to set.
    1995             :        *  @param  v  Value to format and insert.
    1996             :        *  @return  Iterator after reading.
    1997             :       */
    1998             :       iter_type
    1999             :       get(iter_type __in, iter_type __end, ios_base& __io,
    2000             :           ios_base::iostate& __err, long& __v) const
    2001             :       { return this->do_get(__in, __end, __io, __err, __v); }
    2002             : 
    2003             :       iter_type
    2004             :       get(iter_type __in, iter_type __end, ios_base& __io,
    2005             :           ios_base::iostate& __err, unsigned short& __v) const
    2006             :       { return this->do_get(__in, __end, __io, __err, __v); }
    2007             : 
    2008             :       iter_type
    2009             :       get(iter_type __in, iter_type __end, ios_base& __io,
    2010             :           ios_base::iostate& __err, unsigned int& __v)   const
    2011             :       { return this->do_get(__in, __end, __io, __err, __v); }
    2012             : 
    2013             :       iter_type
    2014             :       get(iter_type __in, iter_type __end, ios_base& __io,
    2015             :           ios_base::iostate& __err, unsigned long& __v)  const
    2016             :       { return this->do_get(__in, __end, __io, __err, __v); }
    2017             : 
    2018             : #ifdef _GLIBCXX_USE_LONG_LONG
    2019             :       iter_type
    2020             :       get(iter_type __in, iter_type __end, ios_base& __io,
    2021             :           ios_base::iostate& __err, long long& __v) const
    2022             :       { return this->do_get(__in, __end, __io, __err, __v); }
    2023             : 
    2024             :       iter_type
    2025             :       get(iter_type __in, iter_type __end, ios_base& __io,
    2026             :           ios_base::iostate& __err, unsigned long long& __v)  const
    2027             :       { return this->do_get(__in, __end, __io, __err, __v); }
    2028             : #endif
    2029             :       //@}
    2030             : 
    2031             :       //@{
    2032             :       /**
    2033             :        *  @brief  Numeric parsing.
    2034             :        *
    2035             :        *  Parses the input stream into the integral variable @a v.  It does so
    2036             :        *  by calling num_get::do_get().
    2037             :        *
    2038             :        *  The input characters are parsed like the scanf %g specifier.  The
    2039             :        *  matching type length modifier is also used.
    2040             :        *
    2041             :        *  The decimal point character used is numpunct::decimal_point().
    2042             :        *  Digit grouping is interpreted according to numpunct::grouping() and
    2043             :        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
    2044             :        *  consistent, sets err to ios_base::failbit.
    2045             :        *
    2046             :        *  If parsing the string yields a valid value for @a v, @a v is set.
    2047             :        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
    2048             :        *  Sets err to ios_base::eofbit if the stream is emptied.
    2049             :        *
    2050             :        *  @param  in  Start of input stream.
    2051             :        *  @param  end  End of input stream.
    2052             :        *  @param  io  Source of locale and flags.
    2053             :        *  @param  err  Error flags to set.
    2054             :        *  @param  v  Value to format and insert.
    2055             :        *  @return  Iterator after reading.
    2056             :       */
    2057             :       iter_type
    2058             :       get(iter_type __in, iter_type __end, ios_base& __io,
    2059             :           ios_base::iostate& __err, float& __v) const
    2060             :       { return this->do_get(__in, __end, __io, __err, __v); }
    2061             : 
    2062             :       iter_type
    2063             :       get(iter_type __in, iter_type __end, ios_base& __io,
    2064             :           ios_base::iostate& __err, double& __v) const
    2065             :       { return this->do_get(__in, __end, __io, __err, __v); }
    2066             : 
    2067             :       iter_type
    2068             :       get(iter_type __in, iter_type __end, ios_base& __io,
    2069             :           ios_base::iostate& __err, long double& __v) const
    2070             :       { return this->do_get(__in, __end, __io, __err, __v); }
    2071             :       //@}
    2072             : 
    2073             :       /**
    2074             :        *  @brief  Numeric parsing.
    2075             :        *
    2076             :        *  Parses the input stream into the pointer variable @a v.  It does so
    2077             :        *  by calling num_get::do_get().
    2078             :        *
    2079             :        *  The input characters are parsed like the scanf %p specifier.
    2080             :        *
    2081             :        *  Digit grouping is interpreted according to numpunct::grouping() and
    2082             :        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
    2083             :        *  consistent, sets err to ios_base::failbit.
    2084             :        *
    2085             :        *  Note that the digit grouping effect for pointers is a bit ambiguous
    2086             :        *  in the standard and shouldn't be relied on.  See DR 344.
    2087             :        *
    2088             :        *  If parsing the string yields a valid value for @a v, @a v is set.
    2089             :        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
    2090             :        *  Sets err to ios_base::eofbit if the stream is emptied.
    2091             :        *
    2092             :        *  @param  in  Start of input stream.
    2093             :        *  @param  end  End of input stream.
    2094             :        *  @param  io  Source of locale and flags.
    2095             :        *  @param  err  Error flags to set.
    2096             :        *  @param  v  Value to format and insert.
    2097             :        *  @return  Iterator after reading.
    2098             :       */
    2099             :       iter_type
    2100             :       get(iter_type __in, iter_type __end, ios_base& __io,
    2101             :           ios_base::iostate& __err, void*& __v) const
    2102             :       { return this->do_get(__in, __end, __io, __err, __v); }
    2103             : 
    2104             :     protected:
    2105             :       /// Destructor.
    2106             :       virtual ~num_get() { }
    2107             : 
    2108             :       iter_type
    2109             :       _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
    2110             :                        string&) const;
    2111             : 
    2112             :       template<typename _ValueT>
    2113             :         iter_type
    2114             :         _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
    2115             :                        _ValueT&) const;
    2116             : 
    2117             :       template<typename _CharT2>
    2118             :       typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, int>::__type
    2119             :         _M_find(const _CharT2*, size_t __len, _CharT2 __c) const
    2120             :         {
    2121             :           int __ret = -1;
    2122             :           if (__len <= 10)
    2123             :             {
    2124             :               if (__c >= _CharT2('0') && __c < _CharT2(_CharT2('0') + __len))
    2125             :                 __ret = __c - _CharT2('0');
    2126             :             }
    2127             :           else
    2128             :             {
    2129             :               if (__c >= _CharT2('0') && __c <= _CharT2('9'))
    2130             :                 __ret = __c - _CharT2('0');
    2131             :               else if (__c >= _CharT2('a') && __c <= _CharT2('f'))
    2132             :                 __ret = 10 + (__c - _CharT2('a'));
    2133             :               else if (__c >= _CharT2('A') && __c <= _CharT2('F'))
    2134             :                 __ret = 10 + (__c - _CharT2('A'));
    2135             :             }
    2136             :           return __ret;
    2137             :         }
    2138             : 
    2139             :       template<typename _CharT2>
    2140             :       typename __gnu_cxx::__enable_if<!__is_char<_CharT2>::__value, 
    2141             :                                       int>::__type
    2142             :         _M_find(const _CharT2* __zero, size_t __len, _CharT2 __c) const
    2143             :         {
    2144             :           int __ret = -1;
    2145             :           const char_type* __q = char_traits<_CharT2>::find(__zero, __len, __c);
    2146             :           if (__q)
    2147             :             {
    2148             :               __ret = __q - __zero;
    2149             :               if (__ret > 15)
    2150             :                 __ret -= 6;
    2151             :             }
    2152             :           return __ret;
    2153             :         }
    2154             : 
    2155             :       //@{
    2156             :       /**
    2157             :        *  @brief  Numeric parsing.
    2158             :        *
    2159             :        *  Parses the input stream into the variable @a v.  This function is a
    2160             :        *  hook for derived classes to change the value returned.  @see get()
    2161             :        *  for more details.
    2162             :        *
    2163             :        *  @param  in  Start of input stream.
    2164             :        *  @param  end  End of input stream.
    2165             :        *  @param  io  Source of locale and flags.
    2166             :        *  @param  err  Error flags to set.
    2167             :        *  @param  v  Value to format and insert.
    2168             :        *  @return  Iterator after reading.
    2169             :       */
    2170             :       virtual iter_type
    2171             :       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
    2172             : 
    2173             :       virtual iter_type
    2174             :       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    2175             :              ios_base::iostate& __err, long& __v) const
    2176             :       { return _M_extract_int(__beg, __end, __io, __err, __v); }
    2177             : 
    2178             :       virtual iter_type
    2179             :       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    2180             :              ios_base::iostate& __err, unsigned short& __v) const
    2181             :       { return _M_extract_int(__beg, __end, __io, __err, __v); }
    2182             : 
    2183             :       virtual iter_type
    2184             :       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    2185             :              ios_base::iostate& __err, unsigned int& __v) const
    2186             :       { return _M_extract_int(__beg, __end, __io, __err, __v); }
    2187             : 
    2188             :       virtual iter_type
    2189             :       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    2190             :              ios_base::iostate& __err, unsigned long& __v) const
    2191             :       { return _M_extract_int(__beg, __end, __io, __err, __v); }
    2192             : 
    2193             : #ifdef _GLIBCXX_USE_LONG_LONG
    2194             :       virtual iter_type
    2195             :       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    2196             :              ios_base::iostate& __err, long long& __v) const
    2197             :       { return _M_extract_int(__beg, __end, __io, __err, __v); }        
    2198             : 
    2199             :       virtual iter_type
    2200             :       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    2201             :              ios_base::iostate& __err, unsigned long long& __v) const
    2202             :       { return _M_extract_int(__beg, __end, __io, __err, __v); }
    2203             : #endif
    2204             : 
    2205             :       virtual iter_type
    2206             :       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    2207             :              float&) const;
    2208             : 
    2209             :       virtual iter_type
    2210             :       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    2211             :              double&) const;
    2212             : 
    2213             :       // XXX GLIBCXX_ABI Deprecated
    2214             : #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    2215             :       virtual iter_type
    2216             :       __do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    2217             :                double&) const;
    2218             : #else
    2219             :       virtual iter_type
    2220             :       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    2221             :              long double&) const;
    2222             : #endif
    2223             : 
    2224             :       virtual iter_type
    2225             :       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    2226             :              void*&) const;
    2227             : 
    2228             :       // XXX GLIBCXX_ABI Deprecated
    2229             : #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    2230             :       virtual iter_type
    2231             :       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    2232             :              long double&) const;
    2233             : #endif
    2234             :       //@}
    2235             :     };
    2236             : 
    2237             :   template<typename _CharT, typename _InIter>
    2238             :     locale::id num_get<_CharT, _InIter>::id;
    2239             : 
    2240             : 
    2241             :   /**
    2242             :    *  @brief  Primary class template num_put.
    2243             :    *  @ingroup locales
    2244             :    *
    2245             :    *  This facet encapsulates the code to convert a number to a string.  It is
    2246             :    *  used by the ostream numeric insertion operators.
    2247             :    *
    2248             :    *  The num_put template uses protected virtual functions to provide the
    2249             :    *  actual results.  The public accessors forward the call to the virtual
    2250             :    *  functions.  These virtual functions are hooks for developers to
    2251             :    *  implement the behavior they require from the num_put facet.
    2252             :   */
    2253             :   template<typename _CharT, typename _OutIter>
    2254             :     class num_put : public locale::facet
    2255             :     {
    2256             :     public:
    2257             :       // Types:
    2258             :       //@{
    2259             :       /// Public typedefs
    2260             :       typedef _CharT            char_type;
    2261             :       typedef _OutIter          iter_type;
    2262             :       //@}
    2263             : 
    2264             :       /// Numpunct facet id.
    2265             :       static locale::id         id;
    2266             : 
    2267             :       /**
    2268             :        *  @brief  Constructor performs initialization.
    2269             :        *
    2270             :        *  This is the constructor provided by the standard.
    2271             :        *
    2272             :        *  @param refs  Passed to the base facet class.
    2273             :       */
    2274             :       explicit
    2275             :       num_put(size_t __refs = 0) : facet(__refs) { }
    2276             : 
    2277             :       /**
    2278             :        *  @brief  Numeric formatting.
    2279             :        *
    2280             :        *  Formats the boolean @a v and inserts it into a stream.  It does so
    2281             :        *  by calling num_put::do_put().
    2282             :        *
    2283             :        *  If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
    2284             :        *  ctype<CharT>::falsename().  Otherwise formats @a v as an int.
    2285             :        *
    2286             :        *  @param  s  Stream to write to.
    2287             :        *  @param  io  Source of locale and flags.
    2288             :        *  @param  fill  Char_type to use for filling.
    2289             :        *  @param  v  Value to format and insert.
    2290             :        *  @return  Iterator after writing.
    2291             :       */
    2292             :       iter_type
    2293             :       put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const
    2294             :       { return this->do_put(__s, __f, __fill, __v); }
    2295             : 
    2296             :       //@{
    2297             :       /**
    2298             :        *  @brief  Numeric formatting.
    2299             :        *
    2300             :        *  Formats the integral value @a v and inserts it into a
    2301             :        *  stream.  It does so by calling num_put::do_put().
    2302             :        *
    2303             :        *  Formatting is affected by the flag settings in @a io.
    2304             :        *
    2305             :        *  The basic format is affected by the value of io.flags() &
    2306             :        *  ios_base::basefield.  If equal to ios_base::oct, formats like the
    2307             :        *  printf %o specifier.  Else if equal to ios_base::hex, formats like
    2308             :        *  %x or %X with ios_base::uppercase unset or set respectively.
    2309             :        *  Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
    2310             :        *  for unsigned values.  Note that if both oct and hex are set, neither
    2311             :        *  will take effect.
    2312             :        *
    2313             :        *  If ios_base::showpos is set, '+' is output before positive values.
    2314             :        *  If ios_base::showbase is set, '0' precedes octal values (except 0)
    2315             :        *  and '0[xX]' precedes hex values.
    2316             :        *
    2317             :        *  Thousands separators are inserted according to numpunct::grouping()
    2318             :        *  and numpunct::thousands_sep().  The decimal point character used is
    2319             :        *  numpunct::decimal_point().
    2320             :        *
    2321             :        *  If io.width() is non-zero, enough @a fill characters are inserted to
    2322             :        *  make the result at least that wide.  If
    2323             :        *  (io.flags() & ios_base::adjustfield) == ios_base::left, result is
    2324             :        *  padded at the end.  If ios_base::internal, then padding occurs
    2325             :        *  immediately after either a '+' or '-' or after '0x' or '0X'.
    2326             :        *  Otherwise, padding occurs at the beginning.
    2327             :        *
    2328             :        *  @param  s  Stream to write to.
    2329             :        *  @param  io  Source of locale and flags.
    2330             :        *  @param  fill  Char_type to use for filling.
    2331             :        *  @param  v  Value to format and insert.
    2332             :        *  @return  Iterator after writing.
    2333             :       */
    2334             :       iter_type
    2335             :       put(iter_type __s, ios_base& __f, char_type __fill, long __v) const
    2336             :       { return this->do_put(__s, __f, __fill, __v); }
    2337             : 
    2338             :       iter_type
    2339             :       put(iter_type __s, ios_base& __f, char_type __fill,
    2340             :           unsigned long __v) const
    2341             :       { return this->do_put(__s, __f, __fill, __v); }
    2342             : 
    2343             : #ifdef _GLIBCXX_USE_LONG_LONG
    2344             :       iter_type
    2345             :       put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const
    2346             :       { return this->do_put(__s, __f, __fill, __v); }
    2347             : 
    2348             :       iter_type
    2349             :       put(iter_type __s, ios_base& __f, char_type __fill,
    2350             :           unsigned long long __v) const
    2351             :       { return this->do_put(__s, __f, __fill, __v); }
    2352             : #endif
    2353             :       //@}
    2354             : 
    2355             :       //@{
    2356             :       /**
    2357             :        *  @brief  Numeric formatting.
    2358             :        *
    2359             :        *  Formats the floating point value @a v and inserts it into a stream.
    2360             :        *  It does so by calling num_put::do_put().
    2361             :        *
    2362             :        *  Formatting is affected by the flag settings in @a io.
    2363             :        *
    2364             :        *  The basic format is affected by the value of io.flags() &
    2365             :        *  ios_base::floatfield.  If equal to ios_base::fixed, formats like the
    2366             :        *  printf %f specifier.  Else if equal to ios_base::scientific, formats
    2367             :        *  like %e or %E with ios_base::uppercase unset or set respectively.
    2368             :        *  Otherwise, formats like %g or %G depending on uppercase.  Note that
    2369             :        *  if both fixed and scientific are set, the effect will also be like
    2370             :        *  %g or %G.
    2371             :        *
    2372             :        *  The output precision is given by io.precision().  This precision is
    2373             :        *  capped at numeric_limits::digits10 + 2 (different for double and
    2374             :        *  long double).  The default precision is 6.
    2375             :        *
    2376             :        *  If ios_base::showpos is set, '+' is output before positive values.
    2377             :        *  If ios_base::showpoint is set, a decimal point will always be
    2378             :        *  output.
    2379             :        *
    2380             :        *  Thousands separators are inserted according to numpunct::grouping()
    2381             :        *  and numpunct::thousands_sep().  The decimal point character used is
    2382             :        *  numpunct::decimal_point().
    2383             :        *
    2384             :        *  If io.width() is non-zero, enough @a fill characters are inserted to
    2385             :        *  make the result at least that wide.  If
    2386             :        *  (io.flags() & ios_base::adjustfield) == ios_base::left, result is
    2387             :        *  padded at the end.  If ios_base::internal, then padding occurs
    2388             :        *  immediately after either a '+' or '-' or after '0x' or '0X'.
    2389             :        *  Otherwise, padding occurs at the beginning.
    2390             :        *
    2391             :        *  @param  s  Stream to write to.
    2392             :        *  @param  io  Source of locale and flags.
    2393             :        *  @param  fill  Char_type to use for filling.
    2394             :        *  @param  v  Value to format and insert.
    2395             :        *  @return  Iterator after writing.
    2396             :       */
    2397             :       iter_type
    2398             :       put(iter_type __s, ios_base& __f, char_type __fill, double __v) const
    2399             :       { return this->do_put(__s, __f, __fill, __v); }
    2400             : 
    2401             :       iter_type
    2402             :       put(iter_type __s, ios_base& __f, char_type __fill,
    2403             :           long double __v) const
    2404             :       { return this->do_put(__s, __f, __fill, __v); }
    2405             :       //@}
    2406             : 
    2407             :       /**
    2408             :        *  @brief  Numeric formatting.
    2409             :        *
    2410             :        *  Formats the pointer value @a v and inserts it into a stream.  It
    2411             :        *  does so by calling num_put::do_put().
    2412             :        *
    2413             :        *  This function formats @a v as an unsigned long with ios_base::hex
    2414             :        *  and ios_base::showbase set.
    2415             :        *
    2416             :        *  @param  s  Stream to write to.
    2417             :        *  @param  io  Source of locale and flags.
    2418             :        *  @param  fill  Char_type to use for filling.
    2419             :        *  @param  v  Value to format and insert.
    2420             :        *  @return  Iterator after writing.
    2421             :       */
    2422             :       iter_type
    2423             :       put(iter_type __s, ios_base& __f, char_type __fill,
    2424             :           const void* __v) const
    2425             :       { return this->do_put(__s, __f, __fill, __v); }
    2426             : 
    2427             :     protected:
    2428             :       template<typename _ValueT>
    2429             :         iter_type
    2430             :         _M_insert_float(iter_type, ios_base& __io, char_type __fill,
    2431             :                         char __mod, _ValueT __v) const;
    2432             : 
    2433             :       void
    2434             :       _M_group_float(const char* __grouping, size_t __grouping_size,
    2435             :                      char_type __sep, const char_type* __p, char_type* __new,
    2436             :                      char_type* __cs, int& __len) const;
    2437             : 
    2438             :       template<typename _ValueT>
    2439             :         iter_type
    2440             :         _M_insert_int(iter_type, ios_base& __io, char_type __fill,
    2441             :                       _ValueT __v) const;
    2442             : 
    2443             :       void
    2444             :       _M_group_int(const char* __grouping, size_t __grouping_size,
    2445             :                    char_type __sep, ios_base& __io, char_type* __new,
    2446             :                    char_type* __cs, int& __len) const;
    2447             : 
    2448             :       void
    2449             :       _M_pad(char_type __fill, streamsize __w, ios_base& __io,
    2450             :              char_type* __new, const char_type* __cs, int& __len) const;
    2451             : 
    2452             :       /// Destructor.
    2453             :       virtual
    2454             :       ~num_put() { };
    2455             : 
    2456             :       //@{
    2457             :       /**
    2458             :        *  @brief  Numeric formatting.
    2459             :        *
    2460             :        *  These functions do the work of formatting numeric values and
    2461             :        *  inserting them into a stream. This function is a hook for derived
    2462             :        *  classes to change the value returned.
    2463             :        *
    2464             :        *  @param  s  Stream to write to.
    2465             :        *  @param  io  Source of locale and flags.
    2466             :        *  @param  fill  Char_type to use for filling.
    2467             :        *  @param  v  Value to format and insert.
    2468             :        *  @return  Iterator after writing.
    2469             :       */
    2470             :       virtual iter_type
    2471             :       do_put(iter_type, ios_base&, char_type __fill, bool __v) const;
    2472             : 
    2473             :       virtual iter_type
    2474             :       do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
    2475             :       { return _M_insert_int(__s, __io, __fill, __v); } 
    2476             : 
    2477             :       virtual iter_type
    2478             :       do_put(iter_type __s, ios_base& __io, char_type __fill,
    2479             :              unsigned long __v) const
    2480             :       { return _M_insert_int(__s, __io, __fill, __v); }
    2481             : 
    2482             : #ifdef _GLIBCXX_USE_LONG_LONG
    2483             :       virtual iter_type
    2484             :       do_put(iter_type __s, ios_base& __io, char_type __fill,
    2485             :              long long __v) const
    2486             :       { return _M_insert_int(__s, __io, __fill, __v); }
    2487             : 
    2488             :       virtual iter_type
    2489             :       do_put(iter_type __s, ios_base& __io, char_type __fill,
    2490             :              unsigned long long __v) const
    2491             :       { return _M_insert_int(__s, __io, __fill, __v); }
    2492             : #endif
    2493             : 
    2494             :       virtual iter_type
    2495             :       do_put(iter_type, ios_base&, char_type __fill, double __v) const;
    2496             : 
    2497             :       // XXX GLIBCXX_ABI Deprecated
    2498             : #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    2499             :       virtual iter_type
    2500             :       __do_put(iter_type, ios_base&, char_type __fill, double __v) const;
    2501             : #else
    2502             :       virtual iter_type
    2503             :       do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
    2504             : #endif
    2505             : 
    2506             :       virtual iter_type
    2507             :       do_put(iter_type, ios_base&, char_type __fill, const void* __v) const;
    2508             : 
    2509             :       // XXX GLIBCXX_ABI Deprecated
    2510             : #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    2511             :       virtual iter_type
    2512             :       do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
    2513             : #endif
    2514             :       //@}
    2515             :     };
    2516             : 
    2517             :   template <typename _CharT, typename _OutIter>
    2518             :     locale::id num_put<_CharT, _OutIter>::id;
    2519             : 
    2520             : _GLIBCXX_END_NAMESPACE_LDBL
    2521             : 
    2522             :   // Subclause convenience interfaces, inlines.
    2523             :   // NB: These are inline because, when used in a loop, some compilers
    2524             :   // can hoist the body out of the loop; then it's just as fast as the
    2525             :   // C is*() function.
    2526             : 
    2527             :   /// Convenience interface to ctype.is(ctype_base::space, __c).
    2528             :   template<typename _CharT>
    2529             :     inline bool
    2530             :     isspace(_CharT __c, const locale& __loc)
    2531             :     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
    2532             : 
    2533             :   /// Convenience interface to ctype.is(ctype_base::print, __c).
    2534             :   template<typename _CharT>
    2535             :     inline bool
    2536             :     isprint(_CharT __c, const locale& __loc)
    2537             :     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
    2538             : 
    2539             :   /// Convenience interface to ctype.is(ctype_base::cntrl, __c).
    2540             :   template<typename _CharT>
    2541             :     inline bool
    2542             :     iscntrl(_CharT __c, const locale& __loc)
    2543             :     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
    2544             : 
    2545             :   /// Convenience interface to ctype.is(ctype_base::upper, __c).
    2546             :   template<typename _CharT>
    2547             :     inline bool
    2548             :     isupper(_CharT __c, const locale& __loc)
    2549             :     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
    2550             : 
    2551             :   /// Convenience interface to ctype.is(ctype_base::lower, __c).
    2552             :   template<typename _CharT>
    2553             :     inline bool 
    2554             :     islower(_CharT __c, const locale& __loc)
    2555             :     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
    2556             : 
    2557             :   /// Convenience interface to ctype.is(ctype_base::alpha, __c).
    2558             :   template<typename _CharT>
    2559             :     inline bool
    2560             :     isalpha(_CharT __c, const locale& __loc)
    2561             :     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
    2562             : 
    2563             :   /// Convenience interface to ctype.is(ctype_base::digit, __c).
    2564             :   template<typename _CharT>
    2565             :     inline bool
    2566             :     isdigit(_CharT __c, const locale& __loc)
    2567             :     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
    2568             : 
    2569             :   /// Convenience interface to ctype.is(ctype_base::punct, __c).
    2570             :   template<typename _CharT>
    2571             :     inline bool
    2572             :     ispunct(_CharT __c, const locale& __loc)
    2573             :     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
    2574             : 
    2575             :   /// Convenience interface to ctype.is(ctype_base::xdigit, __c).
    2576             :   template<typename _CharT>
    2577             :     inline bool
    2578             :     isxdigit(_CharT __c, const locale& __loc)
    2579             :     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
    2580             : 
    2581             :   /// Convenience interface to ctype.is(ctype_base::alnum, __c).
    2582             :   template<typename _CharT>
    2583             :     inline bool
    2584             :     isalnum(_CharT __c, const locale& __loc)
    2585             :     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
    2586             : 
    2587             :   /// Convenience interface to ctype.is(ctype_base::graph, __c).
    2588             :   template<typename _CharT>
    2589             :     inline bool
    2590             :     isgraph(_CharT __c, const locale& __loc)
    2591             :     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
    2592             : 
    2593             :   /// Convenience interface to ctype.toupper(__c).
    2594             :   template<typename _CharT>
    2595             :     inline _CharT
    2596             :     toupper(_CharT __c, const locale& __loc)
    2597             :     { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
    2598             : 
    2599             :   /// Convenience interface to ctype.tolower(__c).
    2600             :   template<typename _CharT>
    2601             :     inline _CharT
    2602             :     tolower(_CharT __c, const locale& __loc)
    2603             :     { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
    2604             : 
    2605             : _GLIBCXX_END_NAMESPACE_VERSION
    2606             : } // namespace
    2607             : 
    2608             : # include <bits/locale_facets.tcc>
    2609             : 
    2610             : #endif

Generated by: LCOV version 1.9

The wpkg tool is an open source tool created by Made to Order Software Corporation.