locale_facets.tcc

00001 // Locale support -*- C++ -*-
00002 
00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
00004 // Free Software Foundation, Inc.
00005 //
00006 // This file is part of the GNU ISO C++ Library.  This library is free
00007 // software; you can redistribute it and/or modify it under the
00008 // terms of the GNU General Public License as published by the
00009 // Free Software Foundation; either version 2, or (at your option)
00010 // any later version.
00011 
00012 // This library is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 
00017 // You should have received a copy of the GNU General Public License along
00018 // with this library; see the file COPYING.  If not, write to the Free
00019 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00020 // USA.
00021 
00022 // As a special exception, you may use this file as part of a free software
00023 // library without restriction.  Specifically, if other files instantiate
00024 // templates or use macros or inline functions from this file, or you compile
00025 // this file and link it with other files to produce an executable, this
00026 // file does not by itself cause the resulting executable to be covered by
00027 // the GNU General Public License.  This exception does not however
00028 // invalidate any other reasons why the executable file might be covered by
00029 // the GNU General Public License.
00030 
00031 // Warning: this file is not meant for user inclusion. Use <locale>.
00032 
00033 #ifndef _CPP_BITS_LOCFACETS_TCC
00034 #define _CPP_BITS_LOCFACETS_TCC 1
00035 
00036 #pragma GCC system_header
00037 
00038 #include <cerrno>
00039 #include <clocale>          // For localeconv
00040 #include <cstdlib>          // For strof, strtold
00041 #include <cmath>            // For ceil
00042 #include <cctype>           // For isspace
00043 #include <limits>           // For numeric_limits
00044 #include <typeinfo>         // For bad_cast.
00045 #include <bits/streambuf_iterator.h>
00046 
00047 namespace std
00048 {
00049   template<typename _Facet>
00050     locale
00051     locale::combine(const locale& __other) const
00052     {
00053       _Impl* __tmp = new _Impl(*_M_impl, 1);
00054       try
00055     {
00056       __tmp->_M_replace_facet(__other._M_impl, &_Facet::id);
00057     }
00058       catch(...)
00059     {
00060       __tmp->_M_remove_reference();
00061       __throw_exception_again;
00062     }
00063       return locale(__tmp);
00064     }
00065 
00066   template<typename _CharT, typename _Traits, typename _Alloc>
00067     bool
00068     locale::operator()(const basic_string<_CharT, _Traits, _Alloc>& __s1,
00069                        const basic_string<_CharT, _Traits, _Alloc>& __s2) const
00070     {
00071       typedef std::collate<_CharT> __collate_type;
00072       const __collate_type& __collate = use_facet<__collate_type>(*this);
00073       return (__collate.compare(__s1.data(), __s1.data() + __s1.length(),
00074                 __s2.data(), __s2.data() + __s2.length()) < 0);
00075     }
00076 
00077   template<typename _Facet>
00078     const _Facet&
00079     use_facet(const locale& __loc)
00080     {
00081       size_t __i = _Facet::id._M_id();
00082       locale::facet** __facets = __loc._M_impl->_M_facets;
00083       if (!(__i < __loc._M_impl->_M_facets_size && __facets[__i]))
00084         __throw_bad_cast();
00085       return static_cast<const _Facet&>(*__facets[__i]);
00086     }
00087 
00088   template<typename _Facet>
00089     bool
00090     has_facet(const locale& __loc) throw()
00091     {
00092       size_t __i = _Facet::id._M_id();
00093       locale::facet** __facets = __loc._M_impl->_M_facets;
00094       return (__i < __loc._M_impl->_M_facets_size && __facets[__i]);
00095     }
00096 
00097   // Routine to access a cache for the locale.  If the cache didn't
00098   // exist before, it gets constructed on the fly.
00099   template<typename _Facet>
00100     inline const __locale_cache<_Facet>&
00101     __use_cache(const locale& __loc)
00102     {
00103       size_t __i = _Facet::id._M_id();
00104       if (__builtin_expect(__i >= __loc._M_impl->_M_facets_size,false))
00105     __throw_bad_cast();
00106       __locale_cache_base* __cache = __loc._M_impl->_M_get_cache(__i);
00107       if (__builtin_expect(!__cache, false))
00108     {
00109       __cache = new __locale_cache<_Facet>(__loc);
00110       __loc._M_impl->_M_install_cache(__cache, __i);
00111     }
00112       return static_cast<const __locale_cache<_Facet>&>(*__cache);
00113     }
00114 
00115   // Stage 1: Determine a conversion specifier.
00116   template<typename _CharT, typename _InIter>
00117     _InIter
00118     num_get<_CharT, _InIter>::
00119     _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io,
00120              ios_base::iostate& __err, string& __xtrc) const
00121     {
00122       typedef char_traits<_CharT>       __traits_type;
00123       const locale __loc = __io.getloc();
00124       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
00125       const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
00126 
00127       // First check for sign.
00128       const char_type __plus = __ctype.widen('+');
00129       const char_type __minus = __ctype.widen('-');
00130       int __pos = 0;
00131       char_type  __c = *__beg;
00132       if ((__traits_type::eq(__c, __plus) || __traits_type::eq(__c, __minus))
00133       && __beg != __end)
00134     {
00135       __xtrc += __ctype.narrow(__c, char());
00136       ++__pos;
00137       __c = *(++__beg);
00138     }
00139 
00140       // Next, strip leading zeros.
00141       const char_type __zero = __ctype.widen(_S_atoms_in[_M_zero]);
00142       bool __found_zero = false;
00143       while (__traits_type::eq(__c, __zero) && __beg != __end)
00144     {
00145       __c = *(++__beg);
00146       __found_zero = true;
00147     }
00148       if (__found_zero)
00149     {
00150       __xtrc += _S_atoms_in[_M_zero];
00151       ++__pos;
00152     }
00153 
00154       // Only need acceptable digits for floating point numbers.
00155       const size_t __len = _M_E - _M_zero + 1;
00156       char_type  __watoms[__len];
00157       __ctype.widen(_S_atoms_in, _S_atoms_in + __len, __watoms);
00158       bool __found_dec = false;
00159       bool __found_sci = false;
00160       const char_type __dec = __np.decimal_point();
00161 
00162       string __found_grouping;
00163       const string __grouping = __np.grouping();
00164       bool __check_grouping = __grouping.size();
00165       int __sep_pos = 0;
00166       const char_type __sep = __np.thousands_sep();
00167 
00168       while (__beg != __end)
00169         {
00170       // Only look in digits.
00171           const char_type* __p = __traits_type::find(__watoms, 10,  __c);
00172 
00173           // NB: strchr returns true for __c == 0x0
00174           if (__p && !__traits_type::eq(__c, char_type()))
00175         {
00176           // Try first for acceptable digit; record it if found.
00177           ++__pos;
00178           __xtrc += _S_atoms_in[__p - __watoms];
00179           ++__sep_pos;
00180           __c = *(++__beg);
00181         }
00182           else if (__traits_type::eq(__c, __sep) 
00183            && __check_grouping && !__found_dec)
00184         {
00185               // NB: Thousands separator at the beginning of a string
00186               // is a no-no, as is two consecutive thousands separators.
00187               if (__sep_pos)
00188                 {
00189                   __found_grouping += static_cast<char>(__sep_pos);
00190                   __sep_pos = 0;
00191           __c = *(++__beg);
00192                 }
00193               else
00194         {
00195           __err |= ios_base::failbit;
00196           break;
00197         }
00198             }
00199       else if (__traits_type::eq(__c, __dec) && !__found_dec)
00200         {
00201           // According to the standard, if no grouping chars are seen,
00202           // no grouping check is applied. Therefore __found_grouping
00203           // must be adjusted only if __dec comes after some __sep.
00204           if (__found_grouping.size())
00205         __found_grouping += static_cast<char>(__sep_pos);
00206           ++__pos;
00207           __xtrc += '.';
00208           __c = *(++__beg);
00209           __found_dec = true;
00210         }
00211       else if ((__traits_type::eq(__c, __watoms[_M_e]) 
00212             || __traits_type::eq(__c, __watoms[_M_E])) 
00213            && !__found_sci && __pos)
00214         {
00215           // Scientific notation.
00216           ++__pos;
00217           __xtrc += __ctype.narrow(__c, char());
00218           __c = *(++__beg);
00219 
00220           // Remove optional plus or minus sign, if they exist.
00221           if (__traits_type::eq(__c, __plus) 
00222           || __traits_type::eq(__c, __minus))
00223         {
00224           ++__pos;
00225           __xtrc += __ctype.narrow(__c, char());
00226           __c = *(++__beg);
00227         }
00228           __found_sci = true;
00229         }
00230       else
00231         // Not a valid input item.
00232         break;
00233         }
00234 
00235       // Digit grouping is checked. If grouping and found_grouping don't
00236       // match, then get very very upset, and set failbit.
00237       if (__check_grouping && __found_grouping.size())
00238         {
00239           // Add the ending grouping if a decimal wasn't found.
00240       if (!__found_dec)
00241         __found_grouping += static_cast<char>(__sep_pos);
00242           if (!__verify_grouping(__grouping, __found_grouping))
00243         __err |= ios_base::failbit;
00244         }
00245 
00246       // Finish up
00247       __xtrc += char();
00248       if (__beg == __end)
00249         __err |= ios_base::eofbit;
00250       return __beg;
00251     }
00252 
00253   // Stage 1: Determine a conversion specifier.
00254   template<typename _CharT, typename _InIter>
00255     _InIter
00256     num_get<_CharT, _InIter>::
00257     _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
00258            ios_base::iostate& __err, string& __xtrc, int& __base) const
00259     {
00260       typedef char_traits<_CharT>       __traits_type;
00261       const locale __loc = __io.getloc();
00262       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
00263       const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
00264  
00265       // NB: Iff __basefield == 0, this can change based on contents.
00266       ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
00267       if (__basefield == ios_base::oct)
00268         __base = 8;
00269       else if (__basefield == ios_base::hex)
00270         __base = 16;
00271       else
00272     __base = 10;
00273 
00274       // First check for sign.
00275       int __pos = 0;
00276       char_type  __c = *__beg;
00277       const char_type __plus = __ctype.widen('+');
00278       const char_type __minus = __ctype.widen('-');
00279 
00280       if ((__traits_type::eq(__c, __plus) || __traits_type::eq(__c, __minus))
00281       && __beg != __end)
00282     {
00283       __xtrc += __ctype.narrow(__c, char());
00284       ++__pos;
00285       __c = *(++__beg);
00286     }
00287 
00288       // Next, strip leading zeros and check required digits for base formats.
00289       const char_type __zero = __ctype.widen(_S_atoms_in[_M_zero]);
00290       const char_type __x = __ctype.widen('x');
00291       const char_type __X = __ctype.widen('X');
00292       if (__base == 10)
00293     {
00294       bool __found_zero = false;
00295       while (__traits_type::eq(__c, __zero) && __beg != __end)
00296         {
00297           __c = *(++__beg);
00298           __found_zero = true;
00299         }
00300       if (__found_zero)
00301         {
00302           __xtrc += _S_atoms_in[_M_zero];
00303           ++__pos;
00304           if (__basefield == 0)
00305         {         
00306           if ((__traits_type::eq(__c, __x) 
00307                || __traits_type::eq(__c, __X))
00308               && __beg != __end)
00309             {
00310               __xtrc += __ctype.narrow(__c, char());
00311               ++__pos;
00312               __c = *(++__beg);
00313               __base = 16;
00314             }
00315           else 
00316             __base = 8;
00317         }
00318         }
00319     }
00320       else if (__base == 16)
00321     {
00322       if (__traits_type::eq(__c, __zero) && __beg != __end)
00323         {
00324           __xtrc += _S_atoms_in[_M_zero];
00325           ++__pos;
00326           __c = *(++__beg); 
00327           if ((__traits_type::eq(__c, __x) || __traits_type::eq(__c, __X))
00328           && __beg != __end)
00329         {
00330           __xtrc += __ctype.narrow(__c, char());
00331           ++__pos;
00332           __c = *(++__beg);
00333         }
00334         }
00335     }
00336 
00337       // At this point, base is determined. If not hex, only allow
00338       // base digits as valid input.
00339       size_t __len;
00340       if (__base == 16)
00341     __len = _M_size;
00342       else
00343     __len = __base;
00344 
00345       // Extract.
00346       char_type __watoms[_M_size];
00347       __ctype.widen(_S_atoms_in, _S_atoms_in + __len, __watoms);
00348       string __found_grouping;
00349       const string __grouping = __np.grouping();
00350       bool __check_grouping = __grouping.size();
00351       int __sep_pos = 0;
00352       const char_type __sep = __np.thousands_sep();
00353       while (__beg != __end)
00354         {
00355           const char_type* __p = __traits_type::find(__watoms, __len,  __c);
00356 
00357           // NB: strchr returns true for __c == 0x0
00358           if (__p && !__traits_type::eq(__c, char_type()))
00359         {
00360           // Try first for acceptable digit; record it if found.
00361           __xtrc += _S_atoms_in[__p - __watoms];
00362           ++__pos;
00363           ++__sep_pos;
00364           __c = *(++__beg);
00365         }
00366           else if (__traits_type::eq(__c, __sep) && __check_grouping)
00367         {
00368               // NB: Thousands separator at the beginning of a string
00369               // is a no-no, as is two consecutive thousands separators.
00370               if (__sep_pos)
00371                 {
00372                   __found_grouping += static_cast<char>(__sep_pos);
00373                   __sep_pos = 0;
00374           __c = *(++__beg);
00375                 }
00376               else
00377         {
00378           __err |= ios_base::failbit;
00379           break;
00380         }
00381             }
00382       else
00383         // Not a valid input item.
00384         break;
00385         }
00386 
00387       // Digit grouping is checked. If grouping and found_grouping don't
00388       // match, then get very very upset, and set failbit.
00389       if (__check_grouping && __found_grouping.size())
00390         {
00391           // Add the ending grouping.
00392           __found_grouping += static_cast<char>(__sep_pos);
00393           if (!__verify_grouping(__grouping, __found_grouping))
00394         __err |= ios_base::failbit;
00395         }
00396 
00397       // Finish up.
00398       __xtrc += char();
00399       if (__beg == __end)
00400         __err |= ios_base::eofbit;
00401       return __beg;
00402     }
00403 
00404 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00405   //17.  Bad bool parsing
00406   template<typename _CharT, typename _InIter>
00407     _InIter
00408     num_get<_CharT, _InIter>::
00409     do_get(iter_type __beg, iter_type __end, ios_base& __io,
00410            ios_base::iostate& __err, bool& __v) const
00411     {
00412       // Parse bool values as unsigned long
00413       if (!(__io.flags() & ios_base::boolalpha))
00414         {
00415           // NB: We can't just call do_get(long) here, as it might
00416           // refer to a derived class.
00417           string __xtrc;
00418           int __base;
00419           __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
00420 
00421       unsigned long __ul; 
00422       __convert_to_v(__xtrc.c_str(), __ul, __err, _S_c_locale, __base);
00423       if (!(__err & ios_base::failbit) && __ul <= 1)
00424         __v = __ul;
00425       else 
00426             __err |= ios_base::failbit;
00427         }
00428 
00429       // Parse bool values as alphanumeric
00430       else
00431         {
00432       typedef char_traits<_CharT>           __traits_type;
00433       typedef basic_string<_CharT>      __string_type;
00434 
00435           locale __loc = __io.getloc();
00436       const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); 
00437       const __string_type __true = __np.truename();
00438       const __string_type __false = __np.falsename();
00439           const char_type* __trues = __true.c_str();
00440           const char_type* __falses = __false.c_str();
00441           const size_t __truen =  __true.size() - 1;
00442           const size_t __falsen =  __false.size() - 1;
00443 
00444           for (size_t __n = 0; __beg != __end; ++__n)
00445             {
00446               char_type __c = *__beg++;
00447               bool __testf = __n <= __falsen 
00448                      ? __traits_type::eq(__c, __falses[__n]) : false;
00449               bool __testt = __n <= __truen 
00450                      ? __traits_type::eq(__c, __trues[__n]) : false;
00451               if (!(__testf || __testt))
00452                 {
00453                   __err |= ios_base::failbit;
00454                   break;
00455                 }
00456               else if (__testf && __n == __falsen)
00457                 {
00458                   __v = 0;
00459                   break;
00460                 }
00461               else if (__testt && __n == __truen)
00462                 {
00463                   __v = 1;
00464                   break;
00465                 }
00466             }
00467           if (__beg == __end)
00468             __err |= ios_base::eofbit;
00469         }
00470       return __beg;
00471     }
00472 #endif
00473 
00474   template<typename _CharT, typename _InIter>
00475     _InIter
00476     num_get<_CharT, _InIter>::
00477     do_get(iter_type __beg, iter_type __end, ios_base& __io,
00478            ios_base::iostate& __err, long& __v) const
00479     {
00480       string __xtrc;
00481       int __base;
00482       __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
00483       __convert_to_v(__xtrc.c_str(), __v, __err, _S_c_locale, __base);
00484       return __beg;
00485     }
00486 
00487   template<typename _CharT, typename _InIter>
00488     _InIter
00489     num_get<_CharT, _InIter>::
00490     do_get(iter_type __beg, iter_type __end, ios_base& __io,
00491            ios_base::iostate& __err, unsigned short& __v) const
00492     {
00493       string __xtrc;
00494       int __base;
00495       __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
00496       unsigned long __ul;
00497       __convert_to_v(__xtrc.c_str(), __ul, __err, _S_c_locale, __base);
00498       if (!(__err & ios_base::failbit) 
00499       && __ul <= numeric_limits<unsigned short>::max())
00500     __v = static_cast<unsigned short>(__ul);
00501       else 
00502     __err |= ios_base::failbit;
00503       return __beg;
00504     }
00505 
00506   template<typename _CharT, typename _InIter>
00507     _InIter
00508     num_get<_CharT, _InIter>::
00509     do_get(iter_type __beg, iter_type __end, ios_base& __io,
00510            ios_base::iostate& __err, unsigned int& __v) const
00511     {
00512       string __xtrc;
00513       int __base;
00514       __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
00515       unsigned long __ul;
00516       __convert_to_v(__xtrc.c_str(), __ul, __err, _S_c_locale, __base);
00517       if (!(__err & ios_base::failbit) 
00518       && __ul <= numeric_limits<unsigned int>::max())
00519     __v = static_cast<unsigned int>(__ul);
00520       else 
00521     __err |= ios_base::failbit;
00522       return __beg;
00523     }
00524 
00525   template<typename _CharT, typename _InIter>
00526     _InIter
00527     num_get<_CharT, _InIter>::
00528     do_get(iter_type __beg, iter_type __end, ios_base& __io,
00529            ios_base::iostate& __err, unsigned long& __v) const
00530     {
00531       string __xtrc;
00532       int __base;
00533       __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
00534       __convert_to_v(__xtrc.c_str(), __v, __err, _S_c_locale, __base);
00535       return __beg;
00536     }
00537 
00538 #ifdef _GLIBCPP_USE_LONG_LONG
00539   template<typename _CharT, typename _InIter>
00540     _InIter
00541     num_get<_CharT, _InIter>::
00542     do_get(iter_type __beg, iter_type __end, ios_base& __io,
00543            ios_base::iostate& __err, long long& __v) const
00544     {
00545       string __xtrc;
00546       int __base;
00547       __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
00548       __convert_to_v(__xtrc.c_str(), __v, __err, _S_c_locale, __base);
00549       return __beg;
00550     }
00551 
00552   template<typename _CharT, typename _InIter>
00553     _InIter
00554     num_get<_CharT, _InIter>::
00555     do_get(iter_type __beg, iter_type __end, ios_base& __io,
00556            ios_base::iostate& __err, unsigned long long& __v) const
00557     {
00558       string __xtrc;
00559       int __base;
00560       __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
00561       __convert_to_v(__xtrc.c_str(), __v, __err, _S_c_locale, __base);
00562       return __beg;
00563     }
00564 #endif
00565 
00566   template<typename _CharT, typename _InIter>
00567     _InIter
00568     num_get<_CharT, _InIter>::
00569     do_get(iter_type __beg, iter_type __end, ios_base& __io, 
00570        ios_base::iostate& __err, float& __v) const
00571     {
00572       string __xtrc;
00573       __xtrc.reserve(32);
00574       __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
00575       __convert_to_v(__xtrc.c_str(), __v, __err, _S_c_locale);
00576       return __beg;
00577     }
00578 
00579   template<typename _CharT, typename _InIter>
00580     _InIter
00581     num_get<_CharT, _InIter>::
00582     do_get(iter_type __beg, iter_type __end, ios_base& __io,
00583            ios_base::iostate& __err, double& __v) const
00584     {
00585       string __xtrc;
00586       __xtrc.reserve(32);
00587       __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
00588       __convert_to_v(__xtrc.c_str(), __v, __err, _S_c_locale);
00589       return __beg;
00590     }
00591 
00592   template<typename _CharT, typename _InIter>
00593     _InIter
00594     num_get<_CharT, _InIter>::
00595     do_get(iter_type __beg, iter_type __end, ios_base& __io,
00596            ios_base::iostate& __err, long double& __v) const
00597     {
00598       string __xtrc;
00599       __xtrc.reserve(32);
00600       __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
00601       __convert_to_v(__xtrc.c_str(), __v, __err, _S_c_locale);
00602       return __beg;
00603     }
00604 
00605   template<typename _CharT, typename _InIter>
00606     _InIter
00607     num_get<_CharT, _InIter>::
00608     do_get(iter_type __beg, iter_type __end, ios_base& __io,
00609            ios_base::iostate& __err, void*& __v) const
00610     {
00611       // Prepare for hex formatted input
00612       typedef ios_base::fmtflags        fmtflags;
00613       fmtflags __fmt = __io.flags();
00614       fmtflags __fmtmask = ~(ios_base::showpos | ios_base::basefield
00615                              | ios_base::uppercase | ios_base::internal);
00616       __io.flags(__fmt & __fmtmask | (ios_base::hex | ios_base::showbase));
00617 
00618       string __xtrc;
00619       int __base;
00620       __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
00621 
00622       // Reset from hex formatted input
00623       __io.flags(__fmt);
00624 
00625       unsigned long __ul;
00626       __convert_to_v(__xtrc.c_str(), __ul, __err, _S_c_locale, __base);
00627       if (!(__err & ios_base::failbit))
00628     __v = reinterpret_cast<void*>(__ul);
00629       else 
00630     __err |= ios_base::failbit;
00631       return __beg;
00632     }
00633 
00634   // For use by integer and floating-point types after they have been
00635   // converted into a char_type string.
00636   template<typename _CharT, typename _OutIter>
00637     void
00638     num_put<_CharT, _OutIter>::
00639     _M_pad(_CharT __fill, streamsize __w, ios_base& __io, 
00640        _CharT* __new, const _CharT* __cs, int& __len) const
00641     {
00642       // [22.2.2.2.2] Stage 3.
00643       // If necessary, pad.
00644       __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, __cs, 
00645                           __w, __len, true);
00646       __len = static_cast<int>(__w);
00647     }
00648 
00649   // Forwarding functions to peel signed from unsigned integer types.
00650   template<typename _CharT>
00651     inline int
00652     __int_to_char(_CharT* __out, const int __size, long __v,
00653                const _CharT* __lit, ios_base::fmtflags __flags)
00654     {
00655       unsigned long __ul = static_cast<unsigned long>(__v);
00656       bool __neg = false;
00657       if (__v < 0) 
00658     {
00659       __ul = -__ul;
00660       __neg = true;
00661     }
00662       return __int_to_char(__out, __size, __ul, __lit, __flags, __neg); 
00663     }
00664 
00665   template<typename _CharT>
00666     inline int
00667     __int_to_char(_CharT* __out, const int __size, unsigned long __v,
00668                const _CharT* __lit, ios_base::fmtflags __flags)
00669     { return __int_to_char(__out, __size, __v, __lit, __flags, false); }
00670 
00671 #ifdef _GLIBCPP_USE_LONG_LONG
00672   template<typename _CharT>
00673     inline int
00674     __int_to_char(_CharT* __out, const int __size, long long __v,
00675                const _CharT* __lit, ios_base::fmtflags __flags)
00676     { 
00677       unsigned long long __ull = static_cast<unsigned long long>(__v);
00678       bool __neg = false;
00679       if (__v < 0) 
00680     {
00681       __ull = -__ull;
00682       __neg = true;
00683     }
00684       return __int_to_char(__out, __size, __ull, __lit, __flags, __neg); 
00685     }
00686 
00687   template<typename _CharT>
00688     inline int
00689     __int_to_char(_CharT* __out, const int __size, unsigned long long __v,
00690                const _CharT* __lit, ios_base::fmtflags __flags)
00691     { return __int_to_char(__out, __size, __v, __lit, __flags, false); }
00692 #endif
00693       
00694   template<typename _CharT, typename _ValueT>
00695     int
00696     __int_to_char(_CharT* __out, const int __size, _ValueT __v,
00697           const _CharT* __lit, ios_base::fmtflags __flags, bool __neg)
00698     {
00699       // Don't write base if already 0.
00700       const bool __showbase = (__flags & ios_base::showbase) && __v;
00701       const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
00702       _CharT* __buf = __out + __size - 1;
00703       _CharT* __bufend = __out + __size;
00704 
00705       if (__builtin_expect(__basefield != ios_base::oct &&
00706                __basefield != ios_base::hex, true))
00707     {
00708       // Decimal.
00709       do 
00710         {
00711           *__buf-- = __lit[(__v % 10) + __num_base::_S_digits];
00712           __v /= 10;
00713         } 
00714       while (__v != 0);
00715       if (__neg)
00716         *__buf-- = __lit[__num_base::_S_minus];
00717       else if (__flags & ios_base::showpos)
00718         *__buf-- = __lit[__num_base::_S_plus];
00719     }
00720       else if (__basefield == ios_base::oct)
00721     {
00722       // Octal.
00723       do 
00724         {
00725           *__buf-- = __lit[(__v & 0x7) + __num_base::_S_digits];
00726           __v >>= 3;
00727         } 
00728       while (__v != 0);
00729       if (__showbase)
00730         *__buf-- = __lit[__num_base::_S_digits];
00731     }
00732       else
00733     {
00734       // Hex.
00735       const bool __uppercase = __flags & ios_base::uppercase;
00736       int __case_offset = __uppercase
00737                           ? __num_base::_S_udigits : __num_base::_S_digits;
00738       do 
00739         {
00740           *__buf-- = __lit[(__v & 0xf) + __case_offset];
00741           __v >>= 4;
00742         } 
00743       while (__v != 0);
00744       if (__showbase)
00745         {
00746           // 'x' or 'X'
00747           *__buf-- = __lit[__num_base::_S_x + __uppercase];
00748           // '0'
00749           *__buf-- = __lit[__num_base::_S_digits];
00750         }
00751     }
00752       int __ret = __bufend - __buf - 1;
00753       return __ret;
00754     }
00755 
00756   template<typename _CharT, typename _OutIter>
00757     void
00758     num_put<_CharT, _OutIter>::
00759     _M_group_int(const string& __grouping, _CharT __sep, ios_base& __io, 
00760          _CharT* __new, _CharT* __cs, int& __len) const
00761     {
00762       // By itself __add_grouping cannot deal correctly with __ws when
00763       // ios::showbase is set and ios_base::oct || ios_base::hex.
00764       // Therefore we take care "by hand" of the initial 0, 0x or 0X.
00765       // However, remember that the latter do not occur if the number
00766       // printed is '0' (__len == 1).
00767       streamsize __off = 0;
00768       const ios_base::fmtflags __basefield = __io.flags() 
00769                                          & ios_base::basefield;
00770       if ((__io.flags() & ios_base::showbase) && __len > 1)
00771     if (__basefield == ios_base::oct)
00772       {
00773         __off = 1;
00774         *__new = *__cs;
00775       }
00776     else if (__basefield == ios_base::hex)
00777       {
00778         __off = 2;
00779         *__new = *__cs;
00780         *(__new + 1) = *(__cs + 1);
00781       }
00782       _CharT* __p;
00783       __p = __add_grouping(__new + __off, __sep, 
00784                __grouping.c_str(),
00785                __grouping.c_str() + __grouping.size(),
00786                __cs + __off, __cs + __len);
00787       __len = __p - __new;
00788     }
00789 
00790   template<typename _CharT, typename _OutIter>
00791     template<typename _ValueT>
00792       _OutIter
00793       num_put<_CharT, _OutIter>::
00794       _M_convert_int(_OutIter __s, ios_base& __io, _CharT __fill, 
00795              _ValueT __v) const
00796       {
00797     typedef numpunct<_CharT>  __facet_type;
00798     typedef __locale_cache<numpunct<_CharT> > __cache_type;
00799     const locale& __loc = __io._M_getloc();
00800     const __cache_type& __lc = __use_cache<__facet_type>(__loc);
00801     const _CharT* __lit = __lc._M_atoms_out;
00802 
00803     // Long enough to hold hex, dec, and octal representations.
00804     int __ilen = 4 * sizeof(_ValueT);
00805     _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
00806                                  * __ilen));
00807     // [22.2.2.2.2] Stage 1, numeric conversion to character.
00808     // Result is returned right-justified in the buffer.
00809     int __len;
00810     __len = __int_to_char(&__cs[0], __ilen, __v, __lit, __io.flags());
00811     __cs = __cs + __ilen - __len;
00812     
00813     // Add grouping, if necessary. 
00814     _CharT* __cs2;
00815     if (__lc._M_use_grouping)
00816       {
00817         // Grouping can add (almost) as many separators as the
00818         // number of digits, but no more.
00819         __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
00820                               * __len * 2));
00821         _M_group_int(__lc._M_grouping, __lc._M_thousands_sep, __io, 
00822              __cs2, __cs, __len);
00823         __cs = __cs2;
00824       }
00825     
00826     // Pad.
00827     _CharT* __cs3;
00828     streamsize __w = __io.width();
00829     if (__w > static_cast<streamsize>(__len))
00830       {
00831         __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
00832                               * __w));
00833         _M_pad(__fill, __w, __io, __cs3, __cs, __len);
00834         __cs = __cs3;
00835       }
00836     __io.width(0);
00837 
00838     // [22.2.2.2.2] Stage 4.
00839     // Write resulting, fully-formatted string to output iterator.
00840     return __write(__s, __cs, __len);
00841       } 
00842 
00843   template<typename _CharT, typename _OutIter>
00844     void
00845     num_put<_CharT, _OutIter>::
00846     _M_group_float(const string& __grouping, _CharT __sep, const _CharT* __p, 
00847            _CharT* __new, _CharT* __cs, int& __len) const
00848     {
00849 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00850       //282. What types does numpunct grouping refer to?
00851       // Add grouping, if necessary. 
00852       _CharT* __p2;
00853       int __declen = __p ? __p - __cs : __len;
00854       __p2 = __add_grouping(__new, __sep, 
00855                 __grouping.c_str(),
00856                 __grouping.c_str() + __grouping.size(),
00857                 __cs, __cs + __declen);
00858       
00859       // Tack on decimal part.
00860       int __newlen = __p2 - __new;
00861       if (__p)
00862     {
00863       char_traits<_CharT>::copy(__p2, __p, __len - __declen);
00864       __newlen += __len - __declen;
00865     }    
00866       __len = __newlen;
00867 #endif
00868     }
00869 
00870   // The following code uses snprintf (or sprintf(), when
00871   // _GLIBCPP_USE_C99 is not defined) to convert floating point values
00872   // for insertion into a stream.  An optimization would be to replace
00873   // them with code that works directly on a wide buffer and then use
00874   // __pad to do the padding.  It would be good to replace them anyway
00875   // to gain back the efficiency that C++ provides by knowing up front
00876   // the type of the values to insert.  Also, sprintf is dangerous
00877   // since may lead to accidental buffer overruns.  This
00878   // implementation follows the C++ standard fairly directly as
00879   // outlined in 22.2.2.2 [lib.locale.num.put]
00880   template<typename _CharT, typename _OutIter>
00881     template<typename _ValueT>
00882       _OutIter
00883       num_put<_CharT, _OutIter>::
00884       _M_convert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
00885                _ValueT __v) const
00886       {
00887     // Note: digits10 is rounded down: add 1 to ensure the maximum
00888     // available precision.  Then, in general, one more 1 needs to
00889     // be added since, when the %{g,G} conversion specifiers are
00890     // chosen inside _S_format_float, the precision field is "the
00891     // maximum number of significant digits", *not* the "number of
00892     // digits to appear after the decimal point", as happens for
00893     // %{e,E,f,F} (C99, 7.19.6.1,4).
00894     const int __max_digits = numeric_limits<_ValueT>::digits10 + 2;
00895 
00896     // Use default precision if out of range.
00897     streamsize __prec = __io.precision();
00898     if (__prec > static_cast<streamsize>(__max_digits))
00899       __prec = static_cast<streamsize>(__max_digits);
00900     else if (__prec < static_cast<streamsize>(0))
00901       __prec = static_cast<streamsize>(6);
00902 
00903     typedef numpunct<_CharT>  __facet_type;
00904     typedef __locale_cache<numpunct<_CharT> > __cache_type;
00905     const locale __loc = __io._M_getloc();
00906     const __cache_type& __lc = __use_cache<__facet_type>(__loc);
00907 
00908     // [22.2.2.2.2] Stage 1, numeric conversion to character.
00909     int __len;
00910     // Long enough for the max format spec.
00911     char __fbuf[16];
00912 
00913 #ifdef _GLIBCPP_USE_C99
00914     // First try a buffer perhaps big enough (for sure sufficient
00915     // for non-ios_base::fixed outputs)
00916     int __cs_size = __max_digits * 3;
00917     char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
00918 
00919     _S_format_float(__io, __fbuf, __mod, __prec);
00920     __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
00921                  _S_c_locale, __prec);
00922 
00923     // If the buffer was not large enough, try again with the correct size.
00924     if (__len >= __cs_size)
00925       {
00926         __cs_size = __len + 1; 
00927         __cs = static_cast<char*>(__builtin_alloca(__cs_size));
00928         __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
00929                      _S_c_locale, __prec);
00930       }
00931 #else
00932     // Consider the possibility of long ios_base::fixed outputs
00933     const bool __fixed = __io.flags() & ios_base::fixed;
00934     const int __max_exp = numeric_limits<_ValueT>::max_exponent10;
00935 
00936     // ios_base::fixed outputs may need up to __max_exp+1 chars
00937     // for the integer part + up to __max_digits chars for the
00938     // fractional part + 3 chars for sign, decimal point, '\0'. On
00939     // the other hand, for non-fixed outputs __max_digits*3 chars
00940     // are largely sufficient.
00941     const int __cs_size = __fixed ? __max_exp + __max_digits + 4 
00942                                   : __max_digits * 3;
00943     char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
00944 
00945     _S_format_float(__io, __fbuf, __mod, __prec);
00946     __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale, __prec);
00947 #endif
00948 
00949       // [22.2.2.2.2] Stage 2, convert to char_type, using correct
00950       // numpunct.decimal_point() values for '.' and adding grouping.
00951       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
00952 
00953       _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
00954                                * __len));
00955       __ctype.widen(__cs, __cs + __len, __ws);
00956       
00957       // Replace decimal point.
00958       const _CharT __cdec = __ctype.widen('.');
00959       const _CharT __dec = __lc._M_decimal_point;
00960       const _CharT* __p;
00961       if (__p = char_traits<_CharT>::find(__ws, __len, __cdec))
00962     __ws[__p - __ws] = __dec;
00963 
00964       // Add grouping, if necessary. 
00965       _CharT* __ws2;
00966       if (__lc._M_use_grouping)
00967     {
00968         // Grouping can add (almost) as many separators as the
00969         // number of digits, but no more.
00970         __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
00971                               * __len * 2));
00972         _M_group_float(__lc._M_grouping, __lc._M_thousands_sep, __p,
00973                __ws2, __ws, __len);
00974         __ws = __ws2;
00975     }
00976 
00977       // Pad.
00978       _CharT* __ws3;
00979       streamsize __w = __io.width();
00980       if (__w > static_cast<streamsize>(__len))
00981     {
00982       __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
00983       _M_pad(__fill, __w, __io, __ws3, __ws, __len);
00984       __ws = __ws3;
00985     }
00986       __io.width(0);
00987       
00988       // [22.2.2.2.2] Stage 4.
00989       // Write resulting, fully-formatted string to output iterator.
00990       return __write(__s, __ws, __len);
00991       }
00992 
00993   template<typename _CharT, typename _OutIter>
00994     _OutIter
00995     num_put<_CharT, _OutIter>::
00996     do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
00997     {
00998       ios_base::fmtflags __flags = __io.flags();
00999       if ((__flags & ios_base::boolalpha) == 0)
01000         {
01001           unsigned long __uv = __v;
01002           __s = _M_convert_int(__s, __io, __fill, __uv);
01003         }
01004       else
01005         {
01006       typedef numpunct<_CharT>  __facet_type;
01007       typedef __locale_cache<numpunct<_CharT> > __cache_type;
01008       const locale __loc = __io._M_getloc();
01009       const __cache_type& __lc = __use_cache<__facet_type>(__loc);
01010 
01011       typedef basic_string<_CharT>  __string_type;
01012       __string_type __name;
01013           if (__v)
01014         __name = __lc._M_truename;
01015           else
01016         __name = __lc._M_falsename;
01017 
01018       const _CharT* __cs = __name.c_str();
01019       int __len = __name.size();
01020       _CharT* __cs3;
01021       streamsize __w = __io.width();
01022       if (__w > static_cast<streamsize>(__len))
01023         {
01024           __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
01025                                 * __w));
01026           _M_pad(__fill, __w, __io, __cs3, __cs, __len);
01027           __cs = __cs3;
01028         }
01029       __io.width(0);
01030       __s = __write(__s, __cs, __len);
01031     }
01032       return __s;
01033     }
01034 
01035   template<typename _CharT, typename _OutIter>
01036     _OutIter
01037     num_put<_CharT, _OutIter>::
01038     do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
01039     { return _M_convert_int(__s, __io, __fill, __v); }
01040 
01041   template<typename _CharT, typename _OutIter>
01042     _OutIter
01043     num_put<_CharT, _OutIter>::
01044     do_put(iter_type __s, ios_base& __io, char_type __fill,
01045            unsigned long __v) const
01046     { return _M_convert_int(__s, __io, __fill, __v); }
01047 
01048 #ifdef _GLIBCPP_USE_LONG_LONG
01049   template<typename _CharT, typename _OutIter>
01050     _OutIter
01051     num_put<_CharT, _OutIter>::
01052     do_put(iter_type __s, ios_base& __b, char_type __fill, long long __v) const
01053     { return _M_convert_int(__s, __b, __fill, __v); }
01054 
01055   template<typename _CharT, typename _OutIter>
01056     _OutIter
01057     num_put<_CharT, _OutIter>::
01058     do_put(iter_type __s, ios_base& __io, char_type __fill,
01059            unsigned long long __v) const
01060     { return _M_convert_int(__s, __io, __fill, __v); }
01061 #endif
01062 
01063   template<typename _CharT, typename _OutIter>
01064     _OutIter
01065     num_put<_CharT, _OutIter>::
01066     do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
01067     { return _M_convert_float(__s, __io, __fill, char(), __v); }
01068 
01069   template<typename _CharT, typename _OutIter>
01070     _OutIter
01071     num_put<_CharT, _OutIter>::
01072     do_put(iter_type __s, ios_base& __io, char_type __fill, 
01073        long double __v) const
01074     { return _M_convert_float(__s, __io, __fill, 'L', __v); }
01075 
01076   template<typename _CharT, typename _OutIter>
01077     _OutIter
01078     num_put<_CharT, _OutIter>::
01079     do_put(iter_type __s, ios_base& __io, char_type __fill,
01080            const void* __v) const
01081     {
01082       ios_base::fmtflags __flags = __io.flags();
01083       ios_base::fmtflags __fmt = ~(ios_base::showpos | ios_base::basefield
01084                    | ios_base::uppercase | ios_base::internal);
01085       __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
01086       try 
01087     {
01088       __s = _M_convert_int(__s, __io, __fill, 
01089                    reinterpret_cast<unsigned long>(__v));
01090       __io.flags(__flags);
01091     }
01092       catch (...) 
01093     {
01094       __io.flags(__flags);
01095       __throw_exception_again;
01096     }
01097       return __s;
01098     }
01099 
01100 
01101   template<typename _CharT, typename _InIter>
01102     _InIter
01103     money_get<_CharT, _InIter>::
01104     do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, 
01105        ios_base::iostate& __err, long double& __units) const
01106     { 
01107       string_type __str;
01108       __beg = this->do_get(__beg, __end, __intl, __io, __err, __str); 
01109 
01110       const int __cs_size = __str.size() + 1;
01111       char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
01112       const locale __loc = __io.getloc();
01113       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
01114       const _CharT* __wcs = __str.c_str();
01115       __ctype.narrow(__wcs, __wcs + __cs_size, char(), __cs);      
01116       __convert_to_v(__cs, __units, __err, _S_c_locale);
01117       return __beg;
01118     }
01119 
01120   template<typename _CharT, typename _InIter>
01121     _InIter
01122     money_get<_CharT, _InIter>::
01123     do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, 
01124        ios_base::iostate& __err, string_type& __units) const
01125     { 
01126       // These contortions are quite unfortunate.
01127       typedef moneypunct<_CharT, true>      __money_true;
01128       typedef moneypunct<_CharT, false>     __money_false;
01129       typedef money_base::part          part;
01130       typedef typename string_type::size_type   size_type;
01131 
01132       const locale __loc = __io.getloc();
01133       const __money_true& __mpt = use_facet<__money_true>(__loc); 
01134       const __money_false& __mpf = use_facet<__money_false>(__loc); 
01135       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
01136 
01137       const money_base::pattern __p = __intl ? __mpt.neg_format() 
01138                          : __mpf.neg_format();
01139 
01140       const string_type __pos_sign =__intl ? __mpt.positive_sign() 
01141                        : __mpf.positive_sign();
01142       const string_type __neg_sign =__intl ? __mpt.negative_sign() 
01143                        : __mpf.negative_sign();
01144       const char_type __d = __intl ? __mpt.decimal_point() 
01145                            : __mpf.decimal_point();
01146       const char_type __sep = __intl ? __mpt.thousands_sep() 
01147                          : __mpf.thousands_sep();
01148 
01149       const string __grouping = __intl ? __mpt.grouping() : __mpf.grouping();
01150 
01151       // Set to deduced positive or negative sign, depending.
01152       string_type __sign;
01153       // String of grouping info from thousands_sep plucked from __units.
01154       string __grouping_tmp; 
01155       // Marker for thousands_sep position.
01156       int __sep_pos = 0;
01157       // If input iterator is in a valid state.
01158       bool __testvalid = true;
01159       // Flag marking when a decimal point is found.
01160       bool __testdecfound = false; 
01161 
01162       // The tentative returned string is stored here.
01163       string_type __temp_units;
01164 
01165       char_type __c = *__beg;
01166       char_type __eof = static_cast<char_type>(char_traits<char_type>::eof());
01167       for (int __i = 0; __beg != __end && __i < 4 && __testvalid; ++__i)
01168     {
01169       part __which = static_cast<part>(__p.field[__i]);
01170       switch (__which)
01171         {
01172         case money_base::symbol:
01173           if (__io.flags() & ios_base::showbase 
01174               || __i < 2 || __sign.size() > 1
01175               || ((static_cast<part>(__p.field[3]) != money_base::none)
01176               && __i == 2)) 
01177             {
01178               // According to 22.2.6.1.2.2, symbol is required
01179               // if (__io.flags() & ios_base::showbase),
01180               // otherwise is optional and consumed only if
01181               // other characters are needed to complete the
01182               // format.
01183               const string_type __symbol = __intl ? __mpt.curr_symbol()
01184                                  : __mpf.curr_symbol();
01185               size_type __len = __symbol.size();
01186               size_type __j = 0;
01187               while (__beg != __end 
01188                  && __j < __len && __symbol[__j] == __c)
01189             {
01190               __c = *(++__beg);
01191               ++__j;
01192             }
01193               // When (__io.flags() & ios_base::showbase)
01194               // symbol is required.
01195               if (__j != __len && (__io.flags() & ios_base::showbase))
01196             __testvalid = false;
01197             }
01198           break;
01199         case money_base::sign:          
01200           // Sign might not exist, or be more than one character long. 
01201           if (__pos_sign.size() && __neg_sign.size())
01202           {
01203             // Sign is mandatory.
01204             if (__c == __pos_sign[0])
01205               {
01206             __sign = __pos_sign;
01207             __c = *(++__beg);
01208               }
01209             else if (__c == __neg_sign[0])
01210               {
01211             __sign = __neg_sign;
01212             __c = *(++__beg);
01213               }
01214             else
01215               __testvalid = false;
01216           }
01217           else if (__pos_sign.size() && __c == __pos_sign[0])
01218             {
01219               __sign = __pos_sign;
01220               __c = *(++__beg);
01221             }
01222           else if (__neg_sign.size() && __c == __neg_sign[0])
01223             {
01224               __sign = __neg_sign;
01225               __c = *(++__beg);
01226             }
01227           break;
01228         case money_base::value:
01229           // Extract digits, remove and stash away the
01230           // grouping of found thousands separators.
01231           while (__beg != __end 
01232              && (__ctype.is(ctype_base::digit, __c) 
01233                  || (__c == __d && !__testdecfound)
01234                  || __c == __sep))
01235             {
01236               if (__c == __d)
01237             {
01238               __grouping_tmp += static_cast<char>(__sep_pos);
01239               __sep_pos = 0;
01240               __testdecfound = true;
01241             }
01242               else if (__c == __sep)
01243             {
01244               if (__grouping.size())
01245                 {
01246                   // Mark position for later analysis.
01247                   __grouping_tmp += static_cast<char>(__sep_pos);
01248                   __sep_pos = 0;
01249                 }
01250               else
01251                 {
01252                   __testvalid = false;
01253                   break;
01254                 }
01255             }
01256               else
01257             {
01258               __temp_units += __c;
01259               ++__sep_pos;
01260             }
01261               __c = *(++__beg);
01262             }
01263           break;
01264         case money_base::space:
01265         case money_base::none:
01266           // Only if not at the end of the pattern.
01267           if (__i != 3)
01268             while (__beg != __end 
01269                && __ctype.is(ctype_base::space, __c))
01270               __c = *(++__beg);
01271           break;
01272         }
01273     }
01274 
01275       // Need to get the rest of the sign characters, if they exist.
01276       if (__sign.size() > 1)
01277     {
01278       size_type __len = __sign.size();
01279       size_type __i = 1;
01280       for (; __c != __eof && __i < __len; ++__i)
01281         while (__beg != __end && __c != __sign[__i])
01282           __c = *(++__beg);
01283       
01284       if (__i != __len)
01285         __testvalid = false;
01286     }
01287 
01288       // Strip leading zeros.
01289       while (__temp_units.size() > 1 && __temp_units[0] == __ctype.widen('0'))
01290     __temp_units.erase(__temp_units.begin());
01291 
01292       if (__sign.size() && __sign == __neg_sign)
01293     __temp_units.insert(__temp_units.begin(), __ctype.widen('-'));
01294 
01295       // Test for grouping fidelity.
01296       if (__grouping.size() && __grouping_tmp.size())
01297     {
01298       if (!__verify_grouping(__grouping, __grouping_tmp))
01299         __testvalid = false;
01300     }
01301 
01302       // Iff no more characters are available.      
01303       if (__c == __eof)
01304     __err |= ios_base::eofbit;
01305 
01306       // Iff valid sequence is not recognized.
01307       if (!__testvalid || !__temp_units.size())
01308     __err |= ios_base::failbit;
01309       else
01310     // Use the "swap trick" to copy __temp_units into __units.
01311     __temp_units.swap(__units);
01312 
01313       return __beg; 
01314     }
01315 
01316   template<typename _CharT, typename _OutIter>
01317     _OutIter
01318     money_put<_CharT, _OutIter>::
01319     do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
01320        long double __units) const
01321     { 
01322       const locale __loc = __io.getloc();
01323       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
01324 #ifdef _GLIBCPP_USE_C99
01325       // First try a buffer perhaps big enough.
01326       int __cs_size = 64;
01327       char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
01328       // _GLIBCXX_RESOLVE_LIB_DEFECTS
01329       // 328. Bad sprintf format modifier in money_put<>::do_put()
01330       int __len = __convert_from_v(__cs, __cs_size, "%.0Lf", __units, 
01331                    _S_c_locale);
01332       // If the buffer was not large enough, try again with the correct size.
01333       if (__len >= __cs_size)
01334     {
01335       __cs_size = __len + 1;
01336       __cs = static_cast<char*>(__builtin_alloca(__cs_size));
01337       __len = __convert_from_v(__cs, __cs_size, "%.0Lf", __units, 
01338                    _S_c_locale);
01339     }
01340 #else
01341       // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
01342       const int __cs_size = numeric_limits<long double>::max_exponent10 + 3;
01343       char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
01344       int __len = __convert_from_v(__cs, 0, "%.0Lf", __units, _S_c_locale);
01345 #endif
01346       _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
01347                                * __cs_size));
01348       __ctype.widen(__cs, __cs + __len, __ws);
01349       const string_type __digits(__ws, __len);
01350       return this->do_put(__s, __intl, __io, __fill, __digits); 
01351     }
01352 
01353   template<typename _CharT, typename _OutIter>
01354     _OutIter
01355     money_put<_CharT, _OutIter>::
01356     do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
01357        const string_type& __digits) const
01358     { 
01359       typedef typename string_type::size_type   size_type;
01360       typedef money_base::part          part;
01361 
01362       const locale __loc = __io.getloc();
01363       const size_type __width = static_cast<size_type>(__io.width());
01364 
01365       // These contortions are quite unfortunate.
01366       typedef moneypunct<_CharT, true> __money_true;
01367       typedef moneypunct<_CharT, false> __money_false;
01368       const __money_true& __mpt = use_facet<__money_true>(__loc); 
01369       const __money_false& __mpf = use_facet<__money_false>(__loc); 
01370       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
01371 
01372       // Determine if negative or positive formats are to be used, and
01373       // discard leading negative_sign if it is present.
01374       const char_type* __beg = __digits.data();
01375       const char_type* __end = __beg + __digits.size();
01376       money_base::pattern __p;
01377       string_type __sign;
01378       if (*__beg != __ctype.widen('-'))
01379     {
01380       __p = __intl ? __mpt.pos_format() : __mpf.pos_format();
01381       __sign =__intl ? __mpt.positive_sign() : __mpf.positive_sign();
01382     }
01383       else
01384     {
01385       __p = __intl ? __mpt.neg_format() : __mpf.neg_format();
01386       __sign =__intl ? __mpt.negative_sign() : __mpf.negative_sign();
01387       ++__beg;
01388     }
01389       
01390       // Look for valid numbers in the current ctype facet within input digits.
01391       __end = __ctype.scan_not(ctype_base::digit, __beg, __end);
01392       if (__beg != __end)
01393     {
01394       // Assume valid input, and attempt to format.
01395       // Break down input numbers into base components, as follows:
01396       //   final_value = grouped units + (decimal point) + (digits)
01397       string_type __res;
01398       string_type __value;
01399       const string_type __symbol = __intl ? __mpt.curr_symbol() 
01400                               : __mpf.curr_symbol();
01401 
01402       // Deal with decimal point, decimal digits.
01403       const int __frac = __intl ? __mpt.frac_digits() 
01404                         : __mpf.frac_digits();
01405       if (__frac > 0)
01406         {
01407           const char_type __d = __intl ? __mpt.decimal_point() 
01408                        : __mpf.decimal_point();
01409           if (__end - __beg >= __frac)
01410         {
01411           __value = string_type(__end - __frac, __end);
01412           __value.insert(__value.begin(), __d);
01413           __end -= __frac;
01414         }
01415           else
01416         {
01417           // Have to pad zeros in the decimal position.
01418           __value = string_type(__beg, __end);
01419           int __paddec = __frac - (__end - __beg);
01420           char_type __zero = __ctype.widen('0');
01421           __value.insert(__value.begin(), __paddec, __zero);
01422           __value.insert(__value.begin(), __d);
01423           __beg = __end;
01424         }
01425         }
01426 
01427       // Add thousands separators to non-decimal digits, per
01428       // grouping rules.
01429       if (__beg != __end)
01430         {
01431           const string __grouping = __intl ? __mpt.grouping() 
01432                            : __mpf.grouping();
01433           if (__grouping.size())
01434         {
01435           const char_type __sep = __intl ? __mpt.thousands_sep() 
01436                                  : __mpf.thousands_sep();
01437           const char* __gbeg = __grouping.c_str();
01438           const char* __gend = __gbeg + __grouping.size();
01439           const int __n = (__end - __beg) * 2;
01440           _CharT* __ws2 =
01441                   static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n));
01442           _CharT* __ws_end = __add_grouping(__ws2, __sep, __gbeg, 
01443                             __gend, __beg, __end);
01444           __value.insert(0, __ws2, __ws_end - __ws2);
01445         }
01446           else
01447         __value.insert(0, string_type(__beg, __end));
01448         }
01449 
01450       // Calculate length of resulting string.
01451       ios_base::fmtflags __f = __io.flags() & ios_base::adjustfield;
01452       size_type __len = __value.size() + __sign.size();
01453       __len += (__io.flags() & ios_base::showbase) ? __symbol.size() : 0;
01454       bool __testipad = __f == ios_base::internal && __len < __width;
01455 
01456       // Fit formatted digits into the required pattern.
01457       for (int __i = 0; __i < 4; ++__i)
01458         {
01459           part __which = static_cast<part>(__p.field[__i]);
01460           switch (__which)
01461         {
01462         case money_base::symbol:
01463           if (__io.flags() & ios_base::showbase)
01464             __res += __symbol;
01465           break;
01466         case money_base::sign:          
01467           // Sign might not exist, or be more than one
01468           // charater long. In that case, add in the rest
01469           // below.
01470           if (__sign.size())
01471             __res += __sign[0];
01472           break;
01473         case money_base::value:
01474           __res += __value;
01475           break;
01476         case money_base::space:
01477           // At least one space is required, but if internal
01478           // formatting is required, an arbitrary number of
01479           // fill spaces will be necessary.
01480           if (__testipad)
01481             __res += string_type(__width - __len, __fill);
01482           else
01483             __res += __ctype.widen(__fill);
01484           break;
01485         case money_base::none:
01486           if (__testipad)
01487             __res += string_type(__width - __len, __fill);
01488           break;
01489         }
01490         }
01491 
01492       // Special case of multi-part sign parts.
01493       if (__sign.size() > 1)
01494         __res += string_type(__sign.begin() + 1, __sign.end());
01495 
01496       // Pad, if still necessary.
01497       __len = __res.size();
01498       if (__width > __len)
01499         {
01500           if (__f == ios_base::left)
01501         // After.
01502         __res.append(__width - __len, __fill);
01503           else
01504         // Before.
01505         __res.insert(0, string_type(__width - __len, __fill));
01506           __len = __width;
01507         }
01508 
01509       // Write resulting, fully-formatted string to output iterator.
01510       __s = __write(__s, __res.c_str(), __len);
01511     }
01512       __io.width(0);
01513       return __s; 
01514     }
01515 
01516 
01517   // NB: Not especially useful. Without an ios_base object or some
01518   // kind of locale reference, we are left clawing at the air where
01519   // the side of the mountain used to be...
01520   template<typename _CharT, typename _InIter>
01521     time_base::dateorder
01522     time_get<_CharT, _InIter>::do_date_order() const
01523     { return time_base::no_order; }
01524 
01525   template<typename _CharT, typename _InIter>
01526     void
01527     time_get<_CharT, _InIter>::
01528     _M_extract_via_format(iter_type& __beg, iter_type& __end, ios_base& __io,
01529               ios_base::iostate& __err, tm* __tm, 
01530               const _CharT* __format) const
01531     {  
01532       locale __loc = __io.getloc();
01533       __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
01534       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
01535       size_t __len = char_traits<_CharT>::length(__format);
01536 
01537       for (size_t __i = 0; __beg != __end && __i < __len && !__err; ++__i)
01538     {
01539       char __c = __format[__i];
01540       if (__c == '%')
01541         {
01542           // Verify valid formatting code, attempt to extract.
01543           __c = __format[++__i];
01544           char __mod = 0;
01545           int __mem = 0; 
01546           if (__c == 'E' || __c == 'O')
01547         {
01548           __mod = __c;
01549           __c = __format[++__i];
01550         }
01551           switch (__c)
01552         {
01553           const char* __cs;
01554           _CharT __wcs[10];
01555         case 'a':
01556           // Abbreviated weekday name [tm_wday]
01557           const char_type*  __days1[7];
01558           __tp._M_days_abbreviated(__days1);
01559           _M_extract_name(__beg, __end, __tm->tm_wday, __days1, 7, 
01560                   __err);
01561           break;
01562         case 'A':
01563           // Weekday name [tm_wday].
01564           const char_type*  __days2[7];
01565           __tp._M_days(__days2);
01566           _M_extract_name(__beg, __end, __tm->tm_wday, __days2, 7, 
01567                   __err);
01568           break;
01569         case 'h':
01570         case 'b':
01571           // Abbreviated month name [tm_mon]
01572           const char_type*  __months1[12];
01573           __tp._M_months_abbreviated(__months1);
01574           _M_extract_name(__beg, __end, __tm->tm_mon, __months1, 12, 
01575                   __err);
01576           break;
01577         case 'B':
01578           // Month name [tm_mon].
01579           const char_type*  __months2[12];
01580           __tp._M_months(__months2);
01581           _M_extract_name(__beg, __end, __tm->tm_mon, __months2, 12, 
01582                   __err);
01583           break;
01584         case 'c':
01585           // Default time and date representation.
01586           const char_type*  __dt[2];
01587           __tp._M_date_time_formats(__dt);
01588           _M_extract_via_format(__beg, __end, __io, __err, __tm, 
01589                     __dt[0]);
01590           break;
01591         case 'd':
01592           // Day [01, 31]. [tm_mday]
01593           _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2, 
01594                  __ctype, __err);
01595           break;
01596         case 'D':
01597           // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
01598           __cs = "%m/%d/%y";
01599           __ctype.widen(__cs, __cs + 9, __wcs);
01600           _M_extract_via_format(__beg, __end, __io, __err, __tm, 
01601                     __wcs);
01602           break;
01603         case 'H':
01604           // Hour [00, 23]. [tm_hour]
01605           _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
01606                  __ctype, __err);
01607           break;
01608         case 'I':
01609           // Hour [01, 12]. [tm_hour]
01610           _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2, 
01611                  __ctype, __err);
01612           break;
01613         case 'm':
01614           // Month [01, 12]. [tm_mon]
01615           _M_extract_num(__beg, __end, __mem, 1, 12, 2, __ctype, 
01616                  __err);
01617           if (!__err)
01618             __tm->tm_mon = __mem - 1;
01619           break;
01620         case 'M':
01621           // Minute [00, 59]. [tm_min]
01622           _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
01623                  __ctype, __err);
01624           break;
01625         case 'n':
01626           if (__ctype.narrow(*__beg, 0) == '\n')
01627             ++__beg;
01628           else
01629             __err |= ios_base::failbit;
01630           break;
01631         case 'R':
01632           // Equivalent to (%H:%M).
01633           __cs = "%H:%M";
01634           __ctype.widen(__cs, __cs + 6, __wcs);
01635           _M_extract_via_format(__beg, __end, __io, __err, __tm, 
01636                     __wcs);
01637           break;
01638         case 'S':
01639           // Seconds.
01640           _M_extract_num(__beg, __end, __tm->tm_sec, 0, 59, 2,
01641                  __ctype, __err);
01642           break;
01643         case 't':
01644           if (__ctype.narrow(*__beg, 0) == '\t')
01645             ++__beg;
01646           else
01647         __err |= ios_base::failbit;
01648           break;
01649         case 'T':
01650           // Equivalent to (%H:%M:%S).
01651           __cs = "%H:%M:%S";
01652           __ctype.widen(__cs, __cs + 9, __wcs);
01653           _M_extract_via_format(__beg, __end, __io, __err, __tm, 
01654                     __wcs);
01655           break;
01656         case 'x':
01657           // Locale's date.
01658           const char_type*  __dates[2];
01659           __tp._M_date_formats(__dates);
01660           _M_extract_via_format(__beg, __end, __io, __err, __tm, 
01661                     __dates[0]);
01662           break;
01663         case 'X':
01664           // Locale's time.
01665           const char_type*  __times[2];
01666           __tp._M_time_formats(__times);
01667           _M_extract_via_format(__beg, __end, __io, __err, __tm, 
01668                     __times[0]);
01669           break;
01670         case 'y':
01671           // Two digit year. [tm_year]
01672           _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2, 
01673                  __ctype, __err);
01674           break;
01675         case 'Y':
01676           // Year [1900). [tm_year]
01677           _M_extract_num(__beg, __end, __mem, 0, 
01678                  numeric_limits<int>::max(), 4, 
01679                  __ctype, __err);
01680           if (!__err)
01681             __tm->tm_year = __mem - 1900;
01682           break;
01683         case 'Z':
01684           // Timezone info.
01685           if (__ctype.is(ctype_base::upper, *__beg))
01686             {
01687               int __tmp;
01688               _M_extract_name(__beg, __end, __tmp, 
01689                       __timepunct<_CharT>::_S_timezones, 
01690                       14, __err);
01691               
01692               // GMT requires special effort.
01693               char_type __c = *__beg;
01694               if (!__err && __tmp == 0 
01695               && (__c == __ctype.widen('-') 
01696                   || __c == __ctype.widen('+')))
01697             {
01698               _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
01699                       __ctype, __err);
01700               _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
01701                       __ctype, __err);
01702             }       
01703               }
01704               else
01705             __err |= ios_base::failbit;
01706               break;
01707             default:
01708               // Not recognized.
01709               __err |= ios_base::failbit;
01710             }
01711         }
01712           else
01713         {
01714           // Verify format and input match, extract and discard.
01715           if (__c == __ctype.narrow(*__beg, 0))
01716             ++__beg;
01717           else
01718             __err |= ios_base::failbit;
01719         }
01720     }
01721     }
01722 
01723   template<typename _CharT, typename _InIter>
01724     void
01725     time_get<_CharT, _InIter>::
01726     _M_extract_num(iter_type& __beg, iter_type& __end, int& __member,
01727            int __min, int __max, size_t __len, 
01728            const ctype<_CharT>& __ctype, 
01729            ios_base::iostate& __err) const
01730     {
01731       size_t __i = 0;
01732       string __digits;
01733       bool __testvalid = true;
01734       char_type __c = *__beg;
01735       while (__beg != __end && __i < __len 
01736          && __ctype.is(ctype_base::digit, __c)) 
01737     {
01738       __digits += __ctype.narrow(__c, 0);
01739       __c = *(++__beg);
01740       ++__i;
01741     }
01742       if (__i == __len)
01743     {
01744       int __value = atoi(__digits.c_str());
01745       if (__min <= __value && __value <= __max)
01746         __member = __value;
01747       else
01748         __testvalid = false;
01749     }
01750       else
01751     __testvalid = false;
01752       if (!__testvalid)
01753     __err |= ios_base::failbit;
01754     }
01755 
01756   // Assumptions:
01757   // All elements in __names are unique.
01758   template<typename _CharT, typename _InIter>
01759     void
01760     time_get<_CharT, _InIter>::
01761     _M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
01762             const _CharT** __names, size_t __indexlen, 
01763             ios_base::iostate& __err) const
01764     {
01765       typedef char_traits<_CharT>       __traits_type;
01766       int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int) 
01767                               * __indexlen));
01768       size_t __nmatches = 0;
01769       size_t __pos = 0;
01770       bool __testvalid = true;
01771       const char_type* __name;
01772 
01773       char_type __c = *__beg;
01774       // Look for initial matches.
01775       for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
01776     if (__c == __names[__i1][0])
01777       __matches[__nmatches++] = __i1;
01778       
01779       while (__nmatches > 1)
01780     {
01781       // Find smallest matching string.
01782       size_t __minlen = 10;
01783       for (size_t __i2 = 0; __i2 < __nmatches; ++__i2)
01784         __minlen = min(__minlen,
01785                __traits_type::length(__names[__matches[__i2]]));
01786       
01787       if (__pos < __minlen && __beg != __end)
01788         {
01789           ++__pos;
01790           __c = *(++__beg);
01791           for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)
01792         {
01793           __name = __names[__matches[__i3]];
01794           if (__name[__pos] != __c)
01795             __matches[__i3] = __matches[--__nmatches];
01796         }
01797         }
01798       else
01799         break;
01800     }
01801 
01802       if (__nmatches == 1)
01803     {
01804       // Make sure found name is completely extracted.
01805       __name = __names[__matches[0]];
01806       const size_t __len = __traits_type::length(__name);
01807       while (__pos < __len && __beg != __end && __name[__pos] == *__beg)
01808         ++__beg, ++__pos;
01809 
01810       if (__len == __pos)
01811         __member = __matches[0];
01812       else
01813         __testvalid = false;
01814     }
01815       else
01816     __testvalid = false;
01817       if (!__testvalid)
01818     __err |= ios_base::failbit;
01819     }
01820 
01821   template<typename _CharT, typename _InIter>
01822     _InIter
01823     time_get<_CharT, _InIter>::
01824     do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
01825         ios_base::iostate& __err, tm* __tm) const
01826     {
01827       _CharT __wcs[3];
01828       const char* __cs = "%X";
01829       locale __loc = __io.getloc();
01830       ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
01831       __ctype.widen(__cs, __cs + 3, __wcs);
01832       _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
01833       if (__beg == __end)
01834     __err |= ios_base::eofbit;
01835       return __beg;
01836     }
01837 
01838   template<typename _CharT, typename _InIter>
01839     _InIter
01840     time_get<_CharT, _InIter>::
01841     do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
01842         ios_base::iostate& __err, tm* __tm) const
01843     {
01844       _CharT __wcs[3];
01845       const char* __cs = "%x";
01846       locale __loc = __io.getloc();
01847       ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
01848       __ctype.widen(__cs, __cs + 3, __wcs);
01849       _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
01850       if (__beg == __end)
01851     __err |= ios_base::eofbit;
01852       return __beg;
01853     }
01854 
01855   template<typename _CharT, typename _InIter>
01856     _InIter
01857     time_get<_CharT, _InIter>::
01858     do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io, 
01859            ios_base::iostate& __err, tm* __tm) const
01860     {
01861       typedef char_traits<_CharT>       __traits_type;
01862       locale __loc = __io.getloc();
01863       __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
01864       const char_type*  __days[7];
01865       __tp._M_days_abbreviated(__days);
01866       int __tmpwday;
01867       _M_extract_name(__beg, __end, __tmpwday, __days, 7, __err);
01868 
01869       // Check to see if non-abbreviated name exists, and extract.
01870       // NB: Assumes both _M_days and _M_days_abbreviated organized in
01871       // exact same order, first to last, such that the resulting
01872       // __days array with the same index points to a day, and that
01873       // day's abbreviated form.
01874       // NB: Also assumes that an abbreviated name is a subset of the name. 
01875       if (!__err)
01876     {
01877       size_t __pos = __traits_type::length(__days[__tmpwday]);
01878       __tp._M_days(__days);
01879       const char_type* __name = __days[__tmpwday];
01880       if (__name[__pos] == *__beg)
01881         {
01882           // Extract the rest of it.
01883           const size_t __len = __traits_type::length(__name);
01884           while (__pos < __len && __beg != __end 
01885              && __name[__pos] == *__beg)
01886         ++__beg, ++__pos;
01887           if (__len != __pos)
01888         __err |= ios_base::failbit;
01889         }
01890       if (!__err)
01891         __tm->tm_wday = __tmpwday;
01892     }
01893       if (__beg == __end)
01894     __err |= ios_base::eofbit;
01895       return __beg;
01896      }
01897 
01898   template<typename _CharT, typename _InIter>
01899     _InIter
01900     time_get<_CharT, _InIter>::
01901     do_get_monthname(iter_type __beg, iter_type __end,
01902                      ios_base& __io, ios_base::iostate& __err, tm* __tm) const
01903     {
01904       typedef char_traits<_CharT>       __traits_type;
01905       locale __loc = __io.getloc();
01906       __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
01907       const char_type*  __months[12];
01908       __tp._M_months_abbreviated(__months);
01909       int __tmpmon;
01910       _M_extract_name(__beg, __end, __tmpmon, __months, 12, __err);
01911 
01912       // Check to see if non-abbreviated name exists, and extract.
01913       // NB: Assumes both _M_months and _M_months_abbreviated organized in
01914       // exact same order, first to last, such that the resulting
01915       // __months array with the same index points to a month, and that
01916       // month's abbreviated form.
01917       // NB: Also assumes that an abbreviated name is a subset of the name. 
01918       if (!__err)
01919     {
01920       size_t __pos = __traits_type::length(__months[__tmpmon]);
01921       __tp._M_months(__months);
01922       const char_type* __name = __months[__tmpmon];
01923       if (__name[__pos] == *__beg)
01924         {
01925           // Extract the rest of it.
01926           const size_t __len = __traits_type::length(__name);
01927           while (__pos < __len && __beg != __end 
01928              && __name[__pos] == *__beg)
01929         ++__beg, ++__pos;
01930           if (__len != __pos)
01931         __err |= ios_base::failbit;
01932         }
01933       if (!__err)
01934         __tm->tm_mon = __tmpmon;
01935     }
01936  
01937       if (__beg == __end)
01938     __err |= ios_base::eofbit;
01939       return __beg;
01940     }
01941 
01942   template<typename _CharT, typename _InIter>
01943     _InIter
01944     time_get<_CharT, _InIter>::
01945     do_get_year(iter_type __beg, iter_type __end, ios_base& __io, 
01946         ios_base::iostate& __err, tm* __tm) const
01947     {
01948       locale __loc = __io.getloc();
01949       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
01950 
01951       char_type __c = *__beg;
01952       size_t __i = 0;
01953       string __digits;
01954       while (__i < 4 && __beg != __end && __ctype.is(ctype_base::digit, __c))
01955     {
01956       __digits += __ctype.narrow(__c, 0);
01957       __c = *(++__beg);
01958       ++__i;
01959     }
01960       if (__i == 2 || __i == 4)
01961     {
01962       long __l;
01963       __convert_to_v(__digits.c_str(), __l, __err, _S_c_locale);
01964       if (!(__err & ios_base::failbit) && __l <= INT_MAX)
01965         {
01966           __l = __i == 2 ? __l : __l - 1900; 
01967           __tm->tm_year = static_cast<int>(__l);
01968         }
01969     }
01970       else
01971     __err |= ios_base::failbit;
01972       if (__beg == __end)
01973     __err |= ios_base::eofbit;
01974       return __beg;
01975     }
01976 
01977   template<typename _CharT, typename _OutIter>
01978     _OutIter
01979     time_put<_CharT, _OutIter>::
01980     put(iter_type __s, ios_base& __io, char_type, const tm* __tm, 
01981     const _CharT* __beg, const _CharT* __end) const
01982     {
01983       locale __loc = __io.getloc();
01984       ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
01985       while (__beg != __end)
01986     {
01987       char __c = __ctype.narrow(*__beg, 0);
01988       ++__beg;
01989       if (__c == '%')
01990         {
01991           char __format;
01992           char __mod = 0;
01993           size_t __len = 1; 
01994           __c = __ctype.narrow(*__beg, 0);
01995           ++__beg;
01996           if (__c == 'E' || __c == 'O')
01997         {
01998           __mod = __c;
01999           __format = __ctype.narrow(*__beg, 0);
02000           ++__beg;
02001         }
02002           else
02003         __format = __c;
02004           __s = this->do_put(__s, __io, _CharT(), __tm, __format, __mod);
02005         }
02006       else
02007         {
02008           *__s = __c;
02009           ++__s;
02010         }
02011     }
02012       return __s;
02013     }
02014 
02015   template<typename _CharT, typename _OutIter>
02016     _OutIter
02017     time_put<_CharT, _OutIter>::
02018     do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm, 
02019        char __format, char __mod) const
02020     { 
02021       locale __loc = __io.getloc();
02022       ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
02023       __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
02024 
02025       // NB: This size is arbitrary. Should this be a data member,
02026       // initialized at construction?
02027       const size_t __maxlen = 64;
02028       char_type* __res = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen));
02029 
02030       // NB: In IEE 1003.1-200x, and perhaps other locale models, it
02031       // is possible that the format character will be longer than one
02032       // character. Possibilities include 'E' or 'O' followed by a
02033       // format character: if __mod is not the default argument, assume
02034       // it's a valid modifier.
02035       char_type __fmt[4];
02036       __fmt[0] = __ctype.widen('%'); 
02037       if (!__mod)
02038     {
02039       __fmt[1] = __format;
02040       __fmt[2] = char_type();
02041     }
02042       else
02043     {
02044       __fmt[1] = __mod;
02045       __fmt[2] = __format;
02046       __fmt[3] = char_type();
02047     }
02048 
02049       __tp._M_put(__res, __maxlen, __fmt, __tm);
02050 
02051       // Write resulting, fully-formatted string to output iterator.
02052       return __write(__s, __res, char_traits<char_type>::length(__res));
02053     }
02054 
02055 
02056   // Generic version does nothing.
02057   template<typename _CharT>
02058     int
02059     collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const
02060     { return 0; }
02061 
02062   // Generic version does nothing.
02063   template<typename _CharT>
02064     size_t
02065     collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const
02066     { return 0; }
02067 
02068   template<typename _CharT>
02069     int
02070     collate<_CharT>::
02071     do_compare(const _CharT* __lo1, const _CharT* __hi1, 
02072            const _CharT* __lo2, const _CharT* __hi2) const
02073     { 
02074       // strcoll assumes zero-terminated strings so we make a copy
02075       // and then put a zero at the end.
02076       const string_type __one(__lo1, __hi1);
02077       const string_type __two(__lo2, __hi2);
02078 
02079       const _CharT* __p = __one.c_str();
02080       const _CharT* __pend = __one.c_str() + __one.length();
02081       const _CharT* __q = __two.c_str();
02082       const _CharT* __qend = __two.c_str() + __two.length();
02083 
02084       // strcoll stops when it sees a nul character so we break
02085       // the strings into zero-terminated substrings and pass those
02086       // to strcoll.
02087       for (;;)
02088     {
02089       int __res = _M_compare(__p, __q);
02090       if (__res)
02091         return __res;
02092 
02093       __p += char_traits<_CharT>::length(__p);
02094       __q += char_traits<_CharT>::length(__q);
02095       if (__p == __pend && __q == __qend)
02096         return 0;
02097       else if (__p == __pend)
02098         return -1;
02099       else if (__q == __qend)
02100         return 1;
02101 
02102       __p++;
02103       __q++;
02104     }
02105     }
02106 
02107  template<typename _CharT>
02108     typename collate<_CharT>::string_type
02109     collate<_CharT>::
02110     do_transform(const _CharT* __lo, const _CharT* __hi) const
02111     {
02112       // strxfrm assumes zero-terminated strings so we make a copy
02113       string_type __str(__lo, __hi);
02114 
02115       const _CharT* __p = __str.c_str();
02116       const _CharT* __pend = __str.c_str() + __str.length();
02117 
02118       size_t __len = (__hi - __lo) * 2;
02119 
02120       string_type __ret;
02121 
02122       // strxfrm stops when it sees a nul character so we break
02123       // the string into zero-terminated substrings and pass those
02124       // to strxfrm.
02125       for (;;)
02126     {
02127       // First try a buffer perhaps big enough.
02128       _CharT* __c =
02129         static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
02130       size_t __res = _M_transform(__c, __p, __len);
02131       // If the buffer was not large enough, try again with the
02132       // correct size.
02133       if (__res >= __len)
02134         {
02135           __len = __res + 1;
02136           __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
02137                               * __len));
02138           __res = _M_transform(__c, __p, __res + 1);
02139         }
02140 
02141       __ret.append(__c, __res);
02142       __p += char_traits<_CharT>::length(__p);
02143       if (__p == __pend)
02144         return __ret;
02145 
02146       __p++;
02147       __ret.push_back(_CharT());
02148     }
02149     }
02150 
02151  template<typename _CharT>
02152     long
02153     collate<_CharT>::
02154     do_hash(const _CharT* __lo, const _CharT* __hi) const
02155     { 
02156       unsigned long __val = 0;
02157       for (; __lo < __hi; ++__lo)
02158     __val = *__lo + ((__val << 7) | 
02159                (__val >> (numeric_limits<unsigned long>::digits - 7)));
02160       return static_cast<long>(__val);
02161     }
02162 
02163   // Construct correctly padded string, as per 22.2.2.2.2
02164   // Assumes 
02165   // __newlen > __oldlen
02166   // __news is allocated for __newlen size
02167   // Used by both num_put and ostream inserters: if __num,
02168   // internal-adjusted objects are padded according to the rules below
02169   // concerning 0[xX] and +-, otherwise, exactly as right-adjusted
02170   // ones are.
02171 
02172   // NB: Of the two parameters, _CharT can be deduced from the
02173   // function arguments. The other (_Traits) has to be explicitly specified.
02174   template<typename _CharT, typename _Traits>
02175     void 
02176     __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill, 
02177                    _CharT* __news, const _CharT* __olds, 
02178                    const streamsize __newlen, 
02179                    const streamsize __oldlen, const bool __num)
02180     {
02181       const size_t __plen = static_cast<size_t>(__newlen - __oldlen);
02182       const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
02183 
02184       // Padding last.
02185       if (__adjust == ios_base::left)
02186     {
02187       _Traits::copy(__news, const_cast<_CharT*>(__olds), __oldlen);
02188       _Traits::assign(__news + __oldlen, __plen, __fill);
02189       return;
02190     }
02191 
02192       size_t __mod = 0;
02193       if (__adjust == ios_base::internal && __num)
02194     {
02195       // Pad after the sign, if there is one.
02196       // Pad after 0[xX], if there is one.
02197       // Who came up with these rules, anyway? Jeeze.
02198           const locale& __loc = __io.getloc();
02199       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
02200       const _CharT __minus = __ctype.widen('-');
02201       const _CharT __plus = __ctype.widen('+');
02202       const bool __testsign = _Traits::eq(__olds[0], __minus)
02203                               || _Traits::eq(__olds[0], __plus);
02204 
02205       const bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0]) 
02206                              && (_Traits::eq(__ctype.widen('x'), __olds[1]) 
02207                      || _Traits::eq(__ctype.widen('X'), __olds[1]));
02208       if (__testhex)
02209         {
02210           __news[0] = __olds[0]; 
02211           __news[1] = __olds[1];
02212           __mod = 2;
02213           __news += 2;
02214         }
02215       else if (__testsign)
02216         {
02217           __news[0] = __olds[0];
02218           __mod = 1;
02219           ++__news;
02220         }
02221       // else Padding first.
02222     }
02223       _Traits::assign(__news, __plen, __fill);
02224       _Traits::copy(__news + __plen, const_cast<_CharT*>(__olds + __mod),
02225             __oldlen - __mod);
02226     }
02227 
02228   template<typename _CharT>
02229     bool
02230     __verify_grouping(const basic_string<_CharT>& __grouping, 
02231               basic_string<_CharT>& __grouping_tmp)
02232     { 
02233       const size_t __n = __grouping_tmp.size() - 1;
02234       const size_t __min = std::min(__n, __grouping.size() - 1);
02235       size_t __i = __n;
02236       bool __test = true;
02237 
02238       // Parsed number groupings have to match the
02239       // numpunct::grouping string exactly, starting at the
02240       // right-most point of the parsed sequence of elements ...
02241       for (size_t __j = 0; __j < __min && __test; --__i, ++__j)
02242     __test = __grouping_tmp[__i] == __grouping[__j];
02243       for (; __i && __test; --__i)
02244     __test = __grouping_tmp[__i] == __grouping[__min];
02245       // ... but the last parsed grouping can be <= numpunct
02246       // grouping.
02247       __test &= __grouping_tmp[0] <= __grouping[__min];
02248       return __test;
02249     }
02250 
02251   template<typename _CharT>
02252     _CharT*
02253     __add_grouping(_CharT* __s, _CharT __sep,  
02254            const char* __gbeg, const char* __gend, 
02255            const _CharT* __first, const _CharT* __last)
02256     {
02257       if (__last - __first > *__gbeg)
02258         {
02259           __s = __add_grouping(__s,  __sep, 
02260                    (__gbeg + 1 == __gend ? __gbeg : __gbeg + 1),
02261                    __gend, __first, __last - *__gbeg);
02262           __first = __last - *__gbeg;
02263           *__s++ = __sep;
02264         }
02265       do
02266     *__s++ = *__first++;
02267       while (__first != __last);
02268       return __s;
02269     }
02270 
02271 #if 1
02272       // XXX GLIBCXX_ABI Deprecated, compatibility only.
02273   template<typename _CharT, typename _OutIter>
02274     template<typename _ValueT>
02275       _OutIter
02276       num_put<_CharT, _OutIter>::
02277       _M_convert_int(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
02278              char __modl, _ValueT __v) const
02279       {
02280     // [22.2.2.2.2] Stage 1, numeric conversion to character.
02281 
02282     // Long enough for the max format spec.
02283     char __fbuf[16];
02284     _S_format_int(__io, __fbuf, __mod, __modl);
02285 #ifdef _GLIBCPP_USE_C99
02286     // First try a buffer perhaps big enough.
02287     int __cs_size = 64;
02288     char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
02289     int __len = __convert_from_v(__cs, __cs_size, __fbuf, __v, 
02290                      _S_c_locale);
02291     // If the buffer was not large enough, try again with the correct size.
02292     if (__len >= __cs_size)
02293       {
02294         __cs_size = __len + 1;
02295         __cs = static_cast<char*>(__builtin_alloca(__cs_size));
02296         __len = __convert_from_v(__cs, __cs_size, __fbuf, __v, 
02297                      _S_c_locale);
02298       }
02299 #else
02300     // Leave room for "+/-," "0x," and commas. This size is
02301     // arbitrary, but should be largely sufficient.
02302     char __cs[128];
02303     int __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale);
02304 #endif
02305     return _M_widen_int(__s, __io, __fill, __cs, __len);
02306       }
02307 
02308   template<typename _CharT, typename _OutIter>
02309     _OutIter
02310     num_put<_CharT, _OutIter>::
02311     _M_widen_float(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs, 
02312            int __len) const
02313     {
02314       typedef char_traits<_CharT>       __traits_type;
02315       // [22.2.2.2.2] Stage 2, convert to char_type, using correct
02316       // numpunct.decimal_point() values for '.' and adding grouping.
02317       const locale __loc = __io.getloc();
02318       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
02319       _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
02320                                * __len));
02321       // Grouping can add (almost) as many separators as the number of
02322       // digits, but no more.
02323       _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
02324                                 * __len * 2));
02325       __ctype.widen(__cs, __cs + __len, __ws);
02326       
02327       // Replace decimal point.
02328       const _CharT* __p;
02329       const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
02330       if (__p = __traits_type::find(__ws, __len, __ctype.widen('.')))
02331     __ws[__p - __ws] = __np.decimal_point();
02332 
02333 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
02334 //282. What types does numpunct grouping refer to?
02335       // Add grouping, if necessary. 
02336       const string __grouping = __np.grouping();
02337       if (__grouping.size())
02338     {
02339       _CharT* __p2;
02340       int __declen = __p ? __p - __ws : __len;
02341       __p2 = __add_grouping(__ws2, __np.thousands_sep(), 
02342                 __grouping.c_str(),
02343                 __grouping.c_str() + __grouping.size(),
02344                 __ws, __ws + __declen);
02345       int __newlen = __p2 - __ws2;
02346     
02347       // Tack on decimal part.
02348       if (__p)
02349         {
02350           __traits_type::copy(__p2, __p, __len - __declen);
02351           __newlen += __len - __declen;
02352         }    
02353 
02354       // Switch strings, establish correct new length.
02355       __ws = __ws2;
02356       __len = __newlen;
02357     }
02358 #endif
02359       return _M_insert(__s, __io, __fill, __ws, __len);
02360     }
02361 
02362   template<typename _CharT, typename _OutIter>
02363     _OutIter
02364     num_put<_CharT, _OutIter>::
02365     _M_widen_int(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs, 
02366          int __len) const
02367     {
02368       // [22.2.2.2.2] Stage 2, convert to char_type, using correct
02369       // numpunct.decimal_point() values for '.' and adding grouping.
02370       const locale __loc = __io.getloc();
02371       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
02372       _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
02373                                * __len));
02374       // Grouping can add (almost) as many separators as the number of
02375       // digits, but no more.
02376       _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
02377                                 * __len * 2));
02378       __ctype.widen(__cs, __cs + __len, __ws);
02379 
02380       // Add grouping, if necessary. 
02381       const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
02382       const string __grouping = __np.grouping();
02383       if (__grouping.size())
02384     {
02385       // By itself __add_grouping cannot deal correctly with __ws when
02386       // ios::showbase is set and ios_base::oct || ios_base::hex.
02387       // Therefore we take care "by hand" of the initial 0, 0x or 0X.
02388       // However, remember that the latter do not occur if the number
02389       // printed is '0' (__len == 1).
02390       streamsize __off = 0;
02391       const ios_base::fmtflags __basefield = __io.flags() 
02392                              & ios_base::basefield;
02393       if ((__io.flags() & ios_base::showbase) && __len > 1)
02394         if (__basefield == ios_base::oct)
02395           {
02396         __off = 1;
02397         *__ws2 = *__ws;
02398           }
02399         else if (__basefield == ios_base::hex)
02400           {
02401         __off = 2;
02402         *__ws2 = *__ws;
02403         *(__ws2 + 1) = *(__ws + 1);
02404           }
02405       _CharT* __p;
02406       __p = __add_grouping(__ws2 + __off, __np.thousands_sep(), 
02407                    __grouping.c_str(),
02408                    __grouping.c_str() + __grouping.size(),
02409                    __ws + __off, __ws + __len);
02410       __len = __p - __ws2;
02411       // Switch strings.
02412       __ws = __ws2;
02413     }
02414       return _M_insert(__s, __io, __fill, __ws, __len);
02415     }
02416 
02417   // For use by integer and floating-point types after they have been
02418   // converted into a char_type string.
02419   template<typename _CharT, typename _OutIter>
02420     _OutIter
02421     num_put<_CharT, _OutIter>::
02422     _M_insert(_OutIter __s, ios_base& __io, _CharT __fill, const _CharT* __ws, 
02423           int __len) const
02424     {
02425       typedef char_traits<_CharT>       __traits_type;
02426       // [22.2.2.2.2] Stage 3.
02427       // If necessary, pad.
02428       streamsize __w = __io.width();
02429       _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
02430                                 * __w));
02431       if (__w > static_cast<streamsize>(__len))
02432     {
02433       __pad<_CharT, __traits_type>::_S_pad(__io, __fill, __ws2, __ws, 
02434                            __w, __len, true);
02435       __len = static_cast<int>(__w);
02436       // Switch strings.
02437       __ws = __ws2;
02438     }
02439       __io.width(0);
02440 
02441       // [22.2.2.2.2] Stage 4.
02442       // Write resulting, fully-formatted string to output iterator.
02443       return __write(__s, __ws, __len);
02444     }
02445 #endif
02446 
02447   template<typename _CharT>
02448     __locale_cache<numpunct<_CharT> >::__locale_cache(const locale& __loc)
02449       : _M_truename(0), _M_falsename(0), _M_use_grouping(false),
02450     _M_grouping(0)
02451     {
02452       if (has_facet<numpunct<_CharT> >(__loc))
02453     {
02454       const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
02455       _M_decimal_point = __np.decimal_point();
02456       _M_thousands_sep = __np.thousands_sep();
02457 
02458       string_type __false = __np.falsename();
02459       _CharT* __falsename = new _CharT[__false.length() + 1];
02460       __false.copy(__falsename, __false.length());
02461       __falsename[__false.length()] = _CharT();
02462       _M_falsename = __falsename;
02463 
02464       string_type __true = __np.truename();
02465       _CharT* __truename = new _CharT[__true.length() + 1];
02466       __true.copy(__truename, __true.length());
02467       __truename[__true.length()] = _CharT();
02468       _M_truename = __truename;
02469 
02470       string __grouping = __np.grouping();
02471       char* __group = new char[__grouping.length() + 1];
02472       __grouping.copy(__group, __grouping.length());
02473       __group[__grouping.length()] = 0;
02474       _M_grouping = __group;
02475 
02476       _M_use_grouping = __grouping.length() != 0 
02477         && __grouping.data()[0] != 0;
02478     }
02479 
02480       if (has_facet<ctype<_CharT> >(__loc))
02481     {
02482       const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
02483       __ct.widen(__num_base::_S_atoms_out,
02484              __num_base::_S_atoms_out + __num_base::_S_end, 
02485              _M_atoms_out);
02486     }
02487     }
02488 
02489   // Static locale cache initialization.  Only instantiated with char
02490   // and wchar_t, so no need to check has_facet.
02491   template<typename _CharT>
02492     __locale_cache<numpunct<_CharT> >::
02493     __locale_cache(const locale& __loc, bool)
02494     {
02495       // Grab pointers to numpunct static strings
02496       const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
02497       _M_thousands_sep = __np._M_thousands_sep;
02498       _M_decimal_point = __np._M_decimal_point;
02499       _M_falsename = __np._M_falsename;
02500       _M_truename = __np._M_truename;
02501       _M_grouping = __np._M_grouping;
02502       _M_use_grouping = false;
02503 
02504       const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
02505       __ct.widen(__num_base::_S_atoms_out,
02506          __num_base::_S_atoms_out + __num_base::_S_end, 
02507          _M_atoms_out);
02508     }
02509 
02510   // Inhibit implicit instantiations for required instantiations,
02511   // which are defined via explicit instantiations elsewhere.  
02512   // NB: This syntax is a GNU extension.
02513 #if _GLIBCPP_EXTERN_TEMPLATE
02514   extern template class moneypunct<char, false>;
02515   extern template class moneypunct<char, true>;
02516   extern template class moneypunct_byname<char, false>;
02517   extern template class moneypunct_byname<char, true>;
02518   extern template class money_get<char>;
02519   extern template class money_put<char>;
02520   extern template class numpunct<char>;
02521   extern template class numpunct_byname<char>;
02522   extern template class num_get<char>;
02523   extern template class num_put<char>; 
02524   extern template class __timepunct<char>;
02525   extern template class time_put<char>;
02526   extern template class time_put_byname<char>;
02527   extern template class time_get<char>;
02528   extern template class time_get_byname<char>;
02529   extern template class messages<char>;
02530   extern template class messages_byname<char>;
02531   extern template class ctype_byname<char>;
02532   extern template class codecvt_byname<char, char, mbstate_t>;
02533   extern template class collate<char>;
02534   extern template class collate_byname<char>;
02535 
02536   extern template
02537     const codecvt<char, char, mbstate_t>& 
02538     use_facet<codecvt<char, char, mbstate_t> >(const locale&);
02539 
02540   extern template
02541     const collate<char>& 
02542     use_facet<collate<char> >(const locale&);
02543 
02544   extern template
02545     const numpunct<char>& 
02546     use_facet<numpunct<char> >(const locale&);
02547 
02548   extern template 
02549     const num_put<char>& 
02550     use_facet<num_put<char> >(const locale&);
02551 
02552   extern template 
02553     const num_get<char>& 
02554     use_facet<num_get<char> >(const locale&);
02555 
02556   extern template
02557     const moneypunct<char, true>& 
02558     use_facet<moneypunct<char, true> >(const locale&);
02559 
02560   extern template
02561     const moneypunct<char, false>& 
02562     use_facet<moneypunct<char, false> >(const locale&);
02563 
02564   extern template 
02565     const money_put<char>& 
02566     use_facet<money_put<char> >(const locale&);
02567 
02568   extern template 
02569     const money_get<char>& 
02570     use_facet<money_get<char> >(const locale&);
02571 
02572   extern template
02573     const __timepunct<char>& 
02574     use_facet<__timepunct<char> >(const locale&);
02575 
02576   extern template 
02577     const time_put<char>& 
02578     use_facet<time_put<char> >(const locale&);
02579 
02580   extern template 
02581     const time_get<char>& 
02582     use_facet<time_get<char> >(const locale&);
02583 
02584   extern template 
02585     const messages<char>& 
02586     use_facet<messages<char> >(const locale&);
02587 
02588   extern template 
02589     bool
02590     has_facet<ctype<char> >(const locale&);
02591 
02592   extern template 
02593     bool
02594     has_facet<codecvt<char, char, mbstate_t> >(const locale&);
02595 
02596   extern template 
02597     bool
02598     has_facet<collate<char> >(const locale&);
02599 
02600   extern template 
02601     bool
02602     has_facet<numpunct<char> >(const locale&);
02603 
02604   extern template 
02605     bool
02606     has_facet<num_put<char> >(const locale&);
02607 
02608   extern template 
02609     bool
02610     has_facet<num_get<char> >(const locale&);
02611 
02612   extern template 
02613     bool
02614     has_facet<moneypunct<char> >(const locale&);
02615 
02616   extern template 
02617     bool
02618     has_facet<money_put<char> >(const locale&);
02619 
02620   extern template 
02621     bool
02622     has_facet<money_get<char> >(const locale&);
02623 
02624   extern template 
02625     bool
02626     has_facet<__timepunct<char> >(const locale&);
02627 
02628   extern template 
02629     bool
02630     has_facet<time_put<char> >(const locale&);
02631 
02632   extern template 
02633     bool
02634     has_facet<time_get<char> >(const locale&);
02635 
02636   extern template 
02637     bool
02638     has_facet<messages<char> >(const locale&);
02639 
02640 #ifdef _GLIBCPP_USE_WCHAR_T
02641   extern template class moneypunct<wchar_t, false>;
02642   extern template class moneypunct<wchar_t, true>;
02643   extern template class moneypunct_byname<wchar_t, false>;
02644   extern template class moneypunct_byname<wchar_t, true>;
02645   extern template class money_get<wchar_t>;
02646   extern template class money_put<wchar_t>;
02647   extern template class numpunct<wchar_t>;
02648   extern template class numpunct_byname<wchar_t>;
02649   extern template class num_get<wchar_t>;
02650   extern template class num_put<wchar_t>;
02651   extern template class __timepunct<wchar_t>;
02652   extern template class time_put<wchar_t>;
02653   extern template class time_put_byname<wchar_t>;
02654   extern template class time_get<wchar_t>;
02655   extern template class time_get_byname<wchar_t>;
02656   extern template class messages<wchar_t>;
02657   extern template class messages_byname<wchar_t>;
02658   extern template class ctype_byname<wchar_t>;
02659   extern template class codecvt_byname<wchar_t, char, mbstate_t>;
02660   extern template class collate<wchar_t>;
02661   extern template class collate_byname<wchar_t>;
02662 
02663   extern template
02664     const codecvt<wchar_t, char, mbstate_t>& 
02665     use_facet<codecvt<wchar_t, char, mbstate_t> >(locale const&);
02666 
02667   extern template
02668     const collate<wchar_t>& 
02669     use_facet<collate<wchar_t> >(const locale&);
02670 
02671   extern template
02672     const numpunct<wchar_t>& 
02673     use_facet<numpunct<wchar_t> >(const locale&);
02674 
02675   extern template 
02676     const num_put<wchar_t>& 
02677     use_facet<num_put<wchar_t> >(const locale&);
02678 
02679   extern template 
02680     const num_get<wchar_t>& 
02681     use_facet<num_get<wchar_t> >(const locale&);
02682 
02683   extern template
02684     const moneypunct<wchar_t, true>& 
02685     use_facet<moneypunct<wchar_t, true> >(const locale&);
02686 
02687   extern template
02688     const moneypunct<wchar_t, false>& 
02689     use_facet<moneypunct<wchar_t, false> >(const locale&);
02690  
02691   extern template 
02692     const money_put<wchar_t>& 
02693     use_facet<money_put<wchar_t> >(const locale&);
02694 
02695   extern template 
02696     const money_get<wchar_t>& 
02697     use_facet<money_get<wchar_t> >(const locale&);
02698 
02699   extern template
02700     const __timepunct<wchar_t>& 
02701     use_facet<__timepunct<wchar_t> >(const locale&);
02702 
02703   extern template 
02704     const time_put<wchar_t>& 
02705     use_facet<time_put<wchar_t> >(const locale&);
02706 
02707   extern template 
02708     const time_get<wchar_t>& 
02709     use_facet<time_get<wchar_t> >(const locale&);
02710 
02711   extern template 
02712     const messages<wchar_t>& 
02713     use_facet<messages<wchar_t> >(const locale&);
02714 
02715  extern template 
02716     bool
02717     has_facet<ctype<wchar_t> >(const locale&);
02718 
02719   extern template 
02720     bool
02721     has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
02722 
02723   extern template 
02724     bool
02725     has_facet<collate<wchar_t> >(const locale&);
02726 
02727   extern template 
02728     bool
02729     has_facet<numpunct<wchar_t> >(const locale&);
02730 
02731   extern template 
02732     bool
02733     has_facet<num_put<wchar_t> >(const locale&);
02734 
02735   extern template 
02736     bool
02737     has_facet<num_get<wchar_t> >(const locale&);
02738 
02739   extern template 
02740     bool
02741     has_facet<moneypunct<wchar_t> >(const locale&);
02742 
02743   extern template 
02744     bool
02745     has_facet<money_put<wchar_t> >(const locale&);
02746 
02747   extern template 
02748     bool
02749     has_facet<money_get<wchar_t> >(const locale&);
02750 
02751   extern template 
02752     bool
02753     has_facet<__timepunct<wchar_t> >(const locale&);
02754 
02755   extern template 
02756     bool
02757     has_facet<time_put<wchar_t> >(const locale&);
02758 
02759   extern template 
02760     bool
02761     has_facet<time_get<wchar_t> >(const locale&);
02762 
02763   extern template 
02764     bool
02765     has_facet<messages<wchar_t> >(const locale&);
02766 #endif
02767 #endif
02768 } // namespace std
02769 
02770 #endif

Generated on Mon Feb 16 13:27:53 2004 for libstdc++-v3 Source by doxygen 1.3.4