# locale_facets.h

Go to the documentation of this file.

    00001 // Locale support -*- C++ -*-
    00002
    00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    00004 // 2006, 2007, 2008, 2009
    00005 // Free Software Foundation, Inc.
    00006 //
    00007 // This file is part of the GNU ISO C++ Library.  This library is free
    00008 // software; you can redistribute it and/or modify it under the
    00009 // terms of the GNU General Public License as published by the
    00010 // Free Software Foundation; either version 3, or (at your option)
    00011 // any later version.
    00012
    00013 // This library is distributed in the hope that it will be useful,
    00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00016 // GNU General Public License for more details.
    00017
    00018 // Under Section 7 of GPL version 3, you are granted additional
    00019 // permissions described in the GCC Runtime Library Exception, version
    00020 // 3.1, as published by the Free Software Foundation.
    00021
    00022 // You should have received a copy of the GNU General Public License and
    00023 // a copy of the GCC Runtime Library Exception along with this program;
    00024 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    00025 // <http://www.gnu.org/licenses/>.
    00026
    00027 /** @file locale_facets.h
    00028  *  This is an internal header file, included by other library headers.
    00029  *  You should not attempt to use it directly.
    00030  */
    00031
    00032 //
    00033 // ISO C++ 14882: 22.1  Locales
    00034 //
    00035
    00036 #ifndef _LOCALE_FACETS_H
    00037 #define _LOCALE_FACETS_H 1
    00038
    00039 #pragma GCC system_header
    00040
    00041 #include <cwctype>  // For wctype_t
    00042 #include <cctype>
    00043 #include <bits/ctype_base.h>
    00044 #include <iosfwd>
    00045 #include <bits/ios_base.h>  // For ios_base, ios_base::iostate
    00046 #include <streambuf>
    00047 #include <bits/cpp_type_traits.h>
    00048 #include <ext/type_traits.h>
    00049 #include <ext/numeric_traits.h>
    00050 #include <bits/streambuf_iterator.h>
    00051
    00052 _GLIBCXX_BEGIN_NAMESPACE(std)
    00053
    00054   // NB: Don't instantiate required wchar_t facets if no wchar_t support.
    00055 #ifdef _GLIBCXX_USE_WCHAR_T
    00056 # define  _GLIBCXX_NUM_FACETS 28
    00057 #else
    00058 # define  _GLIBCXX_NUM_FACETS 14
    00059 #endif
    00060
    00061   // Convert string to numeric value of type _Tv and store results.
    00062   // NB: This is specialized for all required types, there is no
    00063   // generic definition.
    00064   template<typename _Tv>
    00065     void
    00066     __convert_to_v(const char* __in, _Tv& __out, ios_base::iostate& __err,
    00067            const __c_locale& __cloc);
    00068
    00069   // Explicit specializations for required types.
    00070   template<>
    00071     void
    00072     __convert_to_v(const char*, float&, ios_base::iostate&,
    00073            const __c_locale&);
    00074
    00075   template<>
    00076     void
    00077     __convert_to_v(const char*, double&, ios_base::iostate&,
    00078            const __c_locale&);
    00079
    00080   template<>
    00081     void
    00082     __convert_to_v(const char*, long double&, ios_base::iostate&,
    00083            const __c_locale&);
    00084
    00085   // NB: __pad is a struct, rather than a function, so it can be
    00086   // partially-specialized.
    00087   template<typename _CharT, typename _Traits>
    00088     struct __pad
    00089     {
    00090       static void
    00091       _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
    00092          const _CharT* __olds, streamsize __newlen, streamsize __oldlen);
    00093     };
    00094
    00095   // Used by both numeric and monetary facets.
    00096   // Inserts "group separator" characters into an array of characters.
    00097   // It's recursive, one iteration per group.  It moves the characters
    00098   // in the buffer this way: "xxxx12345" -> "12,345xxx".  Call this
    00099   // only with __gsize != 0.
    00100   template<typename _CharT>
    00101     _CharT*
    00102     __add_grouping(_CharT* __s, _CharT __sep,
    00103            const char* __gbeg, size_t __gsize,
    00104            const _CharT* __first, const _CharT* __last);
    00105
    00106   // This template permits specializing facet output code for
    00107   // ostreambuf_iterator.  For ostreambuf_iterator, sputn is
    00108   // significantly more efficient than incrementing iterators.
    00109   template<typename _CharT>
    00110     inline
    00111     ostreambuf_iterator<_CharT>
    00112     __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
    00113     {
    00114       __s._M_put(__ws, __len);
    00115       return __s;
    00116     }
    00117
    00118   // This is the unspecialized form of the template.
    00119   template<typename _CharT, typename _OutIter>
    00120     inline
    00121     _OutIter
    00122     __write(_OutIter __s, const _CharT* __ws, int __len)
    00123     {
    00124       for (int __j = 0; __j < __len; __j++, ++__s)
    00125     *__s = __ws[__j];
    00126       return __s;
    00127     }
    00128
    00129
    00130   // 22.2.1.1  Template class ctype
    00131   // Include host and configuration specific ctype enums for ctype_base.
    00132
    00133   // Common base for ctype<_CharT>.
    00134   /**
    00135    *  @brief  Common base for ctype facet
    00136    *
    00137    *  This template class provides implementations of the public functions
    00138    *  that forward to the protected virtual functions.
    00139    *
    00140    *  This template also provides abstract stubs for the protected virtual
    00141    *  functions.
    00142   */
    00143   template<typename _CharT>
    00144     class __ctype_abstract_base : public locale::facet, public ctype_base
    00145     {
    00146     public:
    00147       // Types:
    00148       /// Typedef for the template parameter
    00149       typedef _CharT char_type;
    00150
    00151       /**
    00152        *  @brief  Test char_type classification.
    00153        *
    00154        *  This function finds a mask M for @a c and compares it to mask @a m.
    00155        *  It does so by returning the value of ctype<char_type>::do_is().
    00156        *
    00157        *  @param c  The char_type to compare the mask of.
    00158        *  @param m  The mask to compare against.
    00159        *  @return  (M & m) != 0.
    00160       */
    00161       bool
    00162       is(mask __m, char_type __c) const
    00163       { return this->do_is(__m, __c); }
    00164
    00165       /**
    00166        *  @brief  Return a mask array.
    00167        *
    00168        *  This function finds the mask for each char_type in the range [lo,hi)
    00169        *  and successively writes it to vec.  vec must have as many elements
    00170        *  as the char array.  It does so by returning the value of
    00171        *  ctype<char_type>::do_is().
    00172        *
    00173        *  @param lo  Pointer to start of range.
    00174        *  @param hi  Pointer to end of range.
    00175        *  @param vec  Pointer to an array of mask storage.
    00176        *  @return  @a hi.
    00177       */
    00178       const char_type*
    00179       is(const char_type *__lo, const char_type *__hi, mask *__vec) const
    00180       { return this->do_is(__lo, __hi, __vec); }
    00181
    00182       /**
    00183        *  @brief  Find char_type matching a mask
    00184        *
    00185        *  This function searches for and returns the first char_type c in
    00186        *  [lo,hi) for which is(m,c) is true.  It does so by returning
    00187        *  ctype<char_type>::do_scan_is().
    00188        *
    00189        *  @param m  The mask to compare against.
    00190        *  @param lo  Pointer to start of range.
    00191        *  @param hi  Pointer to end of range.
    00192        *  @return  Pointer to matching char_type if found, else @a hi.
    00193       */
    00194       const char_type*
    00195       scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
    00196       { return this->do_scan_is(__m, __lo, __hi); }
    00197
    00198       /**
    00199        *  @brief  Find char_type not matching a mask
    00200        *
    00201        *  This function searches for and returns the first char_type c in
    00202        *  [lo,hi) for which is(m,c) is false.  It does so by returning
    00203        *  ctype<char_type>::do_scan_not().
    00204        *
    00205        *  @param m  The mask to compare against.
    00206        *  @param lo  Pointer to first char in range.
    00207        *  @param hi  Pointer to end of range.
    00208        *  @return  Pointer to non-matching char if found, else @a hi.
    00209       */
    00210       const char_type*
    00211       scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
    00212       { return this->do_scan_not(__m, __lo, __hi); }
    00213
    00214       /**
    00215        *  @brief  Convert to uppercase.
    00216        *
    00217        *  This function converts the argument to uppercase if possible.
    00218        *  If not possible (for example, '2'), returns the argument.  It does
    00219        *  so by returning ctype<char_type>::do_toupper().
    00220        *
    00221        *  @param c  The char_type to convert.
    00222        *  @return  The uppercase char_type if convertible, else @a c.
    00223       */
    00224       char_type
    00225       toupper(char_type __c) const
    00226       { return this->do_toupper(__c); }
    00227
    00228       /**
    00229        *  @brief  Convert array to uppercase.
    00230        *
    00231        *  This function converts each char_type in the range [lo,hi) to
    00232        *  uppercase if possible.  Other elements remain untouched.  It does so
    00233        *  by returning ctype<char_type>:: do_toupper(lo, hi).
    00234        *
    00235        *  @param lo  Pointer to start of range.
    00236        *  @param hi  Pointer to end of range.
    00237        *  @return  @a hi.
    00238       */
    00239       const char_type*
    00240       toupper(char_type *__lo, const char_type* __hi) const
    00241       { return this->do_toupper(__lo, __hi); }
    00242
    00243       /**
    00244        *  @brief  Convert to lowercase.
    00245        *
    00246        *  This function converts the argument to lowercase if possible.  If
    00247        *  not possible (for example, '2'), returns the argument.  It does so
    00248        *  by returning ctype<char_type>::do_tolower(c).
    00249        *
    00250        *  @param c  The char_type to convert.
    00251        *  @return  The lowercase char_type if convertible, else @a c.
    00252       */
    00253       char_type
    00254       tolower(char_type __c) const
    00255       { return this->do_tolower(__c); }
    00256
    00257       /**
    00258        *  @brief  Convert array to lowercase.
    00259        *
    00260        *  This function converts each char_type in the range [lo,hi) to
    00261        *  lowercase if possible.  Other elements remain untouched.  It does so
    00262        *  by returning ctype<char_type>:: do_tolower(lo, hi).
    00263        *
    00264        *  @param lo  Pointer to start of range.
    00265        *  @param hi  Pointer to end of range.
    00266        *  @return  @a hi.
    00267       */
    00268       const char_type*
    00269       tolower(char_type* __lo, const char_type* __hi) const
    00270       { return this->do_tolower(__lo, __hi); }
    00271
    00272       /**
    00273        *  @brief  Widen char to char_type
    00274        *
    00275        *  This function converts the char argument to char_type using the
    00276        *  simplest reasonable transformation.  It does so by returning
    00277        *  ctype<char_type>::do_widen(c).
    00278        *
    00279        *  Note: this is not what you want for codepage conversions.  See
    00280        *  codecvt for that.
    00281        *
    00282        *  @param c  The char to convert.
    00283        *  @return  The converted char_type.
    00284       */
    00285       char_type
    00286       widen(char __c) const
    00287       { return this->do_widen(__c); }
    00288
    00289       /**
    00290        *  @brief  Widen array to char_type
    00291        *
    00292        *  This function converts each char in the input to char_type using the
    00293        *  simplest reasonable transformation.  It does so by returning
    00294        *  ctype<char_type>::do_widen(c).
    00295        *
    00296        *  Note: this is not what you want for codepage conversions.  See
    00297        *  codecvt for that.
    00298        *
    00299        *  @param lo  Pointer to start of range.
    00300        *  @param hi  Pointer to end of range.
    00301        *  @param to  Pointer to the destination array.
    00302        *  @return  @a hi.
    00303       */
    00304       const char*
    00305       widen(const char* __lo, const char* __hi, char_type* __to) const
    00306       { return this->do_widen(__lo, __hi, __to); }
    00307
    00308       /**
    00309        *  @brief  Narrow char_type to char
    00310        *
    00311        *  This function converts the char_type to char using the simplest
    00312        *  reasonable transformation.  If the conversion fails, dfault is
    00313        *  returned instead.  It does so by returning
    00314        *  ctype<char_type>::do_narrow(c).
    00315        *
    00316        *  Note: this is not what you want for codepage conversions.  See
    00317        *  codecvt for that.
    00318        *
    00319        *  @param c  The char_type to convert.
    00320        *  @param dfault  Char to return if conversion fails.
    00321        *  @return  The converted char.
    00322       */
    00323       char
    00324       narrow(char_type __c, char __dfault) const
    00325       { return this->do_narrow(__c, __dfault); }
    00326
    00327       /**
    00328        *  @brief  Narrow array to char array
    00329        *
    00330        *  This function converts each char_type in the input to char using the
    00331        *  simplest reasonable transformation and writes the results to the
    00332        *  destination array.  For any char_type in the input that cannot be
    00333        *  converted, @a dfault is used instead.  It does so by returning
    00334        *  ctype<char_type>::do_narrow(lo, hi, dfault, to).
    00335        *
    00336        *  Note: this is not what you want for codepage conversions.  See
    00337        *  codecvt for that.
    00338        *
    00339        *  @param lo  Pointer to start of range.
    00340        *  @param hi  Pointer to end of range.
    00341        *  @param dfault  Char to use if conversion fails.
    00342        *  @param to  Pointer to the destination array.
    00343        *  @return  @a hi.
    00344       */
    00345       const char_type*
    00346       narrow(const char_type* __lo, const char_type* __hi,
    00347           char __dfault, char *__to) const
    00348       { return this->do_narrow(__lo, __hi, __dfault, __to); }
    00349
    00350     protected:
    00351       explicit
    00352       __ctype_abstract_base(size_t __refs = 0): facet(__refs) { }
    00353
    00354       virtual
    00355       ~__ctype_abstract_base() { }
    00356
    00357       /**
    00358        *  @brief  Test char_type classification.
    00359        *
    00360        *  This function finds a mask M for @a c and compares it to mask @a m.
    00361        *
    00362        *  do_is() is a hook for a derived facet to change the behavior of
    00363        *  classifying.  do_is() must always return the same result for the
    00364        *  same input.
    00365        *
    00366        *  @param c  The char_type to find the mask of.
    00367        *  @param m  The mask to compare against.
    00368        *  @return  (M & m) != 0.
    00369       */
    00370       virtual bool
    00371       do_is(mask __m, char_type __c) const = 0;
    00372
    00373       /**
    00374        *  @brief  Return a mask array.
    00375        *
    00376        *  This function finds the mask for each char_type in the range [lo,hi)
    00377        *  and successively writes it to vec.  vec must have as many elements
    00378        *  as the input.
    00379        *
    00380        *  do_is() is a hook for a derived facet to change the behavior of
    00381        *  classifying.  do_is() must always return the same result for the
    00382        *  same input.
    00383        *
    00384        *  @param lo  Pointer to start of range.
    00385        *  @param hi  Pointer to end of range.
    00386        *  @param vec  Pointer to an array of mask storage.
    00387        *  @return  @a hi.
    00388       */
    00389       virtual const char_type*
    00390       do_is(const char_type* __lo, const char_type* __hi,
    00391         mask* __vec) const = 0;
    00392
    00393       /**
    00394        *  @brief  Find char_type matching mask
    00395        *
    00396        *  This function searches for and returns the first char_type c in
    00397        *  [lo,hi) for which is(m,c) is true.
    00398        *
    00399        *  do_scan_is() is a hook for a derived facet to change the behavior of
    00400        *  match searching.  do_is() must always return the same result for the
    00401        *  same input.
    00402        *
    00403        *  @param m  The mask to compare against.
    00404        *  @param lo  Pointer to start of range.
    00405        *  @param hi  Pointer to end of range.
    00406        *  @return  Pointer to a matching char_type if found, else @a hi.
    00407       */
    00408       virtual const char_type*
    00409       do_scan_is(mask __m, const char_type* __lo,
    00410          const char_type* __hi) const = 0;
    00411
    00412       /**
    00413        *  @brief  Find char_type not matching mask
    00414        *
    00415        *  This function searches for and returns a pointer to the first
    00416        *  char_type c of [lo,hi) for which is(m,c) is false.
    00417        *
    00418        *  do_scan_is() is a hook for a derived facet to change the behavior of
    00419        *  match searching.  do_is() must always return the same result for the
    00420        *  same input.
    00421        *
    00422        *  @param m  The mask to compare against.
    00423        *  @param lo  Pointer to start of range.
    00424        *  @param hi  Pointer to end of range.
    00425        *  @return  Pointer to a non-matching char_type if found, else @a hi.
    00426       */
    00427       virtual const char_type*
    00428       do_scan_not(mask __m, const char_type* __lo,
    00429           const char_type* __hi) const = 0;
    00430
    00431       /**
    00432        *  @brief  Convert to uppercase.
    00433        *
    00434        *  This virtual function converts the char_type argument to uppercase
    00435        *  if possible.  If not possible (for example, '2'), returns the
    00436        *  argument.
    00437        *
    00438        *  do_toupper() is a hook for a derived facet to change the behavior of
    00439        *  uppercasing.  do_toupper() must always return the same result for
    00440        *  the same input.
    00441        *
    00442        *  @param c  The char_type to convert.
    00443        *  @return  The uppercase char_type if convertible, else @a c.
    00444       */
    00445       virtual char_type
    00446       do_toupper(char_type) const = 0;
    00447
    00448       /**
    00449        *  @brief  Convert array to uppercase.
    00450        *
    00451        *  This virtual function converts each char_type in the range [lo,hi)
    00452        *  to uppercase if possible.  Other elements remain untouched.
    00453        *
    00454        *  do_toupper() is a hook for a derived facet to change the behavior of
    00455        *  uppercasing.  do_toupper() must always return the same result for
    00456        *  the same input.
    00457        *
    00458        *  @param lo  Pointer to start of range.
    00459        *  @param hi  Pointer to end of range.
    00460        *  @return  @a hi.
    00461       */
    00462       virtual const char_type*
    00463       do_toupper(char_type* __lo, const char_type* __hi) const = 0;
    00464
    00465       /**
    00466        *  @brief  Convert to lowercase.
    00467        *
    00468        *  This virtual function converts the argument to lowercase if
    00469        *  possible.  If not possible (for example, '2'), returns the argument.
    00470        *
    00471        *  do_tolower() is a hook for a derived facet to change the behavior of
    00472        *  lowercasing.  do_tolower() must always return the same result for
    00473        *  the same input.
    00474        *
    00475        *  @param c  The char_type to convert.
    00476        *  @return  The lowercase char_type if convertible, else @a c.
    00477       */
    00478       virtual char_type
    00479       do_tolower(char_type) const = 0;
    00480
    00481       /**
    00482        *  @brief  Convert array to lowercase.
    00483        *
    00484        *  This virtual function converts each char_type in the range [lo,hi)
    00485        *  to lowercase if possible.  Other elements remain untouched.
    00486        *
    00487        *  do_tolower() is a hook for a derived facet to change the behavior of
    00488        *  lowercasing.  do_tolower() must always return the same result for
    00489        *  the same input.
    00490        *
    00491        *  @param lo  Pointer to start of range.
    00492        *  @param hi  Pointer to end of range.
    00493        *  @return  @a hi.
    00494       */
    00495       virtual const char_type*
    00496       do_tolower(char_type* __lo, const char_type* __hi) const = 0;
    00497
    00498       /**
    00499        *  @brief  Widen char
    00500        *
    00501        *  This virtual function converts the char to char_type using the
    00502        *  simplest reasonable transformation.
    00503        *
    00504        *  do_widen() is a hook for a derived facet to change the behavior of
    00505        *  widening.  do_widen() must always return the same result for the
    00506        *  same input.
    00507        *
    00508        *  Note: this is not what you want for codepage conversions.  See
    00509        *  codecvt for that.
    00510        *
    00511        *  @param c  The char to convert.
    00512        *  @return  The converted char_type
    00513       */
    00514       virtual char_type
    00515       do_widen(char) const = 0;
    00516
    00517       /**
    00518        *  @brief  Widen char array
    00519        *
    00520        *  This function converts each char in the input to char_type using the
    00521        *  simplest reasonable transformation.
    00522        *
    00523        *  do_widen() is a hook for a derived facet to change the behavior of
    00524        *  widening.  do_widen() must always return the same result for the
    00525        *  same input.
    00526        *
    00527        *  Note: this is not what you want for codepage conversions.  See
    00528        *  codecvt for that.
    00529        *
    00530        *  @param lo  Pointer to start range.
    00531        *  @param hi  Pointer to end of range.
    00532        *  @param to  Pointer to the destination array.
    00533        *  @return  @a hi.
    00534       */
    00535       virtual const char*
    00536       do_widen(const char* __lo, const char* __hi,
    00537            char_type* __dest) const = 0;
    00538
    00539       /**
    00540        *  @brief  Narrow char_type to char
    00541        *
    00542        *  This virtual function converts the argument to char using the
    00543        *  simplest reasonable transformation.  If the conversion fails, dfault
    00544        *  is returned instead.
    00545        *
    00546        *  do_narrow() is a hook for a derived facet to change the behavior of
    00547        *  narrowing.  do_narrow() must always return the same result for the
    00548        *  same input.
    00549        *
    00550        *  Note: this is not what you want for codepage conversions.  See
    00551        *  codecvt for that.
    00552        *
    00553        *  @param c  The char_type to convert.
    00554        *  @param dfault  Char to return if conversion fails.
    00555        *  @return  The converted char.
    00556       */
    00557       virtual char
    00558       do_narrow(char_type, char __dfault) const = 0;
    00559
    00560       /**
    00561        *  @brief  Narrow char_type array to char
    00562        *
    00563        *  This virtual function converts each char_type in the range [lo,hi) to
    00564        *  char using the simplest reasonable transformation and writes the
    00565        *  results to the destination array.  For any element in the input that
    00566        *  cannot be converted, @a dfault is used instead.
    00567        *
    00568        *  do_narrow() is a hook for a derived facet to change the behavior of
    00569        *  narrowing.  do_narrow() must always return the same result for the
    00570        *  same input.
    00571        *
    00572        *  Note: this is not what you want for codepage conversions.  See
    00573        *  codecvt for that.
    00574        *
    00575        *  @param lo  Pointer to start of range.
    00576        *  @param hi  Pointer to end of range.
    00577        *  @param dfault  Char to use if conversion fails.
    00578        *  @param to  Pointer to the destination array.
    00579        *  @return  @a hi.
    00580       */
    00581       virtual const char_type*
    00582       do_narrow(const char_type* __lo, const char_type* __hi,
    00583         char __dfault, char* __dest) const = 0;
    00584     };
    00585
    00586   // NB: Generic, mostly useless implementation.
    00587   /**
    00588    *  @brief  Template ctype facet
    00589    *
    00590    *  This template class defines classification and conversion functions for
    00591    *  character sets.  It wraps <cctype> functionality.  Ctype gets used by
    00592    *  streams for many I/O operations.
    00593    *
    00594    *  This template provides the protected virtual functions the developer
    00595    *  will have to replace in a derived class or specialization to make a
    00596    *  working facet.  The public functions that access them are defined in
    00597    *  __ctype_abstract_base, to allow for implementation flexibility.  See
    00598    *  ctype<wchar_t> for an example.  The functions are documented in
    00599    *  __ctype_abstract_base.
    00600    *
    00601    *  Note: implementations are provided for all the protected virtual
    00602    *  functions, but will likely not be useful.
    00603   */
    00604   template<typename _CharT>
    00605     class ctype : public __ctype_abstract_base<_CharT>
    00606     {
    00607     public:
    00608       // Types:
    00609       typedef _CharT            char_type;
    00610       typedef typename __ctype_abstract_base<_CharT>::mask mask;
    00611
    00612       /// The facet id for ctype<char_type>
    00613       static locale::id         id;
    00614
    00615       explicit
    00616       ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
    00617
    00618    protected:
    00619       virtual
    00620       ~ctype();
    00621
    00622       virtual bool
    00623       do_is(mask __m, char_type __c) const;
    00624
    00625       virtual const char_type*
    00626       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
    00627
    00628       virtual const char_type*
    00629       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
    00630
    00631       virtual const char_type*
    00632       do_scan_not(mask __m, const char_type* __lo,
    00633           const char_type* __hi) const;
    00634
    00635       virtual char_type
    00636       do_toupper(char_type __c) const;
    00637
    00638       virtual const char_type*
    00639       do_toupper(char_type* __lo, const char_type* __hi) const;
    00640
    00641       virtual char_type
    00642       do_tolower(char_type __c) const;
    00643
    00644       virtual const char_type*
    00645       do_tolower(char_type* __lo, const char_type* __hi) const;
    00646
    00647       virtual char_type
    00648       do_widen(char __c) const;
    00649
    00650       virtual const char*
    00651       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
    00652
    00653       virtual char
    00654       do_narrow(char_type, char __dfault) const;
    00655
    00656       virtual const char_type*
    00657       do_narrow(const char_type* __lo, const char_type* __hi,
    00658         char __dfault, char* __dest) const;
    00659     };
    00660
    00661   template<typename _CharT>
    00662     locale::id ctype<_CharT>::id;
    00663
    00664   // 22.2.1.3  ctype<char> specialization.
    00665   /**
    00666    *  @brief  The ctype<char> specialization.
    00667    *
    00668    *  This class defines classification and conversion functions for
    00669    *  the char type.  It gets used by char streams for many I/O
    00670    *  operations.  The char specialization provides a number of
    00671    *  optimizations as well.
    00672   */
    00673   template<>
    00674     class ctype<char> : public locale::facet, public ctype_base
    00675     {
    00676     public:
    00677       // Types:
    00678       /// Typedef for the template parameter char.
    00679       typedef char      char_type;
    00680
    00681     protected:
    00682       // Data Members:
    00683       __c_locale        _M_c_locale_ctype;
    00684       bool          _M_del;
    00685       __to_type         _M_toupper;
    00686       __to_type         _M_tolower;
    00687       const mask*       _M_table;
    00688       mutable char      _M_widen_ok;
    00689       mutable char      _M_widen[1 + static_cast<unsigned char>(-1)];
    00690       mutable char      _M_narrow[1 + static_cast<unsigned char>(-1)];
    00691       mutable char      _M_narrow_ok;   // 0 uninitialized, 1 init,
    00692                         // 2 memcpy can't be used
    00693
    00694     public:
    00695       /// The facet id for ctype<char>
    00696       static locale::id        id;
    00697       /// The size of the mask table.  It is SCHAR_MAX + 1.
    00698       static const size_t      table_size = 1 + static_cast<unsigned char>(-1);
    00699
    00700       /**
    00701        *  @brief  Constructor performs initialization.
    00702        *
    00703        *  This is the constructor provided by the standard.
    00704        *
    00705        *  @param table If non-zero, table is used as the per-char mask.
    00706        *               Else classic_table() is used.
    00707        *  @param del   If true, passes ownership of table to this facet.
    00708        *  @param refs  Passed to the base facet class.
    00709       */
    00710       explicit
    00711       ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
    00712
    00713       /**
    00714        *  @brief  Constructor performs static initialization.
    00715        *
    00716        *  This constructor is used to construct the initial C locale facet.
    00717        *
    00718        *  @param cloc  Handle to C locale data.
    00719        *  @param table If non-zero, table is used as the per-char mask.
    00720        *  @param del   If true, passes ownership of table to this facet.
    00721        *  @param refs  Passed to the base facet class.
    00722       */
    00723       explicit
    00724       ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false,
    00725         size_t __refs = 0);
    00726
    00727       /**
    00728        *  @brief  Test char classification.
    00729        *
    00730        *  This function compares the mask table[c] to @a m.
    00731        *
    00732        *  @param c  The char to compare the mask of.
    00733        *  @param m  The mask to compare against.
    00734        *  @return  True if m & table[c] is true, false otherwise.
    00735       */
    00736       inline bool
    00737       is(mask __m, char __c) const;
    00738
    00739       /**
    00740        *  @brief  Return a mask array.
    00741        *
    00742        *  This function finds the mask for each char in the range [lo, hi) and
    00743        *  successively writes it to vec.  vec must have as many elements as
    00744        *  the char array.
    00745        *
    00746        *  @param lo  Pointer to start of range.
    00747        *  @param hi  Pointer to end of range.
    00748        *  @param vec  Pointer to an array of mask storage.
    00749        *  @return  @a hi.
    00750       */
    00751       inline const char*
    00752       is(const char* __lo, const char* __hi, mask* __vec) const;
    00753
    00754       /**
    00755        *  @brief  Find char matching a mask
    00756        *
    00757        *  This function searches for and returns the first char in [lo,hi) for
    00758        *  which is(m,char) is true.
    00759        *
    00760        *  @param m  The mask to compare against.
    00761        *  @param lo  Pointer to start of range.
    00762        *  @param hi  Pointer to end of range.
    00763        *  @return  Pointer to a matching char if found, else @a hi.
    00764       */
    00765       inline const char*
    00766       scan_is(mask __m, const char* __lo, const char* __hi) const;
    00767
    00768       /**
    00769        *  @brief  Find char not matching a mask
    00770        *
    00771        *  This function searches for and returns a pointer to the first char
    00772        *  in [lo,hi) for which is(m,char) is false.
    00773        *
    00774        *  @param m  The mask to compare against.
    00775        *  @param lo  Pointer to start of range.
    00776        *  @param hi  Pointer to end of range.
    00777        *  @return  Pointer to a non-matching char if found, else @a hi.
    00778       */
    00779       inline const char*
    00780       scan_not(mask __m, const char* __lo, const char* __hi) const;
    00781
    00782       /**
    00783        *  @brief  Convert to uppercase.
    00784        *
    00785        *  This function converts the char argument to uppercase if possible.
    00786        *  If not possible (for example, '2'), returns the argument.
    00787        *
    00788        *  toupper() acts as if it returns ctype<char>::do_toupper(c).
    00789        *  do_toupper() must always return the same result for the same input.
    00790        *
    00791        *  @param c  The char to convert.
    00792        *  @return  The uppercase char if convertible, else @a c.
    00793       */
    00794       char_type
    00795       toupper(char_type __c) const
    00796       { return this->do_toupper(__c); }
    00797
    00798       /**
    00799        *  @brief  Convert array to uppercase.
    00800        *
    00801        *  This function converts each char in the range [lo,hi) to uppercase
    00802        *  if possible.  Other chars remain untouched.
    00803        *
    00804        *  toupper() acts as if it returns ctype<char>:: do_toupper(lo, hi).
    00805        *  do_toupper() must always return the same result for the same input.
    00806        *
    00807        *  @param lo  Pointer to first char in range.
    00808        *  @param hi  Pointer to end of range.
    00809        *  @return  @a hi.
    00810       */
    00811       const char_type*
    00812       toupper(char_type *__lo, const char_type* __hi) const
    00813       { return this->do_toupper(__lo, __hi); }
    00814
    00815       /**
    00816        *  @brief  Convert to lowercase.
    00817        *
    00818        *  This function converts the char argument to lowercase if possible.
    00819        *  If not possible (for example, '2'), returns the argument.
    00820        *
    00821        *  tolower() acts as if it returns ctype<char>::do_tolower(c).
    00822        *  do_tolower() must always return the same result for the same input.
    00823        *
    00824        *  @param c  The char to convert.
    00825        *  @return  The lowercase char if convertible, else @a c.
    00826       */
    00827       char_type
    00828       tolower(char_type __c) const
    00829       { return this->do_tolower(__c); }
    00830
    00831       /**
    00832        *  @brief  Convert array to lowercase.
    00833        *
    00834        *  This function converts each char in the range [lo,hi) to lowercase
    00835        *  if possible.  Other chars remain untouched.
    00836        *
    00837        *  tolower() acts as if it returns ctype<char>:: do_tolower(lo, hi).
    00838        *  do_tolower() must always return the same result for the same input.
    00839        *
    00840        *  @param lo  Pointer to first char in range.
    00841        *  @param hi  Pointer to end of range.
    00842        *  @return  @a hi.
    00843       */
    00844       const char_type*
    00845       tolower(char_type* __lo, const char_type* __hi) const
    00846       { return this->do_tolower(__lo, __hi); }
    00847
    00848       /**
    00849        *  @brief  Widen char
    00850        *
    00851        *  This function converts the char to char_type using the simplest
    00852        *  reasonable transformation.  For an underived ctype<char> facet, the
    00853        *  argument will be returned unchanged.
    00854        *
    00855        *  This function works as if it returns ctype<char>::do_widen(c).
    00856        *  do_widen() must always return the same result for the same input.
    00857        *
    00858        *  Note: this is not what you want for codepage conversions.  See
    00859        *  codecvt for that.
    00860        *
    00861        *  @param c  The char to convert.
    00862        *  @return  The converted character.
    00863       */
    00864       char_type
    00865       widen(char __c) const
    00866       {
    00867     if (_M_widen_ok)
    00868       return _M_widen[static_cast<unsigned char>(__c)];
    00869     this->_M_widen_init();
    00870     return this->do_widen(__c);
    00871       }
    00872
    00873       /**
    00874        *  @brief  Widen char array
    00875        *
    00876        *  This function converts each char in the input to char using the
    00877        *  simplest reasonable transformation.  For an underived ctype<char>
    00878        *  facet, the argument will be copied unchanged.
    00879        *
    00880        *  This function works as if it returns ctype<char>::do_widen(c).
    00881        *  do_widen() must always return the same result for the same input.
    00882        *
    00883        *  Note: this is not what you want for codepage conversions.  See
    00884        *  codecvt for that.
    00885        *
    00886        *  @param lo  Pointer to first char in range.
    00887        *  @param hi  Pointer to end of range.
    00888        *  @param to  Pointer to the destination array.
    00889        *  @return  @a hi.
    00890       */
    00891       const char*
    00892       widen(const char* __lo, const char* __hi, char_type* __to) const
    00893       {
    00894     if (_M_widen_ok == 1)
    00895       {
    00896         __builtin_memcpy(__to, __lo, __hi - __lo);
    00897         return __hi;
    00898       }
    00899     if (!_M_widen_ok)
    00900       _M_widen_init();
    00901     return this->do_widen(__lo, __hi, __to);
    00902       }
    00903
    00904       /**
    00905        *  @brief  Narrow char
    00906        *
    00907        *  This function converts the char to char using the simplest
    00908        *  reasonable transformation.  If the conversion fails, dfault is
    00909        *  returned instead.  For an underived ctype<char> facet, @a c
    00910        *  will be returned unchanged.
    00911        *
    00912        *  This function works as if it returns ctype<char>::do_narrow(c).
    00913        *  do_narrow() must always return the same result for the same input.
    00914        *
    00915        *  Note: this is not what you want for codepage conversions.  See
    00916        *  codecvt for that.
    00917        *
    00918        *  @param c  The char to convert.
    00919        *  @param dfault  Char to return if conversion fails.
    00920        *  @return  The converted character.
    00921       */
    00922       char
    00923       narrow(char_type __c, char __dfault) const
    00924       {
    00925     if (_M_narrow[static_cast<unsigned char>(__c)])
    00926       return _M_narrow[static_cast<unsigned char>(__c)];
    00927     const char __t = do_narrow(__c, __dfault);
    00928     if (__t != __dfault)
    00929       _M_narrow[static_cast<unsigned char>(__c)] = __t;
    00930     return __t;
    00931       }
    00932
    00933       /**
    00934        *  @brief  Narrow char array
    00935        *
    00936        *  This function converts each char in the input to char using the
    00937        *  simplest reasonable transformation and writes the results to the
    00938        *  destination array.  For any char in the input that cannot be
    00939        *  converted, @a dfault is used instead.  For an underived ctype<char>
    00940        *  facet, the argument will be copied unchanged.
    00941        *
    00942        *  This function works as if it returns ctype<char>::do_narrow(lo, hi,
    00943        *  dfault, to).  do_narrow() must always return the same result for the
    00944        *  same input.
    00945        *
    00946        *  Note: this is not what you want for codepage conversions.  See
    00947        *  codecvt for that.
    00948        *
    00949        *  @param lo  Pointer to start of range.
    00950        *  @param hi  Pointer to end of range.
    00951        *  @param dfault  Char to use if conversion fails.
    00952        *  @param to  Pointer to the destination array.
    00953        *  @return  @a hi.
    00954       */
    00955       const char_type*
    00956       narrow(const char_type* __lo, const char_type* __hi,
    00957          char __dfault, char *__to) const
    00958       {
    00959     if (__builtin_expect(_M_narrow_ok == 1, true))
    00960       {
    00961         __builtin_memcpy(__to, __lo, __hi - __lo);
    00962         return __hi;
    00963       }
    00964     if (!_M_narrow_ok)
    00965       _M_narrow_init();
    00966     return this->do_narrow(__lo, __hi, __dfault, __to);
    00967       }
    00968
    00969       // _GLIBCXX_RESOLVE_LIB_DEFECTS
    00970       // DR 695. ctype<char>::classic_table() not accessible.
    00971       /// Returns a pointer to the mask table provided to the constructor, or
    00972       /// the default from classic_table() if none was provided.
    00973       const mask*
    00974       table() const throw()
    00975       { return _M_table; }
    00976
    00977       /// Returns a pointer to the C locale mask table.
    00978       static const mask*
    00979       classic_table() throw();
    00980     protected:
    00981
    00982       /**
    00983        *  @brief  Destructor.
    00984        *
    00985        *  This function deletes table() if @a del was true in the
    00986        *  constructor.
    00987       */
    00988       virtual
    00989       ~ctype();
    00990
    00991       /**
    00992        *  @brief  Convert to uppercase.
    00993        *
    00994        *  This virtual function converts the char argument to uppercase if
    00995        *  possible.  If not possible (for example, '2'), returns the argument.
    00996        *
    00997        *  do_toupper() is a hook for a derived facet to change the behavior of
    00998        *  uppercasing.  do_toupper() must always return the same result for
    00999        *  the same input.
    01000        *
    01001        *  @param c  The char to convert.
    01002        *  @return  The uppercase char if convertible, else @a c.
    01003       */
    01004       virtual char_type
    01005       do_toupper(char_type) const;
    01006
    01007       /**
    01008        *  @brief  Convert array to uppercase.
    01009        *
    01010        *  This virtual function converts each char in the range [lo,hi) to
    01011        *  uppercase if possible.  Other chars remain untouched.
    01012        *
    01013        *  do_toupper() is a hook for a derived facet to change the behavior of
    01014        *  uppercasing.  do_toupper() must always return the same result for
    01015        *  the same input.
    01016        *
    01017        *  @param lo  Pointer to start of range.
    01018        *  @param hi  Pointer to end of range.
    01019        *  @return  @a hi.
    01020       */
    01021       virtual const char_type*
    01022       do_toupper(char_type* __lo, const char_type* __hi) const;
    01023
    01024       /**
    01025        *  @brief  Convert to lowercase.
    01026        *
    01027        *  This virtual function converts the char argument to lowercase if
    01028        *  possible.  If not possible (for example, '2'), returns the argument.
    01029        *
    01030        *  do_tolower() is a hook for a derived facet to change the behavior of
    01031        *  lowercasing.  do_tolower() must always return the same result for
    01032        *  the same input.
    01033        *
    01034        *  @param c  The char to convert.
    01035        *  @return  The lowercase char if convertible, else @a c.
    01036       */
    01037       virtual char_type
    01038       do_tolower(char_type) const;
    01039
    01040       /**
    01041        *  @brief  Convert array to lowercase.
    01042        *
    01043        *  This virtual function converts each char in the range [lo,hi) to
    01044        *  lowercase if possible.  Other chars remain untouched.
    01045        *
    01046        *  do_tolower() is a hook for a derived facet to change the behavior of
    01047        *  lowercasing.  do_tolower() must always return the same result for
    01048        *  the same input.
    01049        *
    01050        *  @param lo  Pointer to first char in range.
    01051        *  @param hi  Pointer to end of range.
    01052        *  @return  @a hi.
    01053       */
    01054       virtual const char_type*
    01055       do_tolower(char_type* __lo, const char_type* __hi) const;
    01056
    01057       /**
    01058        *  @brief  Widen char
    01059        *
    01060        *  This virtual function converts the char to char using the simplest
    01061        *  reasonable transformation.  For an underived ctype<char> facet, the
    01062        *  argument will be returned unchanged.
    01063        *
    01064        *  do_widen() is a hook for a derived facet to change the behavior of
    01065        *  widening.  do_widen() must always return the same result for the
    01066        *  same input.
    01067        *
    01068        *  Note: this is not what you want for codepage conversions.  See
    01069        *  codecvt for that.
    01070        *
    01071        *  @param c  The char to convert.
    01072        *  @return  The converted character.
    01073       */
    01074       virtual char_type
    01075       do_widen(char __c) const
    01076       { return __c; }
    01077
    01078       /**
    01079        *  @brief  Widen char array
    01080        *
    01081        *  This function converts each char in the range [lo,hi) to char using
    01082        *  the simplest reasonable transformation.  For an underived
    01083        *  ctype<char> facet, the argument will be copied unchanged.
    01084        *
    01085        *  do_widen() is a hook for a derived facet to change the behavior of
    01086        *  widening.  do_widen() must always return the same result for the
    01087        *  same input.
    01088        *
    01089        *  Note: this is not what you want for codepage conversions.  See
    01090        *  codecvt for that.
    01091        *
    01092        *  @param lo  Pointer to start of range.
    01093        *  @param hi  Pointer to end of range.
    01094        *  @param to  Pointer to the destination array.
    01095        *  @return  @a hi.
    01096       */
    01097       virtual const char*
    01098       do_widen(const char* __lo, const char* __hi, char_type* __dest) const
    01099       {
    01100     __builtin_memcpy(__dest, __lo, __hi - __lo);
    01101     return __hi;
    01102       }
    01103
    01104       /**
    01105        *  @brief  Narrow char
    01106        *
    01107        *  This virtual function converts the char to char using the simplest
    01108        *  reasonable transformation.  If the conversion fails, dfault is
    01109        *  returned instead.  For an underived ctype<char> facet, @a c will be
    01110        *  returned unchanged.
    01111        *
    01112        *  do_narrow() is a hook for a derived facet to change the behavior of
    01113        *  narrowing.  do_narrow() must always return the same result for the
    01114        *  same input.
    01115        *
    01116        *  Note: this is not what you want for codepage conversions.  See
    01117        *  codecvt for that.
    01118        *
    01119        *  @param c  The char to convert.
    01120        *  @param dfault  Char to return if conversion fails.
    01121        *  @return  The converted char.
    01122       */
    01123       virtual char
    01124       do_narrow(char_type __c, char) const
    01125       { return __c; }
    01126
    01127       /**
    01128        *  @brief  Narrow char array to char array
    01129        *
    01130        *  This virtual function converts each char in the range [lo,hi) to
    01131        *  char using the simplest reasonable transformation and writes the
    01132        *  results to the destination array.  For any char in the input that
    01133        *  cannot be converted, @a dfault is used instead.  For an underived
    01134        *  ctype<char> facet, the argument will be copied unchanged.
    01135        *
    01136        *  do_narrow() is a hook for a derived facet to change the behavior of
    01137        *  narrowing.  do_narrow() must always return the same result for the
    01138        *  same input.
    01139        *
    01140        *  Note: this is not what you want for codepage conversions.  See
    01141        *  codecvt for that.
    01142        *
    01143        *  @param lo  Pointer to start of range.
    01144        *  @param hi  Pointer to end of range.
    01145        *  @param dfault  Char to use if conversion fails.
    01146        *  @param to  Pointer to the destination array.
    01147        *  @return  @a hi.
    01148       */
    01149       virtual const char_type*
    01150       do_narrow(const char_type* __lo, const char_type* __hi,
    01151         char, char* __dest) const
    01152       {
    01153     __builtin_memcpy(__dest, __lo, __hi - __lo);
    01154     return __hi;
    01155       }
    01156
    01157     private:
    01158       void _M_narrow_init() const;
    01159       void _M_widen_init() const;
    01160     };
    01161
    01162 #ifdef _GLIBCXX_USE_WCHAR_T
    01163   // 22.2.1.3  ctype<wchar_t> specialization
    01164   /**
    01165    *  @brief  The ctype<wchar_t> specialization.
    01166    *
    01167    *  This class defines classification and conversion functions for the
    01168    *  wchar_t type.  It gets used by wchar_t streams for many I/O operations.
    01169    *  The wchar_t specialization provides a number of optimizations as well.
    01170    *
    01171    *  ctype<wchar_t> inherits its public methods from
    01172    *  __ctype_abstract_base<wchar_t>.
    01173   */
    01174   template<>
    01175     class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
    01176     {
    01177     public:
    01178       // Types:
    01179       /// Typedef for the template parameter wchar_t.
    01180       typedef wchar_t       char_type;
    01181       typedef wctype_t      __wmask_type;
    01182
    01183     protected:
    01184       __c_locale        _M_c_locale_ctype;
    01185
    01186       // Pre-computed narrowed and widened chars.
    01187       bool                      _M_narrow_ok;
    01188       char                      _M_narrow[128];
    01189       wint_t                    _M_widen[1 + static_cast<unsigned char>(-1)];
    01190
    01191       // Pre-computed elements for do_is.
    01192       mask                      _M_bit[16];
    01193       __wmask_type              _M_wmask[16];
    01194
    01195     public:
    01196       // Data Members:
    01197       /// The facet id for ctype<wchar_t>
    01198       static locale::id     id;
    01199
    01200       /**
    01201        *  @brief  Constructor performs initialization.
    01202        *
    01203        *  This is the constructor provided by the standard.
    01204        *
    01205        *  @param refs  Passed to the base facet class.
    01206       */
    01207       explicit
    01208       ctype(size_t __refs = 0);
    01209
    01210       /**
    01211        *  @brief  Constructor performs static initialization.
    01212        *
    01213        *  This constructor is used to construct the initial C locale facet.
    01214        *
    01215        *  @param cloc  Handle to C locale data.
    01216        *  @param refs  Passed to the base facet class.
    01217       */
    01218       explicit
    01219       ctype(__c_locale __cloc, size_t __refs = 0);
    01220
    01221     protected:
    01222       __wmask_type
    01223       _M_convert_to_wmask(const mask __m) const;
    01224
    01225       /// Destructor
    01226       virtual
    01227       ~ctype();
    01228
    01229       /**
    01230        *  @brief  Test wchar_t classification.
    01231        *
    01232        *  This function finds a mask M for @a c and compares it to mask @a m.
    01233        *
    01234        *  do_is() is a hook for a derived facet to change the behavior of
    01235        *  classifying.  do_is() must always return the same result for the
    01236        *  same input.
    01237        *
    01238        *  @param c  The wchar_t to find the mask of.
    01239        *  @param m  The mask to compare against.
    01240        *  @return  (M & m) != 0.
    01241       */
    01242       virtual bool
    01243       do_is(mask __m, char_type __c) const;
    01244
    01245       /**
    01246        *  @brief  Return a mask array.
    01247        *
    01248        *  This function finds the mask for each wchar_t in the range [lo,hi)
    01249        *  and successively writes it to vec.  vec must have as many elements
    01250        *  as the input.
    01251        *
    01252        *  do_is() is a hook for a derived facet to change the behavior of
    01253        *  classifying.  do_is() must always return the same result for the
    01254        *  same input.
    01255        *
    01256        *  @param lo  Pointer to start of range.
    01257        *  @param hi  Pointer to end of range.
    01258        *  @param vec  Pointer to an array of mask storage.
    01259        *  @return  @a hi.
    01260       */
    01261       virtual const char_type*
    01262       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
    01263
    01264       /**
    01265        *  @brief  Find wchar_t matching mask
    01266        *
    01267        *  This function searches for and returns the first wchar_t c in
    01268        *  [lo,hi) for which is(m,c) is true.
    01269        *
    01270        *  do_scan_is() is a hook for a derived facet to change the behavior of
    01271        *  match searching.  do_is() must always return the same result for the
    01272        *  same input.
    01273        *
    01274        *  @param m  The mask to compare against.
    01275        *  @param lo  Pointer to start of range.
    01276        *  @param hi  Pointer to end of range.
    01277        *  @return  Pointer to a matching wchar_t if found, else @a hi.
    01278       */
    01279       virtual const char_type*
    01280       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
    01281
    01282       /**
    01283        *  @brief  Find wchar_t not matching mask
    01284        *
    01285        *  This function searches for and returns a pointer to the first
    01286        *  wchar_t c of [lo,hi) for which is(m,c) is false.
    01287        *
    01288        *  do_scan_is() is a hook for a derived facet to change the behavior of
    01289        *  match searching.  do_is() must always return the same result for the
    01290        *  same input.
    01291        *
    01292        *  @param m  The mask to compare against.
    01293        *  @param lo  Pointer to start of range.
    01294        *  @param hi  Pointer to end of range.
    01295        *  @return  Pointer to a non-matching wchar_t if found, else @a hi.
    01296       */
    01297       virtual const char_type*
    01298       do_scan_not(mask __m, const char_type* __lo,
    01299           const char_type* __hi) const;
    01300
    01301       /**
    01302        *  @brief  Convert to uppercase.
    01303        *
    01304        *  This virtual function converts the wchar_t argument to uppercase if
    01305        *  possible.  If not possible (for example, '2'), returns the argument.
    01306        *
    01307        *  do_toupper() is a hook for a derived facet to change the behavior of
    01308        *  uppercasing.  do_toupper() must always return the same result for
    01309        *  the same input.
    01310        *
    01311        *  @param c  The wchar_t to convert.
    01312        *  @return  The uppercase wchar_t if convertible, else @a c.
    01313       */
    01314       virtual char_type
    01315       do_toupper(char_type) const;
    01316
    01317       /**
    01318        *  @brief  Convert array to uppercase.
    01319        *
    01320        *  This virtual function converts each wchar_t in the range [lo,hi) to
    01321        *  uppercase if possible.  Other elements remain untouched.
    01322        *
    01323        *  do_toupper() is a hook for a derived facet to change the behavior of
    01324        *  uppercasing.  do_toupper() must always return the same result for
    01325        *  the same input.
    01326        *
    01327        *  @param lo  Pointer to start of range.
    01328        *  @param hi  Pointer to end of range.
    01329        *  @return  @a hi.
    01330       */
    01331       virtual const char_type*
    01332       do_toupper(char_type* __lo, const char_type* __hi) const;
    01333
    01334       /**
    01335        *  @brief  Convert to lowercase.
    01336        *
    01337        *  This virtual function converts the argument to lowercase if
    01338        *  possible.  If not possible (for example, '2'), returns the argument.
    01339        *
    01340        *  do_tolower() is a hook for a derived facet to change the behavior of
    01341        *  lowercasing.  do_tolower() must always return the same result for
    01342        *  the same input.
    01343        *
    01344        *  @param c  The wchar_t to convert.
    01345        *  @return  The lowercase wchar_t if convertible, else @a c.
    01346       */
    01347       virtual char_type
    01348       do_tolower(char_type) const;
    01349
    01350       /**
    01351        *  @brief  Convert array to lowercase.
    01352        *
    01353        *  This virtual function converts each wchar_t in the range [lo,hi) to
    01354        *  lowercase if possible.  Other elements remain untouched.
    01355        *
    01356        *  do_tolower() is a hook for a derived facet to change the behavior of
    01357        *  lowercasing.  do_tolower() must always return the same result for
    01358        *  the same input.
    01359        *
    01360        *  @param lo  Pointer to start of range.
    01361        *  @param hi  Pointer to end of range.
    01362        *  @return  @a hi.
    01363       */
    01364       virtual const char_type*
    01365       do_tolower(char_type* __lo, const char_type* __hi) const;
    01366
    01367       /**
    01368        *  @brief  Widen char to wchar_t
    01369        *
    01370        *  This virtual function converts the char to wchar_t using the
    01371        *  simplest reasonable transformation.  For an underived ctype<wchar_t>
    01372        *  facet, the argument will be cast to wchar_t.
    01373        *
    01374        *  do_widen() is a hook for a derived facet to change the behavior of
    01375        *  widening.  do_widen() must always return the same result for the
    01376        *  same input.
    01377        *
    01378        *  Note: this is not what you want for codepage conversions.  See
    01379        *  codecvt for that.
    01380        *
    01381        *  @param c  The char to convert.
    01382        *  @return  The converted wchar_t.
    01383       */
    01384       virtual char_type
    01385       do_widen(char) const;
    01386
    01387       /**
    01388        *  @brief  Widen char array to wchar_t array
    01389        *
    01390        *  This function converts each char in the input to wchar_t using the
    01391        *  simplest reasonable transformation.  For an underived ctype<wchar_t>
    01392        *  facet, the argument will be copied, casting each element to wchar_t.
    01393        *
    01394        *  do_widen() is a hook for a derived facet to change the behavior of
    01395        *  widening.  do_widen() must always return the same result for the
    01396        *  same input.
    01397        *
    01398        *  Note: this is not what you want for codepage conversions.  See
    01399        *  codecvt for that.
    01400        *
    01401        *  @param lo  Pointer to start range.
    01402        *  @param hi  Pointer to end of range.
    01403        *  @param to  Pointer to the destination array.
    01404        *  @return  @a hi.
    01405       */
    01406       virtual const char*
    01407       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
    01408
    01409       /**
    01410        *  @brief  Narrow wchar_t to char
    01411        *
    01412        *  This virtual function converts the argument to char using
    01413        *  the simplest reasonable transformation.  If the conversion
    01414        *  fails, dfault is returned instead.  For an underived
    01415        *  ctype<wchar_t> facet, @a c will be cast to char and
    01416        *  returned.
    01417        *
    01418        *  do_narrow() is a hook for a derived facet to change the
    01419        *  behavior of narrowing.  do_narrow() must always return the
    01420        *  same result for the same input.
    01421        *
    01422        *  Note: this is not what you want for codepage conversions.  See
    01423        *  codecvt for that.
    01424        *
    01425        *  @param c  The wchar_t to convert.
    01426        *  @param dfault  Char to return if conversion fails.
    01427        *  @return  The converted char.
    01428       */
    01429       virtual char
    01430       do_narrow(char_type, char __dfault) const;
    01431
    01432       /**
    01433        *  @brief  Narrow wchar_t array to char array
    01434        *
    01435        *  This virtual function converts each wchar_t in the range [lo,hi) to
    01436        *  char using the simplest reasonable transformation and writes the
    01437        *  results to the destination array.  For any wchar_t in the input that
    01438        *  cannot be converted, @a dfault is used instead.  For an underived
    01439        *  ctype<wchar_t> facet, the argument will be copied, casting each
    01440        *  element to char.
    01441        *
    01442        *  do_narrow() is a hook for a derived facet to change the behavior of
    01443        *  narrowing.  do_narrow() must always return the same result for the
    01444        *  same input.
    01445        *
    01446        *  Note: this is not what you want for codepage conversions.  See
    01447        *  codecvt for that.
    01448        *
    01449        *  @param lo  Pointer to start of range.
    01450        *  @param hi  Pointer to end of range.
    01451        *  @param dfault  Char to use if conversion fails.
    01452        *  @param to  Pointer to the destination array.
    01453        *  @return  @a hi.
    01454       */
    01455       virtual const char_type*
    01456       do_narrow(const char_type* __lo, const char_type* __hi,
    01457         char __dfault, char* __dest) const;
    01458
    01459       // For use at construction time only.
    01460       void
    01461       _M_initialize_ctype();
    01462     };
    01463 #endif //_GLIBCXX_USE_WCHAR_T
    01464
    01465   /// class ctype_byname [22.2.1.2].
    01466   template<typename _CharT>
    01467     class ctype_byname : public ctype<_CharT>
    01468     {
    01469     public:
    01470       typedef typename ctype<_CharT>::mask  mask;
    01471
    01472       explicit
    01473       ctype_byname(const char* __s, size_t __refs = 0);
    01474
    01475     protected:
    01476       virtual
    01477       ~ctype_byname() { };
    01478     };
    01479
    01480   /// 22.2.1.4  Class ctype_byname specializations.
    01481   template<>
    01482     class ctype_byname<char> : public ctype<char>
    01483     {
    01484     public:
    01485       explicit
    01486       ctype_byname(const char* __s, size_t __refs = 0);
    01487
    01488     protected:
    01489       virtual
    01490       ~ctype_byname();
    01491     };
    01492
    01493 #ifdef _GLIBCXX_USE_WCHAR_T
    01494   template<>
    01495     class ctype_byname<wchar_t> : public ctype<wchar_t>
    01496     {
    01497     public:
    01498       explicit
    01499       ctype_byname(const char* __s, size_t __refs = 0);
    01500
    01501     protected:
    01502       virtual
    01503       ~ctype_byname();
    01504     };
    01505 #endif
    01506
    01507 _GLIBCXX_END_NAMESPACE
    01508
    01509 // Include host and configuration specific ctype inlines.
    01510 #include <bits/ctype_inline.h>
    01511
    01512 _GLIBCXX_BEGIN_NAMESPACE(std)
    01513
    01514   // 22.2.2  The numeric category.
    01515   class __num_base
    01516   {
    01517   public:
    01518     // NB: Code depends on the order of _S_atoms_out elements.
    01519     // Below are the indices into _S_atoms_out.
    01520     enum
    01521       {
    01522         _S_ominus,
    01523         _S_oplus,
    01524         _S_ox,
    01525         _S_oX,
    01526         _S_odigits,
    01527         _S_odigits_end = _S_odigits + 16,
    01528         _S_oudigits = _S_odigits_end,
    01529         _S_oudigits_end = _S_oudigits + 16,
    01530         _S_oe = _S_odigits + 14,  // For scientific notation, 'e'
    01531         _S_oE = _S_oudigits + 14, // For scientific notation, 'E'
    01532     _S_oend = _S_oudigits_end
    01533       };
    01534
    01535     // A list of valid numeric literals for output.  This array
    01536     // contains chars that will be passed through the current locale's
    01537     // ctype<_CharT>.widen() and then used to render numbers.
    01538     // For the standard "C" locale, this is
    01539     // "-+xX0123456789abcdef0123456789ABCDEF".
    01540     static const char* _S_atoms_out;
    01541
    01542     // String literal of acceptable (narrow) input, for num_get.
    01543     // "-+xX0123456789abcdefABCDEF"
    01544     static const char* _S_atoms_in;
    01545
    01546     enum
    01547     {
    01548       _S_iminus,
    01549       _S_iplus,
    01550       _S_ix,
    01551       _S_iX,
    01552       _S_izero,
    01553       _S_ie = _S_izero + 14,
    01554       _S_iE = _S_izero + 20,
    01555       _S_iend = 26
    01556     };
    01557
    01558     // num_put
    01559     // Construct and return valid scanf format for floating point types.
    01560     static void
    01561     _S_format_float(const ios_base& __io, char* __fptr, char __mod);
    01562   };
    01563
    01564   template<typename _CharT>
    01565     struct __numpunct_cache : public locale::facet
    01566     {
    01567       const char*           _M_grouping;
    01568       size_t                            _M_grouping_size;
    01569       bool              _M_use_grouping;
    01570       const _CharT*         _M_truename;
    01571       size_t                            _M_truename_size;
    01572       const _CharT*         _M_falsename;
    01573       size_t                            _M_falsename_size;
    01574       _CharT                _M_decimal_point;
    01575       _CharT                _M_thousands_sep;
    01576
    01577       // A list of valid numeric literals for output: in the standard
    01578       // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
    01579       // This array contains the chars after having been passed
    01580       // through the current locale's ctype<_CharT>.widen().
    01581       _CharT                _M_atoms_out[__num_base::_S_oend];
    01582
    01583       // A list of valid numeric literals for input: in the standard
    01584       // "C" locale, this is "-+xX0123456789abcdefABCDEF"
    01585       // This array contains the chars after having been passed
    01586       // through the current locale's ctype<_CharT>.widen().
    01587       _CharT                _M_atoms_in[__num_base::_S_iend];
    01588
    01589       bool              _M_allocated;
    01590
    01591       __numpunct_cache(size_t __refs = 0) : facet(__refs),
    01592       _M_grouping(NULL), _M_grouping_size(0), _M_use_grouping(false),
    01593       _M_truename(NULL), _M_truename_size(0), _M_falsename(NULL),
    01594       _M_falsename_size(0), _M_decimal_point(_CharT()),
    01595       _M_thousands_sep(_CharT()), _M_allocated(false)
    01596       { }
    01597
    01598       ~__numpunct_cache();
    01599
    01600       void
    01601       _M_cache(const locale& __loc);
    01602
    01603     private:
    01604       __numpunct_cache&
    01605       operator=(const __numpunct_cache&);
    01606
    01607       explicit
    01608       __numpunct_cache(const __numpunct_cache&);
    01609     };
    01610
    01611   template<typename _CharT>
    01612     __numpunct_cache<_CharT>::~__numpunct_cache()
    01613     {
    01614       if (_M_allocated)
    01615     {
    01616       delete [] _M_grouping;
    01617       delete [] _M_truename;
    01618       delete [] _M_falsename;
    01619     }
    01620     }
    01621
    01622   /**
    01623    *  @brief  Numpunct facet.
    01624    *
    01625    *  This facet stores several pieces of information related to printing and
    01626    *  scanning numbers, such as the decimal point character.  It takes a
    01627    *  template parameter specifying the char type.  The numpunct facet is
    01628    *  used by streams for many I/O operations involving numbers.
    01629    *
    01630    *  The numpunct template uses protected virtual functions to provide the
    01631    *  actual results.  The public accessors forward the call to the virtual
    01632    *  functions.  These virtual functions are hooks for developers to
    01633    *  implement the behavior they require from a numpunct facet.
    01634   */
    01635   template<typename _CharT>
    01636     class numpunct : public locale::facet
    01637     {
    01638     public:
    01639       // Types:
    01640       //@{
    01641       /// Public typedefs
    01642       typedef _CharT            char_type;
    01643       typedef basic_string<_CharT>  string_type;
    01644       //@}
    01645       typedef __numpunct_cache<_CharT>  __cache_type;
    01646
    01647     protected:
    01648       __cache_type*         _M_data;
    01649
    01650     public:
    01651       /// Numpunct facet id.
    01652       static locale::id         id;
    01653
    01654       /**
    01655        *  @brief  Numpunct constructor.
    01656        *
    01657        *  @param  refs  Refcount to pass to the base class.
    01658        */
    01659       explicit
    01660       numpunct(size_t __refs = 0) : facet(__refs), _M_data(NULL)
    01661       { _M_initialize_numpunct(); }
    01662
    01663       /**
    01664        *  @brief  Internal constructor.  Not for general use.
    01665        *
    01666        *  This is a constructor for use by the library itself to set up the
    01667        *  predefined locale facets.
    01668        *
    01669        *  @param  cache  __numpunct_cache object.
    01670        *  @param  refs  Refcount to pass to the base class.
    01671        */
    01672       explicit
    01673       numpunct(__cache_type* __cache, size_t __refs = 0)
    01674       : facet(__refs), _M_data(__cache)
    01675       { _M_initialize_numpunct(); }
    01676
    01677       /**
    01678        *  @brief  Internal constructor.  Not for general use.
    01679        *
    01680        *  This is a constructor for use by the library itself to set up new
    01681        *  locales.
    01682        *
    01683        *  @param  cloc  The "C" locale.
    01684        *  @param  refs  Refcount to pass to the base class.
    01685        */
    01686       explicit
    01687       numpunct(__c_locale __cloc, size_t __refs = 0)
    01688       : facet(__refs), _M_data(NULL)
    01689       { _M_initialize_numpunct(__cloc); }
    01690
    01691       /**
    01692        *  @brief  Return decimal point character.
    01693        *
    01694        *  This function returns a char_type to use as a decimal point.  It
    01695        *  does so by returning returning
    01696        *  numpunct<char_type>::do_decimal_point().
    01697        *
    01698        *  @return  @a char_type representing a decimal point.
    01699       */
    01700       char_type
    01701       decimal_point() const
    01702       { return this->do_decimal_point(); }
    01703
    01704       /**
    01705        *  @brief  Return thousands separator character.
    01706        *
    01707        *  This function returns a char_type to use as a thousands
    01708        *  separator.  It does so by returning returning
    01709        *  numpunct<char_type>::do_thousands_sep().
    01710        *
    01711        *  @return  char_type representing a thousands separator.
    01712       */
    01713       char_type
    01714       thousands_sep() const
    01715       { return this->do_thousands_sep(); }
    01716
    01717       /**
    01718        *  @brief  Return grouping specification.
    01719        *
    01720        *  This function returns a string representing groupings for the
    01721        *  integer part of a number.  Groupings indicate where thousands
    01722        *  separators should be inserted in the integer part of a number.
    01723        *
    01724        *  Each char in the return string is interpret as an integer
    01725        *  rather than a character.  These numbers represent the number
    01726        *  of digits in a group.  The first char in the string
    01727        *  represents the number of digits in the least significant
    01728        *  group.  If a char is negative, it indicates an unlimited
    01729        *  number of digits for the group.  If more chars from the
    01730        *  string are required to group a number, the last char is used
    01731        *  repeatedly.
    01732        *
    01733        *  For example, if the grouping() returns "\003\002" and is
    01734        *  applied to the number 123456789, this corresponds to
    01735        *  12,34,56,789.  Note that if the string was "32", this would
    01736        *  put more than 50 digits into the least significant group if
    01737        *  the character set is ASCII.
    01738        *
    01739        *  The string is returned by calling
    01740        *  numpunct<char_type>::do_grouping().
    01741        *
    01742        *  @return  string representing grouping specification.
    01743       */
    01744       string
    01745       grouping() const
    01746       { return this->do_grouping(); }
    01747
    01748       /**
    01749        *  @brief  Return string representation of bool true.
    01750        *
    01751        *  This function returns a string_type containing the text
    01752        *  representation for true bool variables.  It does so by calling
    01753        *  numpunct<char_type>::do_truename().
    01754        *
    01755        *  @return  string_type representing printed form of true.
    01756       */
    01757       string_type
    01758       truename() const
    01759       { return this->do_truename(); }
    01760
    01761       /**
    01762        *  @brief  Return string representation of bool false.
    01763        *
    01764        *  This function returns a string_type containing the text
    01765        *  representation for false bool variables.  It does so by calling
    01766        *  numpunct<char_type>::do_falsename().
    01767        *
    01768        *  @return  string_type representing printed form of false.
    01769       */
    01770       string_type
    01771       falsename() const
    01772       { return this->do_falsename(); }
    01773
    01774     protected:
    01775       /// Destructor.
    01776       virtual
    01777       ~numpunct();
    01778
    01779       /**
    01780        *  @brief  Return decimal point character.
    01781        *
    01782        *  Returns a char_type to use as a decimal point.  This function is a
    01783        *  hook for derived classes to change the value returned.
    01784        *
    01785        *  @return  @a char_type representing a decimal point.
    01786       */
    01787       virtual char_type
    01788       do_decimal_point() const
    01789       { return _M_data->_M_decimal_point; }
    01790
    01791       /**
    01792        *  @brief  Return thousands separator character.
    01793        *
    01794        *  Returns a char_type to use as a thousands separator.  This function
    01795        *  is a hook for derived classes to change the value returned.
    01796        *
    01797        *  @return  @a char_type representing a thousands separator.
    01798       */
    01799       virtual char_type
    01800       do_thousands_sep() const
    01801       { return _M_data->_M_thousands_sep; }
    01802
    01803       /**
    01804        *  @brief  Return grouping specification.
    01805        *
    01806        *  Returns a string representing groupings for the integer part of a
    01807        *  number.  This function is a hook for derived classes to change the
    01808        *  value returned.  @see grouping() for details.
    01809        *
    01810        *  @return  String representing grouping specification.
    01811       */
    01812       virtual string
    01813       do_grouping() const
    01814       { return _M_data->_M_grouping; }
    01815
    01816       /**
    01817        *  @brief  Return string representation of bool true.
    01818        *
    01819        *  Returns a string_type containing the text representation for true
    01820        *  bool variables.  This function is a hook for derived classes to
    01821        *  change the value returned.
    01822        *
    01823        *  @return  string_type representing printed form of true.
    01824       */
    01825       virtual string_type
    01826       do_truename() const
    01827       { return _M_data->_M_truename; }
    01828
    01829       /**
    01830        *  @brief  Return string representation of bool false.
    01831        *
    01832        *  Returns a string_type containing the text representation for false
    01833        *  bool variables.  This function is a hook for derived classes to
    01834        *  change the value returned.
    01835        *
    01836        *  @return  string_type representing printed form of false.
    01837       */
    01838       virtual string_type
    01839       do_falsename() const
    01840       { return _M_data->_M_falsename; }
    01841
    01842       // For use at construction time only.
    01843       void
    01844       _M_initialize_numpunct(__c_locale __cloc = NULL);
    01845     };
    01846
    01847   template<typename _CharT>
    01848     locale::id numpunct<_CharT>::id;
    01849
    01850   template<>
    01851     numpunct<char>::~numpunct();
    01852
    01853   template<>
    01854     void
    01855     numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
    01856
    01857 #ifdef _GLIBCXX_USE_WCHAR_T
    01858   template<>
    01859     numpunct<wchar_t>::~numpunct();
    01860
    01861   template<>
    01862     void
    01863     numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
    01864 #endif
    01865
    01866   /// class numpunct_byname [22.2.3.2].
    01867   template<typename _CharT>
    01868     class numpunct_byname : public numpunct<_CharT>
    01869     {
    01870     public:
    01871       typedef _CharT            char_type;
    01872       typedef basic_string<_CharT>  string_type;
    01873
    01874       explicit
    01875       numpunct_byname(const char* __s, size_t __refs = 0)
    01876       : numpunct<_CharT>(__refs)
    01877       {
    01878     if (__builtin_strcmp(__s, "C") != 0
    01879         && __builtin_strcmp(__s, "POSIX") != 0)
    01880       {
    01881         __c_locale __tmp;
    01882         this->_S_create_c_locale(__tmp, __s);
    01883         this->_M_initialize_numpunct(__tmp);
    01884         this->_S_destroy_c_locale(__tmp);
    01885       }
    01886       }
    01887
    01888     protected:
    01889       virtual
    01890       ~numpunct_byname() { }
    01891     };
    01892
    01893 _GLIBCXX_BEGIN_LDBL_NAMESPACE
    01894
    01895   /**
    01896    *  @brief  Facet for parsing number strings.
    01897    *
    01898    *  This facet encapsulates the code to parse and return a number
    01899    *  from a string.  It is used by the istream numeric extraction
    01900    *  operators.
    01901    *
    01902    *  The num_get template uses protected virtual functions to provide the
    01903    *  actual results.  The public accessors forward the call to the virtual
    01904    *  functions.  These virtual functions are hooks for developers to
    01905    *  implement the behavior they require from the num_get facet.
    01906   */
    01907   template<typename _CharT, typename _InIter>
    01908     class num_get : public locale::facet
    01909     {
    01910     public:
    01911       // Types:
    01912       //@{
    01913       /// Public typedefs
    01914       typedef _CharT            char_type;
    01915       typedef _InIter           iter_type;
    01916       //@}
    01917
    01918       /// Numpunct facet id.
    01919       static locale::id         id;
    01920
    01921       /**
    01922        *  @brief  Constructor performs initialization.
    01923        *
    01924        *  This is the constructor provided by the standard.
    01925        *
    01926        *  @param refs  Passed to the base facet class.
    01927       */
    01928       explicit
    01929       num_get(size_t __refs = 0) : facet(__refs) { }
    01930
    01931       /**
    01932        *  @brief  Numeric parsing.
    01933        *
    01934        *  Parses the input stream into the bool @a v.  It does so by calling
    01935        *  num_get::do_get().
    01936        *
    01937        *  If ios_base::boolalpha is set, attempts to read
    01938        *  ctype<CharT>::truename() or ctype<CharT>::falsename().  Sets
    01939        *  @a v to true or false if successful.  Sets err to
    01940        *  ios_base::failbit if reading the string fails.  Sets err to
    01941        *  ios_base::eofbit if the stream is emptied.
    01942        *
    01943        *  If ios_base::boolalpha is not set, proceeds as with reading a long,
    01944        *  except if the value is 1, sets @a v to true, if the value is 0, sets
    01945        *  @a v to false, and otherwise set err to ios_base::failbit.
    01946        *
    01947        *  @param  in  Start of input stream.
    01948        *  @param  end  End of input stream.
    01949        *  @param  io  Source of locale and flags.
    01950        *  @param  err  Error flags to set.
    01951        *  @param  v  Value to format and insert.
    01952        *  @return  Iterator after reading.
    01953       */
    01954       iter_type
    01955       get(iter_type __in, iter_type __end, ios_base& __io,
    01956       ios_base::iostate& __err, bool& __v) const
    01957       { return this->do_get(__in, __end, __io, __err, __v); }
    01958
    01959       //@{
    01960       /**
    01961        *  @brief  Numeric parsing.
    01962        *
    01963        *  Parses the input stream into the integral variable @a v.  It does so
    01964        *  by calling num_get::do_get().
    01965        *
    01966        *  Parsing is affected by the flag settings in @a io.
    01967        *
    01968        *  The basic parse is affected by the value of io.flags() &
    01969        *  ios_base::basefield.  If equal to ios_base::oct, parses like the
    01970        *  scanf %o specifier.  Else if equal to ios_base::hex, parses like %X
    01971        *  specifier.  Else if basefield equal to 0, parses like the %i
    01972        *  specifier.  Otherwise, parses like %d for signed and %u for unsigned
    01973        *  types.  The matching type length modifier is also used.
    01974        *
    01975        *  Digit grouping is interpreted according to numpunct::grouping() and
    01976        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
    01977        *  consistent, sets err to ios_base::failbit.
    01978        *
    01979        *  If parsing the string yields a valid value for @a v, @a v is set.
    01980        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
    01981        *  Sets err to ios_base::eofbit if the stream is emptied.
    01982        *
    01983        *  @param  in  Start of input stream.
    01984        *  @param  end  End of input stream.
    01985        *  @param  io  Source of locale and flags.
    01986        *  @param  err  Error flags to set.
    01987        *  @param  v  Value to format and insert.
    01988        *  @return  Iterator after reading.
    01989       */
    01990       iter_type
    01991       get(iter_type __in, iter_type __end, ios_base& __io,
    01992       ios_base::iostate& __err, long& __v) const
    01993       { return this->do_get(__in, __end, __io, __err, __v); }
    01994
    01995       iter_type
    01996       get(iter_type __in, iter_type __end, ios_base& __io,
    01997       ios_base::iostate& __err, unsigned short& __v) const
    01998       { return this->do_get(__in, __end, __io, __err, __v); }
    01999
    02000       iter_type
    02001       get(iter_type __in, iter_type __end, ios_base& __io,
    02002       ios_base::iostate& __err, unsigned int& __v)   const
    02003       { return this->do_get(__in, __end, __io, __err, __v); }
    02004
    02005       iter_type
    02006       get(iter_type __in, iter_type __end, ios_base& __io,
    02007       ios_base::iostate& __err, unsigned long& __v)  const
    02008       { return this->do_get(__in, __end, __io, __err, __v); }
    02009
    02010 #ifdef _GLIBCXX_USE_LONG_LONG
    02011       iter_type
    02012       get(iter_type __in, iter_type __end, ios_base& __io,
    02013       ios_base::iostate& __err, long long& __v) const
    02014       { return this->do_get(__in, __end, __io, __err, __v); }
    02015
    02016       iter_type
    02017       get(iter_type __in, iter_type __end, ios_base& __io,
    02018       ios_base::iostate& __err, unsigned long long& __v)  const
    02019       { return this->do_get(__in, __end, __io, __err, __v); }
    02020 #endif
    02021       //@}
    02022
    02023       //@{
    02024       /**
    02025        *  @brief  Numeric parsing.
    02026        *
    02027        *  Parses the input stream into the integral variable @a v.  It does so
    02028        *  by calling num_get::do_get().
    02029        *
    02030        *  The input characters are parsed like the scanf %g specifier.  The
    02031        *  matching type length modifier is also used.
    02032        *
    02033        *  The decimal point character used is numpunct::decimal_point().
    02034        *  Digit grouping is interpreted according to numpunct::grouping() and
    02035        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
    02036        *  consistent, sets err to ios_base::failbit.
    02037        *
    02038        *  If parsing the string yields a valid value for @a v, @a v is set.
    02039        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
    02040        *  Sets err to ios_base::eofbit if the stream is emptied.
    02041        *
    02042        *  @param  in  Start of input stream.
    02043        *  @param  end  End of input stream.
    02044        *  @param  io  Source of locale and flags.
    02045        *  @param  err  Error flags to set.
    02046        *  @param  v  Value to format and insert.
    02047        *  @return  Iterator after reading.
    02048       */
    02049       iter_type
    02050       get(iter_type __in, iter_type __end, ios_base& __io,
    02051       ios_base::iostate& __err, float& __v) const
    02052       { return this->do_get(__in, __end, __io, __err, __v); }
    02053
    02054       iter_type
    02055       get(iter_type __in, iter_type __end, ios_base& __io,
    02056       ios_base::iostate& __err, double& __v) const
    02057       { return this->do_get(__in, __end, __io, __err, __v); }
    02058
    02059       iter_type
    02060       get(iter_type __in, iter_type __end, ios_base& __io,
    02061       ios_base::iostate& __err, long double& __v) const
    02062       { return this->do_get(__in, __end, __io, __err, __v); }
    02063       //@}
    02064
    02065       /**
    02066        *  @brief  Numeric parsing.
    02067        *
    02068        *  Parses the input stream into the pointer variable @a v.  It does so
    02069        *  by calling num_get::do_get().
    02070        *
    02071        *  The input characters are parsed like the scanf %p specifier.
    02072        *
    02073        *  Digit grouping is interpreted according to numpunct::grouping() and
    02074        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
    02075        *  consistent, sets err to ios_base::failbit.
    02076        *
    02077        *  Note that the digit grouping effect for pointers is a bit ambiguous
    02078        *  in the standard and shouldn't be relied on.  See DR 344.
    02079        *
    02080        *  If parsing the string yields a valid value for @a v, @a v is set.
    02081        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
    02082        *  Sets err to ios_base::eofbit if the stream is emptied.
    02083        *
    02084        *  @param  in  Start of input stream.
    02085        *  @param  end  End of input stream.
    02086        *  @param  io  Source of locale and flags.
    02087        *  @param  err  Error flags to set.
    02088        *  @param  v  Value to format and insert.
    02089        *  @return  Iterator after reading.
    02090       */
    02091       iter_type
    02092       get(iter_type __in, iter_type __end, ios_base& __io,
    02093       ios_base::iostate& __err, void*& __v) const
    02094       { return this->do_get(__in, __end, __io, __err, __v); }
    02095
    02096     protected:
    02097       /// Destructor.
    02098       virtual ~num_get() { }
    02099
    02100       iter_type
    02101       _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
    02102                string&) const;
    02103
    02104       template<typename _ValueT>
    02105         iter_type
    02106         _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
    02107                _ValueT&) const;
    02108
    02109       template<typename _CharT2>
    02110       typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, int>::__type
    02111         _M_find(const _CharT2*, size_t __len, _CharT2 __c) const
    02112         {
    02113       int __ret = -1;
    02114       if (__len <= 10)
    02115         {
    02116           if (__c >= _CharT2('0') && __c < _CharT2(_CharT2('0') + __len))
    02117         __ret = __c - _CharT2('0');
    02118         }
    02119       else
    02120         {
    02121           if (__c >= _CharT2('0') && __c <= _CharT2('9'))
    02122         __ret = __c - _CharT2('0');
    02123           else if (__c >= _CharT2('a') && __c <= _CharT2('f'))
    02124         __ret = 10 + (__c - _CharT2('a'));
    02125           else if (__c >= _CharT2('A') && __c <= _CharT2('F'))
    02126         __ret = 10 + (__c - _CharT2('A'));
    02127         }
    02128       return __ret;
    02129     }
    02130
    02131       template<typename _CharT2>
    02132       typename __gnu_cxx::__enable_if<!__is_char<_CharT2>::__value,
    02133                       int>::__type
    02134         _M_find(const _CharT2* __zero, size_t __len, _CharT2 __c) const
    02135         {
    02136       int __ret = -1;
    02137       const char_type* __q = char_traits<_CharT2>::find(__zero, __len, __c);
    02138       if (__q)
    02139         {
    02140           __ret = __q - __zero;
    02141           if (__ret > 15)
    02142         __ret -= 6;
    02143         }
    02144       return __ret;
    02145     }
    02146
    02147       //@{
    02148       /**
    02149        *  @brief  Numeric parsing.
    02150        *
    02151        *  Parses the input stream into the variable @a v.  This function is a
    02152        *  hook for derived classes to change the value returned.  @see get()
    02153        *  for more details.
    02154        *
    02155        *  @param  in  Start of input stream.
    02156        *  @param  end  End of input stream.
    02157        *  @param  io  Source of locale and flags.
    02158        *  @param  err  Error flags to set.
    02159        *  @param  v  Value to format and insert.
    02160        *  @return  Iterator after reading.
    02161       */
    02162       virtual iter_type
    02163       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
    02164
    02165       virtual iter_type
    02166       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    02167          ios_base::iostate& __err, long& __v) const
    02168       { return _M_extract_int(__beg, __end, __io, __err, __v); }
    02169
    02170       virtual iter_type
    02171       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    02172          ios_base::iostate& __err, unsigned short& __v) const
    02173       { return _M_extract_int(__beg, __end, __io, __err, __v); }
    02174
    02175       virtual iter_type
    02176       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    02177          ios_base::iostate& __err, unsigned int& __v) const
    02178       { return _M_extract_int(__beg, __end, __io, __err, __v); }
    02179
    02180       virtual iter_type
    02181       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    02182          ios_base::iostate& __err, unsigned long& __v) const
    02183       { return _M_extract_int(__beg, __end, __io, __err, __v); }
    02184
    02185 #ifdef _GLIBCXX_USE_LONG_LONG
    02186       virtual iter_type
    02187       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    02188          ios_base::iostate& __err, long long& __v) const
    02189       { return _M_extract_int(__beg, __end, __io, __err, __v); }
    02190
    02191       virtual iter_type
    02192       do_get(iter_type __beg, iter_type __end, ios_base& __io,
    02193          ios_base::iostate& __err, unsigned long long& __v) const
    02194       { return _M_extract_int(__beg, __end, __io, __err, __v); }
    02195 #endif
    02196
    02197       virtual iter_type
    02198       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02199          float&) const;
    02200
    02201       virtual iter_type
    02202       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02203          double&) const;
    02204
    02205       // XXX GLIBCXX_ABI Deprecated
    02206 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    02207       virtual iter_type
    02208       __do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02209            double&) const;
    02210 #else
    02211       virtual iter_type
    02212       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02213          long double&) const;
    02214 #endif
    02215
    02216       virtual iter_type
    02217       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02218          void*&) const;
    02219
    02220       // XXX GLIBCXX_ABI Deprecated
    02221 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    02222       virtual iter_type
    02223       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02224          long double&) const;
    02225 #endif
    02226       //@}
    02227     };
    02228
    02229   template<typename _CharT, typename _InIter>
    02230     locale::id num_get<_CharT, _InIter>::id;
    02231
    02232
    02233   /**
    02234    *  @brief  Facet for converting numbers to strings.
    02235    *
    02236    *  This facet encapsulates the code to convert a number to a string.  It is
    02237    *  used by the ostream numeric insertion operators.
    02238    *
    02239    *  The num_put template uses protected virtual functions to provide the
    02240    *  actual results.  The public accessors forward the call to the virtual
    02241    *  functions.  These virtual functions are hooks for developers to
    02242    *  implement the behavior they require from the num_put facet.
    02243   */
    02244   template<typename _CharT, typename _OutIter>
    02245     class num_put : public locale::facet
    02246     {
    02247     public:
    02248       // Types:
    02249       //@{
    02250       /// Public typedefs
    02251       typedef _CharT        char_type;
    02252       typedef _OutIter      iter_type;
    02253       //@}
    02254
    02255       /// Numpunct facet id.
    02256       static locale::id     id;
    02257
    02258       /**
    02259        *  @brief  Constructor performs initialization.
    02260        *
    02261        *  This is the constructor provided by the standard.
    02262        *
    02263        *  @param refs  Passed to the base facet class.
    02264       */
    02265       explicit
    02266       num_put(size_t __refs = 0) : facet(__refs) { }
    02267
    02268       /**
    02269        *  @brief  Numeric formatting.
    02270        *
    02271        *  Formats the boolean @a v and inserts it into a stream.  It does so
    02272        *  by calling num_put::do_put().
    02273        *
    02274        *  If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
    02275        *  ctype<CharT>::falsename().  Otherwise formats @a v as an int.
    02276        *
    02277        *  @param  s  Stream to write to.
    02278        *  @param  io  Source of locale and flags.
    02279        *  @param  fill  Char_type to use for filling.
    02280        *  @param  v  Value to format and insert.
    02281        *  @return  Iterator after writing.
    02282       */
    02283       iter_type
    02284       put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const
    02285       { return this->do_put(__s, __f, __fill, __v); }
    02286
    02287       //@{
    02288       /**
    02289        *  @brief  Numeric formatting.
    02290        *
    02291        *  Formats the integral value @a v and inserts it into a
    02292        *  stream.  It does so by calling num_put::do_put().
    02293        *
    02294        *  Formatting is affected by the flag settings in @a io.
    02295        *
    02296        *  The basic format is affected by the value of io.flags() &
    02297        *  ios_base::basefield.  If equal to ios_base::oct, formats like the
    02298        *  printf %o specifier.  Else if equal to ios_base::hex, formats like
    02299        *  %x or %X with ios_base::uppercase unset or set respectively.
    02300        *  Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
    02301        *  for unsigned values.  Note that if both oct and hex are set, neither
    02302        *  will take effect.
    02303        *
    02304        *  If ios_base::showpos is set, '+' is output before positive values.
    02305        *  If ios_base::showbase is set, '0' precedes octal values (except 0)
    02306        *  and '0[xX]' precedes hex values.
    02307        *
    02308        *  Thousands separators are inserted according to numpunct::grouping()
    02309        *  and numpunct::thousands_sep().  The decimal point character used is
    02310        *  numpunct::decimal_point().
    02311        *
    02312        *  If io.width() is non-zero, enough @a fill characters are inserted to
    02313        *  make the result at least that wide.  If
    02314        *  (io.flags() & ios_base::adjustfield) == ios_base::left, result is
    02315        *  padded at the end.  If ios_base::internal, then padding occurs
    02316        *  immediately after either a '+' or '-' or after '0x' or '0X'.
    02317        *  Otherwise, padding occurs at the beginning.
    02318        *
    02319        *  @param  s  Stream to write to.
    02320        *  @param  io  Source of locale and flags.
    02321        *  @param  fill  Char_type to use for filling.
    02322        *  @param  v  Value to format and insert.
    02323        *  @return  Iterator after writing.
    02324       */
    02325       iter_type
    02326       put(iter_type __s, ios_base& __f, char_type __fill, long __v) const
    02327       { return this->do_put(__s, __f, __fill, __v); }
    02328
    02329       iter_type
    02330       put(iter_type __s, ios_base& __f, char_type __fill,
    02331       unsigned long __v) const
    02332       { return this->do_put(__s, __f, __fill, __v); }
    02333
    02334 #ifdef _GLIBCXX_USE_LONG_LONG
    02335       iter_type
    02336       put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const
    02337       { return this->do_put(__s, __f, __fill, __v); }
    02338
    02339       iter_type
    02340       put(iter_type __s, ios_base& __f, char_type __fill,
    02341       unsigned long long __v) const
    02342       { return this->do_put(__s, __f, __fill, __v); }
    02343 #endif
    02344       //@}
    02345
    02346       //@{
    02347       /**
    02348        *  @brief  Numeric formatting.
    02349        *
    02350        *  Formats the floating point value @a v and inserts it into a stream.
    02351        *  It does so by calling num_put::do_put().
    02352        *
    02353        *  Formatting is affected by the flag settings in @a io.
    02354        *
    02355        *  The basic format is affected by the value of io.flags() &
    02356        *  ios_base::floatfield.  If equal to ios_base::fixed, formats like the
    02357        *  printf %f specifier.  Else if equal to ios_base::scientific, formats
    02358        *  like %e or %E with ios_base::uppercase unset or set respectively.
    02359        *  Otherwise, formats like %g or %G depending on uppercase.  Note that
    02360        *  if both fixed and scientific are set, the effect will also be like
    02361        *  %g or %G.
    02362        *
    02363        *  The output precision is given by io.precision().  This precision is
    02364        *  capped at numeric_limits::digits10 + 2 (different for double and
    02365        *  long double).  The default precision is 6.
    02366        *
    02367        *  If ios_base::showpos is set, '+' is output before positive values.
    02368        *  If ios_base::showpoint is set, a decimal point will always be
    02369        *  output.
    02370        *
    02371        *  Thousands separators are inserted according to numpunct::grouping()
    02372        *  and numpunct::thousands_sep().  The decimal point character used is
    02373        *  numpunct::decimal_point().
    02374        *
    02375        *  If io.width() is non-zero, enough @a fill characters are inserted to
    02376        *  make the result at least that wide.  If
    02377        *  (io.flags() & ios_base::adjustfield) == ios_base::left, result is
    02378        *  padded at the end.  If ios_base::internal, then padding occurs
    02379        *  immediately after either a '+' or '-' or after '0x' or '0X'.
    02380        *  Otherwise, padding occurs at the beginning.
    02381        *
    02382        *  @param  s  Stream to write to.
    02383        *  @param  io  Source of locale and flags.
    02384        *  @param  fill  Char_type to use for filling.
    02385        *  @param  v  Value to format and insert.
    02386        *  @return  Iterator after writing.
    02387       */
    02388       iter_type
    02389       put(iter_type __s, ios_base& __f, char_type __fill, double __v) const
    02390       { return this->do_put(__s, __f, __fill, __v); }
    02391
    02392       iter_type
    02393       put(iter_type __s, ios_base& __f, char_type __fill,
    02394       long double __v) const
    02395       { return this->do_put(__s, __f, __fill, __v); }
    02396       //@}
    02397
    02398       /**
    02399        *  @brief  Numeric formatting.
    02400        *
    02401        *  Formats the pointer value @a v and inserts it into a stream.  It
    02402        *  does so by calling num_put::do_put().
    02403        *
    02404        *  This function formats @a v as an unsigned long with ios_base::hex
    02405        *  and ios_base::showbase set.
    02406        *
    02407        *  @param  s  Stream to write to.
    02408        *  @param  io  Source of locale and flags.
    02409        *  @param  fill  Char_type to use for filling.
    02410        *  @param  v  Value to format and insert.
    02411        *  @return  Iterator after writing.
    02412       */
    02413       iter_type
    02414       put(iter_type __s, ios_base& __f, char_type __fill,
    02415       const void* __v) const
    02416       { return this->do_put(__s, __f, __fill, __v); }
    02417
    02418     protected:
    02419       template<typename _ValueT>
    02420         iter_type
    02421         _M_insert_float(iter_type, ios_base& __io, char_type __fill,
    02422             char __mod, _ValueT __v) const;
    02423
    02424       void
    02425       _M_group_float(const char* __grouping, size_t __grouping_size,
    02426              char_type __sep, const char_type* __p, char_type* __new,
    02427              char_type* __cs, int& __len) const;
    02428
    02429       template<typename _ValueT>
    02430         iter_type
    02431         _M_insert_int(iter_type, ios_base& __io, char_type __fill,
    02432               _ValueT __v) const;
    02433
    02434       void
    02435       _M_group_int(const char* __grouping, size_t __grouping_size,
    02436            char_type __sep, ios_base& __io, char_type* __new,
    02437            char_type* __cs, int& __len) const;
    02438
    02439       void
    02440       _M_pad(char_type __fill, streamsize __w, ios_base& __io,
    02441          char_type* __new, const char_type* __cs, int& __len) const;
    02442
    02443       /// Destructor.
    02444       virtual
    02445       ~num_put() { };
    02446
    02447       //@{
    02448       /**
    02449        *  @brief  Numeric formatting.
    02450        *
    02451        *  These functions do the work of formatting numeric values and
    02452        *  inserting them into a stream. This function is a hook for derived
    02453        *  classes to change the value returned.
    02454        *
    02455        *  @param  s  Stream to write to.
    02456        *  @param  io  Source of locale and flags.
    02457        *  @param  fill  Char_type to use for filling.
    02458        *  @param  v  Value to format and insert.
    02459        *  @return  Iterator after writing.
    02460       */
    02461       virtual iter_type
    02462       do_put(iter_type, ios_base&, char_type __fill, bool __v) const;
    02463
    02464       virtual iter_type
    02465       do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
    02466       { return _M_insert_int(__s, __io, __fill, __v); }
    02467
    02468       virtual iter_type
    02469       do_put(iter_type __s, ios_base& __io, char_type __fill,
    02470          unsigned long __v) const
    02471       { return _M_insert_int(__s, __io, __fill, __v); }
    02472
    02473 #ifdef _GLIBCXX_USE_LONG_LONG
    02474       virtual iter_type
    02475       do_put(iter_type __s, ios_base& __io, char_type __fill,
    02476          long long __v) const
    02477       { return _M_insert_int(__s, __io, __fill, __v); }
    02478
    02479       virtual iter_type
    02480       do_put(iter_type __s, ios_base& __io, char_type __fill,
    02481          unsigned long long __v) const
    02482       { return _M_insert_int(__s, __io, __fill, __v); }
    02483 #endif
    02484
    02485       virtual iter_type
    02486       do_put(iter_type, ios_base&, char_type __fill, double __v) const;
    02487
    02488       // XXX GLIBCXX_ABI Deprecated
    02489 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    02490       virtual iter_type
    02491       __do_put(iter_type, ios_base&, char_type __fill, double __v) const;
    02492 #else
    02493       virtual iter_type
    02494       do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
    02495 #endif
    02496
    02497       virtual iter_type
    02498       do_put(iter_type, ios_base&, char_type __fill, const void* __v) const;
    02499
    02500       // XXX GLIBCXX_ABI Deprecated
    02501 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    02502       virtual iter_type
    02503       do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
    02504 #endif
    02505       //@}
    02506     };
    02507
    02508   template <typename _CharT, typename _OutIter>
    02509     locale::id num_put<_CharT, _OutIter>::id;
    02510
    02511 _GLIBCXX_END_LDBL_NAMESPACE
    02512
    02513   // Subclause convenience interfaces, inlines.
    02514   // NB: These are inline because, when used in a loop, some compilers
    02515   // can hoist the body out of the loop; then it's just as fast as the
    02516   // C is*() function.
    02517
    02518   /// Convenience interface to ctype.is(ctype_base::space, __c).
    02519   template<typename _CharT>
    02520     inline bool
    02521     isspace(_CharT __c, const locale& __loc)
    02522     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
    02523
    02524   /// Convenience interface to ctype.is(ctype_base::print, __c).
    02525   template<typename _CharT>
    02526     inline bool
    02527     isprint(_CharT __c, const locale& __loc)
    02528     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
    02529
    02530   /// Convenience interface to ctype.is(ctype_base::cntrl, __c).
    02531   template<typename _CharT>
    02532     inline bool
    02533     iscntrl(_CharT __c, const locale& __loc)
    02534     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
    02535
    02536   /// Convenience interface to ctype.is(ctype_base::upper, __c).
    02537   template<typename _CharT>
    02538     inline bool
    02539     isupper(_CharT __c, const locale& __loc)
    02540     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
    02541
    02542   /// Convenience interface to ctype.is(ctype_base::lower, __c).
    02543   template<typename _CharT>
    02544     inline bool
    02545     islower(_CharT __c, const locale& __loc)
    02546     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
    02547
    02548   /// Convenience interface to ctype.is(ctype_base::alpha, __c).
    02549   template<typename _CharT>
    02550     inline bool
    02551     isalpha(_CharT __c, const locale& __loc)
    02552     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
    02553
    02554   /// Convenience interface to ctype.is(ctype_base::digit, __c).
    02555   template<typename _CharT>
    02556     inline bool
    02557     isdigit(_CharT __c, const locale& __loc)
    02558     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
    02559
    02560   /// Convenience interface to ctype.is(ctype_base::punct, __c).
    02561   template<typename _CharT>
    02562     inline bool
    02563     ispunct(_CharT __c, const locale& __loc)
    02564     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
    02565
    02566   /// Convenience interface to ctype.is(ctype_base::xdigit, __c).
    02567   template<typename _CharT>
    02568     inline bool
    02569     isxdigit(_CharT __c, const locale& __loc)
    02570     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
    02571
    02572   /// Convenience interface to ctype.is(ctype_base::alnum, __c).
    02573   template<typename _CharT>
    02574     inline bool
    02575     isalnum(_CharT __c, const locale& __loc)
    02576     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
    02577
    02578   /// Convenience interface to ctype.is(ctype_base::graph, __c).
    02579   template<typename _CharT>
    02580     inline bool
    02581     isgraph(_CharT __c, const locale& __loc)
    02582     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
    02583
    02584   /// Convenience interface to ctype.toupper(__c).
    02585   template<typename _CharT>
    02586     inline _CharT
    02587     toupper(_CharT __c, const locale& __loc)
    02588     { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
    02589
    02590   /// Convenience interface to ctype.tolower(__c).
    02591   template<typename _CharT>
    02592     inline _CharT
    02593     tolower(_CharT __c, const locale& __loc)
    02594     { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
    02595
    02596 _GLIBCXX_END_NAMESPACE
    02597
    02598 #ifndef _GLIBCXX_EXPORT_TEMPLATE
    02599 # include <bits/locale_facets.tcc>
    02600 #endif
    02601
    02602 #endif