1 // Locale support -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 // Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
31 // Warning: this file is not meant for user inclusion. Use <locale>.
33 #ifndef _LOCALE_FACETS_TCC
34 #define _LOCALE_FACETS_TCC 1
36 #pragma GCC system_header
38 #include <limits> // For numeric_limits
39 #include <typeinfo> // For bad_cast.
40 #include <bits/streambuf_iterator.h>
44 template<typename _Facet>
46 locale::combine(const locale& __other) const
48 _Impl* __tmp = new _Impl(*_M_impl, 1);
51 __tmp->_M_replace_facet(__other._M_impl, &_Facet::id);
55 __tmp->_M_remove_reference();
56 __throw_exception_again;
61 template<typename _CharT, typename _Traits, typename _Alloc>
63 locale::operator()(const basic_string<_CharT, _Traits, _Alloc>& __s1,
64 const basic_string<_CharT, _Traits, _Alloc>& __s2) const
66 typedef std::collate<_CharT> __collate_type;
67 const __collate_type& __collate = use_facet<__collate_type>(*this);
68 return (__collate.compare(__s1.data(), __s1.data() + __s1.length(),
69 __s2.data(), __s2.data() + __s2.length()) < 0);
72 template<typename _Facet>
74 has_facet(const locale& __loc) throw()
76 const size_t __i = _Facet::id._M_id();
77 const locale::facet** __facets = __loc._M_impl->_M_facets;
78 return (__i < __loc._M_impl->_M_facets_size && __facets[__i]);
81 template<typename _Facet>
83 use_facet(const locale& __loc)
85 const size_t __i = _Facet::id._M_id();
86 const locale::facet** __facets = __loc._M_impl->_M_facets;
87 if (!(__i < __loc._M_impl->_M_facets_size && __facets[__i]))
89 return static_cast<const _Facet&>(*__facets[__i]);
92 // Routine to access a cache for the facet. If the cache didn't
93 // exist before, it gets constructed on the fly.
94 template<typename _Facet>
98 operator() (const locale& __loc) const;
101 template<typename _CharT>
102 struct __use_cache<__numpunct_cache<_CharT> >
104 const __numpunct_cache<_CharT>*
105 operator() (const locale& __loc) const
107 const size_t __i = numpunct<_CharT>::id._M_id();
108 const locale::facet** __caches = __loc._M_impl->_M_caches;
111 __numpunct_cache<_CharT>* __tmp = NULL;
114 __tmp = new __numpunct_cache<_CharT>;
115 __tmp->_M_cache(__loc);
120 __throw_exception_again;
122 __loc._M_impl->_M_install_cache(__tmp, __i);
124 return static_cast<const __numpunct_cache<_CharT>*>(__caches[__i]);
128 template<typename _CharT, typename _InIter>
130 num_get<_CharT, _InIter>::
131 _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io,
132 ios_base::iostate& __err, string& __xtrc) const
134 typedef char_traits<_CharT> __traits_type;
135 typedef typename numpunct<_CharT>::__cache_type __cache_type;
136 __use_cache<__cache_type> __uc;
137 const locale& __loc = __io._M_getloc();
138 const __cache_type* __lc = __uc(__loc);
139 const _CharT* __lit = __lc->_M_atoms_in;
141 // First check for sign.
144 const char_type __c = *__beg;
145 const bool __plus = __traits_type::eq(__c, __lit[_S_iplus]);
146 if (__plus || __traits_type::eq(__c, __lit[_S_iminus]))
148 __xtrc += __plus ? _S_atoms_in[_S_iplus]
149 : _S_atoms_in[_S_iminus];
154 // Next, look for a zero...
155 bool __found_mantissa = false;
156 if (__beg != __end && __traits_type::eq(*__beg, __lit[_S_izero]))
158 __xtrc += _S_atoms_in[_S_izero];
159 __found_mantissa = true;
161 // ... and skip the additional ones.
162 for (; __beg != __end
163 && __traits_type::eq(*__beg, __lit[_S_izero]); ++__beg);
166 // Only need acceptable digits for floating point numbers.
167 bool __found_dec = false;
168 bool __found_sci = false;
169 string __found_grouping;
172 for (; __beg != __end; ++__beg)
174 // Only look in digits.
175 const char_type __c = *__beg;
176 const char_type* __p = __traits_type::find(__lit + _S_izero, 10,
178 // NB: strchr returns true for *__beg == 0x0
179 if (__p && !__traits_type::eq(__c, char_type()))
181 // Try first for acceptable digit; record it if found.
182 __xtrc += _S_atoms_in[__p - __lit];
183 __found_mantissa = true;
186 else if (__traits_type::eq(__c, __lc->_M_thousands_sep)
187 && __lc->_M_use_grouping && !__found_dec)
189 // NB: Thousands separator at the beginning of a string
190 // is a no-no, as is two consecutive thousands separators.
193 __found_grouping += static_cast<char>(__sep_pos);
198 __err |= ios_base::failbit;
202 else if (__traits_type::eq(__c, __lc->_M_decimal_point)
205 // According to the standard, if no grouping chars are seen,
206 // no grouping check is applied. Therefore __found_grouping
207 // must be adjusted only if __dec comes after some __sep.
208 if (__found_grouping.size())
209 __found_grouping += static_cast<char>(__sep_pos);
213 else if ((__e = __traits_type::eq(__c, __lit[_S_ie])
214 || __traits_type::eq(__c, __lit[_S_iE]))
215 && __found_mantissa && !__found_sci)
217 // Scientific notation.
218 __xtrc += __e ? _S_atoms_in[_S_ie] : _S_atoms_in[_S_iE];
220 // Remove optional plus or minus sign, if they exist.
221 if (++__beg != __end)
223 const bool __plus = __traits_type::eq(*__beg, __lit[_S_iplus]);
224 if (__plus || __traits_type::eq(*__beg, __lit[_S_iminus]))
225 __xtrc += __plus ? _S_atoms_in[_S_iplus]
226 : _S_atoms_in[_S_iminus];
233 // Not a valid input item.
237 // Digit grouping is checked. If grouping and found_grouping don't
238 // match, then get very very upset, and set failbit.
239 if (__lc->_M_use_grouping && __found_grouping.size())
241 // Add the ending grouping if a decimal wasn't found.
243 __found_grouping += static_cast<char>(__sep_pos);
245 const string __grouping = __lc->_M_grouping;
246 if (!std::__verify_grouping(__grouping, __found_grouping))
247 __err |= ios_base::failbit;
253 __err |= ios_base::eofbit;
257 template<typename _CharT, typename _InIter>
259 num_get<_CharT, _InIter>::
260 _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
261 ios_base::iostate& __err, string& __xtrc, int& __base) const
263 typedef char_traits<_CharT> __traits_type;
264 typedef typename numpunct<_CharT>::__cache_type __cache_type;
265 __use_cache<__cache_type> __uc;
266 const locale& __loc = __io._M_getloc();
267 const __cache_type* __lc = __uc(__loc);
268 const _CharT* __lit = __lc->_M_atoms_in;
270 // NB: Iff __basefield == 0, this can change based on contents.
271 const ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
272 if (__basefield == ios_base::oct)
274 else if (__basefield == ios_base::hex)
279 // First check for sign.
282 const char_type __c = *__beg;
283 const bool __plus = __traits_type::eq(__c, __lit[_S_iplus]);
284 if (__plus || __traits_type::eq(__c, __lit[_S_iminus]))
286 __xtrc += __plus ? _S_atoms_in[_S_iplus]
287 : _S_atoms_in[_S_iminus];
292 // Next, look for leading zeros and check required digits for base formats.
293 if (__builtin_expect(__base == 10, true))
295 // Look for a zero...
296 if (__beg != __end && __traits_type::eq(*__beg, __lit[_S_izero]))
298 __xtrc += _S_atoms_in[_S_izero];
300 // ... and skip the additional ones.
301 for (; __beg != __end
302 && __traits_type::eq(*__beg, __lit[_S_izero]); ++__beg);
304 // Check required digits.
305 if (__beg != __end && __basefield == 0)
307 const bool __x = __traits_type::eq(*__beg, __lit[_S_ix]);
308 if (__x || __traits_type::eq(*__beg, __lit[_S_iX]))
310 __xtrc += __x ? _S_atoms_in[_S_ix]
311 : _S_atoms_in[_S_iX];
320 else if (__base == 16)
322 if (__beg != __end && __traits_type::eq(*__beg, __lit[_S_izero]))
324 __xtrc += _S_atoms_in[_S_izero];
326 if (++__beg != __end)
328 const bool __x = __traits_type::eq(*__beg, __lit[_S_ix]);
329 if (__x || __traits_type::eq(*__beg, __lit[_S_iX]))
331 __xtrc += __x ? _S_atoms_in[_S_ix]
332 : _S_atoms_in[_S_iX];
339 // At this point, base is determined. If not hex, only allow
340 // base digits as valid input.
341 const size_t __len = __base == 16 ? _S_iend : __base;
344 string __found_grouping;
346 for (; __beg != __end; ++__beg)
348 const char_type __c = *__beg;
349 const char_type* __p = __traits_type::find(__lit + _S_izero,
351 // NB: strchr returns true for __c == 0x0
352 if (__p && !__traits_type::eq(__c, char_type()))
354 // Try first for acceptable digit; record it if found.
355 __xtrc += _S_atoms_in[__p - __lit];
358 else if (__traits_type::eq(__c, __lc->_M_thousands_sep)
359 && __lc->_M_use_grouping)
361 // NB: Thousands separator at the beginning of a string
362 // is a no-no, as is two consecutive thousands separators.
365 __found_grouping += static_cast<char>(__sep_pos);
370 __err |= ios_base::failbit;
375 // Not a valid input item.
379 // Digit grouping is checked. If grouping and found_grouping don't
380 // match, then get very very upset, and set failbit.
381 if (__lc->_M_use_grouping && __found_grouping.size())
383 // Add the ending grouping.
384 __found_grouping += static_cast<char>(__sep_pos);
386 const string __grouping = __lc->_M_grouping;
387 if (!std::__verify_grouping(__grouping, __found_grouping))
388 __err |= ios_base::failbit;
394 __err |= ios_base::eofbit;
398 // _GLIBCXX_RESOLVE_LIB_DEFECTS
399 // 17. Bad bool parsing
400 template<typename _CharT, typename _InIter>
402 num_get<_CharT, _InIter>::
403 do_get(iter_type __beg, iter_type __end, ios_base& __io,
404 ios_base::iostate& __err, bool& __v) const
406 if (!(__io.flags() & ios_base::boolalpha))
408 // Parse bool values as unsigned long.
409 // NB: We can't just call do_get(long) here, as it might
410 // refer to a derived class.
413 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
416 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
417 _S_get_c_locale(), __base);
418 if (!(__err & ios_base::failbit) && __ul <= 1)
421 __err |= ios_base::failbit;
425 // Parse bool values as alphanumeric.
426 typedef char_traits<_CharT> __traits_type;
427 typedef typename numpunct<_CharT>::__cache_type __cache_type;
428 __use_cache<__cache_type> __uc;
429 const locale& __loc = __io._M_getloc();
430 const __cache_type* __lc = __uc(__loc);
431 const size_t __tn = __traits_type::length(__lc->_M_truename) - 1;
432 const size_t __fn = __traits_type::length(__lc->_M_falsename) - 1;
434 bool __testf = false;
435 bool __testt = false;
436 for (size_t __n = 0; __beg != __end; ++__n)
438 const char_type __c = *__beg;
442 __testf = __traits_type::eq(__c, __lc->_M_falsename[__n]);
445 __testt = __traits_type::eq(__c, __lc->_M_truename[__n]);
447 if (!(__testf || __testt))
449 __err |= ios_base::failbit;
452 else if (__testf && __n == __fn)
457 else if (__testt && __n == __tn)
464 __err |= ios_base::eofbit;
469 template<typename _CharT, typename _InIter>
471 num_get<_CharT, _InIter>::
472 do_get(iter_type __beg, iter_type __end, ios_base& __io,
473 ios_base::iostate& __err, long& __v) const
477 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
478 std::__convert_to_v(__xtrc.c_str(), __v, __err,
479 _S_get_c_locale(), __base);
483 template<typename _CharT, typename _InIter>
485 num_get<_CharT, _InIter>::
486 do_get(iter_type __beg, iter_type __end, ios_base& __io,
487 ios_base::iostate& __err, unsigned short& __v) const
491 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
493 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
494 _S_get_c_locale(), __base);
495 if (!(__err & ios_base::failbit)
496 && __ul <= numeric_limits<unsigned short>::max())
497 __v = static_cast<unsigned short>(__ul);
499 __err |= ios_base::failbit;
503 template<typename _CharT, typename _InIter>
505 num_get<_CharT, _InIter>::
506 do_get(iter_type __beg, iter_type __end, ios_base& __io,
507 ios_base::iostate& __err, unsigned int& __v) const
511 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
513 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
514 _S_get_c_locale(), __base);
515 if (!(__err & ios_base::failbit)
516 && __ul <= numeric_limits<unsigned int>::max())
517 __v = static_cast<unsigned int>(__ul);
519 __err |= ios_base::failbit;
523 template<typename _CharT, typename _InIter>
525 num_get<_CharT, _InIter>::
526 do_get(iter_type __beg, iter_type __end, ios_base& __io,
527 ios_base::iostate& __err, unsigned long& __v) const
531 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
532 std::__convert_to_v(__xtrc.c_str(), __v, __err,
533 _S_get_c_locale(), __base);
537 #ifdef _GLIBCXX_USE_LONG_LONG
538 template<typename _CharT, typename _InIter>
540 num_get<_CharT, _InIter>::
541 do_get(iter_type __beg, iter_type __end, ios_base& __io,
542 ios_base::iostate& __err, long long& __v) const
546 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
547 std::__convert_to_v(__xtrc.c_str(), __v, __err,
548 _S_get_c_locale(), __base);
552 template<typename _CharT, typename _InIter>
554 num_get<_CharT, _InIter>::
555 do_get(iter_type __beg, iter_type __end, ios_base& __io,
556 ios_base::iostate& __err, unsigned long long& __v) const
560 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
561 std::__convert_to_v(__xtrc.c_str(), __v, __err,
562 _S_get_c_locale(), __base);
567 template<typename _CharT, typename _InIter>
569 num_get<_CharT, _InIter>::
570 do_get(iter_type __beg, iter_type __end, ios_base& __io,
571 ios_base::iostate& __err, float& __v) const
575 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
576 std::__convert_to_v(__xtrc.c_str(), __v, __err,
581 template<typename _CharT, typename _InIter>
583 num_get<_CharT, _InIter>::
584 do_get(iter_type __beg, iter_type __end, ios_base& __io,
585 ios_base::iostate& __err, double& __v) const
589 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
590 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
594 template<typename _CharT, typename _InIter>
596 num_get<_CharT, _InIter>::
597 do_get(iter_type __beg, iter_type __end, ios_base& __io,
598 ios_base::iostate& __err, long double& __v) const
602 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
603 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
607 template<typename _CharT, typename _InIter>
609 num_get<_CharT, _InIter>::
610 do_get(iter_type __beg, iter_type __end, ios_base& __io,
611 ios_base::iostate& __err, void*& __v) const
613 // Prepare for hex formatted input.
614 typedef ios_base::fmtflags fmtflags;
615 const fmtflags __fmt = __io.flags();
616 const fmtflags __fmtmask = ~(ios_base::showpos | ios_base::basefield
617 | ios_base::uppercase | ios_base::internal);
618 __io.flags(__fmt & __fmtmask | (ios_base::hex | ios_base::showbase));
622 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
624 // Reset from hex formatted input.
628 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
629 _S_get_c_locale(), __base);
630 if (!(__err & ios_base::failbit))
631 __v = reinterpret_cast<void*>(__ul);
633 __err |= ios_base::failbit;
637 // For use by integer and floating-point types after they have been
638 // converted into a char_type string.
639 template<typename _CharT, typename _OutIter>
641 num_put<_CharT, _OutIter>::
642 _M_pad(_CharT __fill, streamsize __w, ios_base& __io,
643 _CharT* __new, const _CharT* __cs, int& __len) const
645 // [22.2.2.2.2] Stage 3.
646 // If necessary, pad.
647 __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, __cs,
649 __len = static_cast<int>(__w);
652 // Forwarding functions to peel signed from unsigned integer types.
653 template<typename _CharT>
655 __int_to_char(_CharT* __bufend, long __v, const _CharT* __lit,
656 ios_base::fmtflags __flags)
658 unsigned long __ul = static_cast<unsigned long>(__v);
665 return __int_to_char(__bufend, __ul, __lit, __flags, __neg);
668 template<typename _CharT>
670 __int_to_char(_CharT* __bufend, unsigned long __v, const _CharT* __lit,
671 ios_base::fmtflags __flags)
672 { return __int_to_char(__bufend, __v, __lit, __flags, false); }
674 #ifdef _GLIBCXX_USE_LONG_LONG
675 template<typename _CharT>
677 __int_to_char(_CharT* __bufend, long long __v, const _CharT* __lit,
678 ios_base::fmtflags __flags)
680 unsigned long long __ull = static_cast<unsigned long long>(__v);
687 return __int_to_char(__bufend, __ull, __lit, __flags, __neg);
690 template<typename _CharT>
692 __int_to_char(_CharT* __bufend, unsigned long long __v, const _CharT* __lit,
693 ios_base::fmtflags __flags)
694 { return __int_to_char(__bufend, __v, __lit, __flags, false); }
697 template<typename _CharT, typename _ValueT>
699 __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit,
700 ios_base::fmtflags __flags, bool __neg)
702 // Don't write base if already 0.
703 const bool __showbase = (__flags & ios_base::showbase) && __v;
704 const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
705 _CharT* __buf = __bufend - 1;
707 if (__builtin_expect(__basefield != ios_base::oct &&
708 __basefield != ios_base::hex, true))
713 *__buf-- = __lit[(__v % 10) + __num_base::_S_odigits];
718 *__buf-- = __lit[__num_base::_S_ominus];
719 else if (__flags & ios_base::showpos)
720 *__buf-- = __lit[__num_base::_S_oplus];
722 else if (__basefield == ios_base::oct)
727 *__buf-- = __lit[(__v & 0x7) + __num_base::_S_odigits];
732 *__buf-- = __lit[__num_base::_S_odigits];
737 const bool __uppercase = __flags & ios_base::uppercase;
738 const int __case_offset = __uppercase ? __num_base::_S_oudigits
739 : __num_base::_S_odigits;
742 *__buf-- = __lit[(__v & 0xf) + __case_offset];
749 *__buf-- = __lit[__num_base::_S_ox + __uppercase];
751 *__buf-- = __lit[__num_base::_S_odigits];
754 return __bufend - __buf - 1;
757 template<typename _CharT, typename _OutIter>
759 num_put<_CharT, _OutIter>::
760 _M_group_int(const string& __grouping, _CharT __sep, ios_base& __io,
761 _CharT* __new, _CharT* __cs, int& __len) const
763 // By itself __add_grouping cannot deal correctly with __ws when
764 // ios::showbase is set and ios_base::oct || ios_base::hex.
765 // Therefore we take care "by hand" of the initial 0, 0x or 0X.
766 // However, remember that the latter do not occur if the number
767 // printed is '0' (__len == 1).
768 streamsize __off = 0;
769 const ios_base::fmtflags __basefield = __io.flags()
770 & ios_base::basefield;
771 if ((__io.flags() & ios_base::showbase) && __len > 1)
772 if (__basefield == ios_base::oct)
777 else if (__basefield == ios_base::hex)
784 __p = std::__add_grouping(__new + __off, __sep, __grouping.data(),
785 __grouping.data() + __grouping.size(),
786 __cs + __off, __cs + __len);
790 template<typename _CharT, typename _OutIter>
791 template<typename _ValueT>
793 num_put<_CharT, _OutIter>::
794 _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
797 typedef typename numpunct<_CharT>::__cache_type __cache_type;
798 __use_cache<__cache_type> __uc;
799 const locale& __loc = __io._M_getloc();
800 const __cache_type* __lc = __uc(__loc);
801 const _CharT* __lit = __lc->_M_atoms_out;
803 // Long enough to hold hex, dec, and octal representations.
804 const int __ilen = 4 * sizeof(_ValueT);
805 _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
808 // [22.2.2.2.2] Stage 1, numeric conversion to character.
809 // Result is returned right-justified in the buffer.
811 __len = __int_to_char(__cs + __ilen, __v, __lit, __io.flags());
812 __cs += __ilen - __len;
814 // Add grouping, if necessary.
816 if (__lc->_M_use_grouping)
818 // Grouping can add (almost) as many separators as the
819 // number of digits, but no more.
820 __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
822 _M_group_int(__lc->_M_grouping, __lc->_M_thousands_sep, __io,
829 const streamsize __w = __io.width();
830 if (__w > static_cast<streamsize>(__len))
832 __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
834 _M_pad(__fill, __w, __io, __cs3, __cs, __len);
839 // [22.2.2.2.2] Stage 4.
840 // Write resulting, fully-formatted string to output iterator.
841 return std::__write(__s, __cs, __len);
844 template<typename _CharT, typename _OutIter>
846 num_put<_CharT, _OutIter>::
847 _M_group_float(const string& __grouping, _CharT __sep, const _CharT* __p,
848 _CharT* __new, _CharT* __cs, int& __len) const
850 // _GLIBCXX_RESOLVE_LIB_DEFECTS
851 // 282. What types does numpunct grouping refer to?
852 // Add grouping, if necessary.
854 const int __declen = __p ? __p - __cs : __len;
855 __p2 = std::__add_grouping(__new, __sep, __grouping.data(),
856 __grouping.data() + __grouping.size(),
857 __cs, __cs + __declen);
859 // Tack on decimal part.
860 int __newlen = __p2 - __new;
863 char_traits<_CharT>::copy(__p2, __p, __len - __declen);
864 __newlen += __len - __declen;
869 // The following code uses snprintf (or sprintf(), when
870 // _GLIBCXX_USE_C99 is not defined) to convert floating point values
871 // for insertion into a stream. An optimization would be to replace
872 // them with code that works directly on a wide buffer and then use
873 // __pad to do the padding. It would be good to replace them anyway
874 // to gain back the efficiency that C++ provides by knowing up front
875 // the type of the values to insert. Also, sprintf is dangerous
876 // since may lead to accidental buffer overruns. This
877 // implementation follows the C++ standard fairly directly as
878 // outlined in 22.2.2.2 [lib.locale.num.put]
879 template<typename _CharT, typename _OutIter>
880 template<typename _ValueT>
882 num_put<_CharT, _OutIter>::
883 _M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
886 typedef typename numpunct<_CharT>::__cache_type __cache_type;
887 __use_cache<__cache_type> __uc;
888 const locale& __loc = __io._M_getloc();
889 const __cache_type* __lc = __uc(__loc);
891 // Note: digits10 is rounded down: add 1 to ensure the maximum
892 // available precision. Then, in general, one more 1 needs to
893 // be added since, when the %{g,G} conversion specifiers are
894 // chosen inside _S_format_float, the precision field is "the
895 // maximum number of significant digits", *not* the "number of
896 // digits to appear after the decimal point", as happens for
897 // %{e,E,f,F} (C99, 7.19.6.1,4).
898 const int __max_digits = numeric_limits<_ValueT>::digits10 + 2;
900 // Use default precision if out of range.
901 streamsize __prec = __io.precision();
902 if (__prec > static_cast<streamsize>(__max_digits))
903 __prec = static_cast<streamsize>(__max_digits);
904 else if (__prec < static_cast<streamsize>(0))
905 __prec = static_cast<streamsize>(6);
907 // [22.2.2.2.2] Stage 1, numeric conversion to character.
909 // Long enough for the max format spec.
912 #ifdef _GLIBCXX_USE_C99
913 // First try a buffer perhaps big enough (for sure sufficient
914 // for non-ios_base::fixed outputs)
915 int __cs_size = __max_digits * 3;
916 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
918 _S_format_float(__io, __fbuf, __mod);
919 __len = std::__convert_from_v(__cs, __cs_size, __fbuf, __v,
920 _S_get_c_locale(), __prec);
922 // If the buffer was not large enough, try again with the correct size.
923 if (__len >= __cs_size)
925 __cs_size = __len + 1;
926 __cs = static_cast<char*>(__builtin_alloca(__cs_size));
927 __len = std::__convert_from_v(__cs, __cs_size, __fbuf, __v,
928 _S_get_c_locale(), __prec);
931 // Consider the possibility of long ios_base::fixed outputs
932 const bool __fixed = __io.flags() & ios_base::fixed;
933 const int __max_exp = numeric_limits<_ValueT>::max_exponent10;
935 // The size of the output string is computed as follows.
936 // ios_base::fixed outputs may need up to __max_exp+1 chars
937 // for the integer part + up to __max_digits chars for the
938 // fractional part + 3 chars for sign, decimal point, '\0'. On
939 // the other hand, for non-fixed outputs __max_digits*3 chars
940 // are largely sufficient.
941 const int __cs_size = __fixed ? __max_exp + __max_digits + 4
943 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
945 _S_format_float(__io, __fbuf, __mod);
946 __len = std::__convert_from_v(__cs, 0, __fbuf, __v,
947 _S_get_c_locale(), __prec);
950 // [22.2.2.2.2] Stage 2, convert to char_type, using correct
951 // numpunct.decimal_point() values for '.' and adding grouping.
952 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
954 _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
956 __ctype.widen(__cs, __cs + __len, __ws);
958 // Replace decimal point.
959 const _CharT __cdec = __ctype.widen('.');
960 const _CharT __dec = __lc->_M_decimal_point;
962 if (__p = char_traits<_CharT>::find(__ws, __len, __cdec))
963 __ws[__p - __ws] = __dec;
965 // Add grouping, if necessary.
967 if (__lc->_M_use_grouping)
969 // Grouping can add (almost) as many separators as the
970 // number of digits, but no more.
971 __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
973 _M_group_float(__lc->_M_grouping, __lc->_M_thousands_sep, __p,
980 const streamsize __w = __io.width();
981 if (__w > static_cast<streamsize>(__len))
983 __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
984 _M_pad(__fill, __w, __io, __ws3, __ws, __len);
989 // [22.2.2.2.2] Stage 4.
990 // Write resulting, fully-formatted string to output iterator.
991 return std::__write(__s, __ws, __len);
994 template<typename _CharT, typename _OutIter>
996 num_put<_CharT, _OutIter>::
997 do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
999 const ios_base::fmtflags __flags = __io.flags();
1000 if ((__flags & ios_base::boolalpha) == 0)
1002 unsigned long __uv = __v;
1003 __s = _M_insert_int(__s, __io, __fill, __uv);
1007 typedef typename numpunct<_CharT>::__cache_type __cache_type;
1008 __use_cache<__cache_type> __uc;
1009 const locale& __loc = __io._M_getloc();
1010 const __cache_type* __lc = __uc(__loc);
1012 const _CharT* __name;
1013 __name = __v ? __lc->_M_truename : __lc->_M_falsename;
1014 int __len = char_traits<_CharT>::length(__name);
1017 const streamsize __w = __io.width();
1018 if (__w > static_cast<streamsize>(__len))
1020 __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1022 _M_pad(__fill, __w, __io, __cs, __name, __len);
1026 __s = std::__write(__s, __name, __len);
1031 template<typename _CharT, typename _OutIter>
1033 num_put<_CharT, _OutIter>::
1034 do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
1035 { return _M_insert_int(__s, __io, __fill, __v); }
1037 template<typename _CharT, typename _OutIter>
1039 num_put<_CharT, _OutIter>::
1040 do_put(iter_type __s, ios_base& __io, char_type __fill,
1041 unsigned long __v) const
1042 { return _M_insert_int(__s, __io, __fill, __v); }
1044 #ifdef _GLIBCXX_USE_LONG_LONG
1045 template<typename _CharT, typename _OutIter>
1047 num_put<_CharT, _OutIter>::
1048 do_put(iter_type __s, ios_base& __b, char_type __fill, long long __v) const
1049 { return _M_insert_int(__s, __b, __fill, __v); }
1051 template<typename _CharT, typename _OutIter>
1053 num_put<_CharT, _OutIter>::
1054 do_put(iter_type __s, ios_base& __io, char_type __fill,
1055 unsigned long long __v) const
1056 { return _M_insert_int(__s, __io, __fill, __v); }
1059 template<typename _CharT, typename _OutIter>
1061 num_put<_CharT, _OutIter>::
1062 do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
1063 { return _M_insert_float(__s, __io, __fill, char(), __v); }
1065 template<typename _CharT, typename _OutIter>
1067 num_put<_CharT, _OutIter>::
1068 do_put(iter_type __s, ios_base& __io, char_type __fill,
1069 long double __v) const
1070 { return _M_insert_float(__s, __io, __fill, 'L', __v); }
1072 template<typename _CharT, typename _OutIter>
1074 num_put<_CharT, _OutIter>::
1075 do_put(iter_type __s, ios_base& __io, char_type __fill,
1076 const void* __v) const
1078 const ios_base::fmtflags __flags = __io.flags();
1079 const ios_base::fmtflags __fmt = ~(ios_base::showpos | ios_base::basefield
1080 | ios_base::uppercase | ios_base::internal);
1081 __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
1084 __s = _M_insert_int(__s, __io, __fill,
1085 reinterpret_cast<unsigned long>(__v));
1086 __io.flags(__flags);
1090 __io.flags(__flags);
1091 __throw_exception_again;
1097 template<typename _CharT, typename _InIter>
1099 money_get<_CharT, _InIter>::
1100 do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
1101 ios_base::iostate& __err, long double& __units) const
1104 __beg = this->do_get(__beg, __end, __intl, __io, __err, __str);
1106 const int __cs_size = __str.size() + 1;
1107 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1108 const locale __loc = __io.getloc();
1109 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1110 const _CharT* __wcs = __str.c_str();
1111 __ctype.narrow(__wcs, __wcs + __cs_size, char(), __cs);
1112 std::__convert_to_v(__cs, __units, __err, _S_get_c_locale());
1116 template<typename _CharT, typename _InIter>
1118 money_get<_CharT, _InIter>::
1119 do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
1120 ios_base::iostate& __err, string_type& __units) const
1122 // These contortions are quite unfortunate.
1123 typedef moneypunct<_CharT, true> __money_true;
1124 typedef moneypunct<_CharT, false> __money_false;
1125 typedef money_base::part part;
1126 typedef typename string_type::size_type size_type;
1128 const locale __loc = __io.getloc();
1129 const __money_true& __mpt = use_facet<__money_true>(__loc);
1130 const __money_false& __mpf = use_facet<__money_false>(__loc);
1131 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1133 const money_base::pattern __p = __intl ? __mpt.neg_format()
1134 : __mpf.neg_format();
1136 const string_type __pos_sign = __intl ? __mpt.positive_sign()
1137 : __mpf.positive_sign();
1138 const string_type __neg_sign = __intl ? __mpt.negative_sign()
1139 : __mpf.negative_sign();
1140 const char_type __d = __intl ? __mpt.decimal_point()
1141 : __mpf.decimal_point();
1142 const char_type __sep = __intl ? __mpt.thousands_sep()
1143 : __mpf.thousands_sep();
1145 const string __grouping = __intl ? __mpt.grouping() : __mpf.grouping();
1147 // Set to deduced positive or negative sign, depending.
1149 // String of grouping info from thousands_sep plucked from __units.
1150 string __grouping_tmp;
1151 // Marker for thousands_sep position.
1153 // If input iterator is in a valid state.
1154 bool __testvalid = true;
1155 // Flag marking when a decimal point is found.
1156 bool __testdecfound = false;
1158 // The tentative returned string is stored here.
1159 string_type __tmp_units;
1161 for (int __i = 0; __beg != __end && __i < 4 && __testvalid; ++__i)
1164 const part __which = static_cast<part>(__p.field[__i]);
1167 case money_base::symbol:
1168 if (__io.flags() & ios_base::showbase
1169 || __i < 2 || __sign.size() > 1
1170 || ((static_cast<part>(__p.field[3]) != money_base::none)
1173 // According to 22.2.6.1.2.2, symbol is required
1174 // if (__io.flags() & ios_base::showbase),
1175 // otherwise is optional and consumed only if
1176 // other characters are needed to complete the
1178 const string_type __symbol = __intl ? __mpt.curr_symbol()
1179 : __mpf.curr_symbol();
1180 const size_type __len = __symbol.size();
1182 for (; __beg != __end && __j < __len
1183 && *__beg == __symbol[__j]; ++__beg, ++__j);
1184 // When (__io.flags() & ios_base::showbase)
1185 // symbol is required.
1186 if (__j != __len && (__io.flags() & ios_base::showbase))
1187 __testvalid = false;
1190 case money_base::sign:
1191 // Sign might not exist, or be more than one character long.
1192 if (__pos_sign.size() && *__beg == __pos_sign[0])
1194 __sign = __pos_sign;
1197 else if (__neg_sign.size() && *__beg == __neg_sign[0])
1199 __sign = __neg_sign;
1202 else if (__pos_sign.size() && __neg_sign.size())
1204 // Sign is mandatory.
1205 __testvalid = false;
1208 case money_base::value:
1209 // Extract digits, remove and stash away the
1210 // grouping of found thousands separators.
1211 for (; __beg != __end; ++__beg)
1212 if (__ctype.is(ctype_base::digit, __c = *__beg))
1217 else if (__c == __d && !__testdecfound)
1219 __grouping_tmp += static_cast<char>(__sep_pos);
1221 __testdecfound = true;
1223 else if (__c == __sep)
1225 if (__grouping.size())
1227 // Mark position for later analysis.
1228 __grouping_tmp += static_cast<char>(__sep_pos);
1233 __testvalid = false;
1240 case money_base::space:
1241 case money_base::none:
1242 // Only if not at the end of the pattern.
1244 for (; __beg != __end
1245 && __ctype.is(ctype_base::space, *__beg); ++__beg);
1250 // Need to get the rest of the sign characters, if they exist.
1251 if (__sign.size() > 1)
1253 const size_type __len = __sign.size();
1255 for (; __beg != __end && __i < __len; ++__i)
1256 for (; __beg != __end
1257 && *__beg != __sign[__i]; ++__beg);
1260 __testvalid = false;
1263 if (__testvalid && __tmp_units.size())
1265 const char_type __zero = __ctype.widen('0');
1267 // Strip leading zeros.
1268 if (__tmp_units.size() > 1)
1270 const size_type __first = __tmp_units.find_first_not_of(__zero);
1271 const bool __only_zeros = __first == string_type::npos;
1273 __tmp_units.erase(0, __only_zeros ? __tmp_units.size() - 1
1278 if (__sign.size() && __sign == __neg_sign
1279 && __tmp_units[0] != __zero)
1280 __tmp_units.insert(__tmp_units.begin(), __ctype.widen('-'));
1282 // Test for grouping fidelity.
1283 if (__grouping.size() && __grouping_tmp.size())
1285 if (!std::__verify_grouping(__grouping, __grouping_tmp))
1286 __testvalid = false;
1289 // Iff not enough digits were supplied after the decimal-point.
1292 const int __frac = __intl ? __mpt.frac_digits()
1293 : __mpf.frac_digits();
1294 if (__frac > 0 && __sep_pos != __frac)
1295 __testvalid = false;
1299 __testvalid = false;
1301 // Iff no more characters are available.
1303 __err |= ios_base::eofbit;
1305 // Iff valid sequence is not recognized.
1307 __err |= ios_base::failbit;
1309 // Use the "swap trick" to copy __tmp_units into __units.
1310 __tmp_units.swap(__units);
1315 template<typename _CharT, typename _OutIter>
1317 money_put<_CharT, _OutIter>::
1318 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1319 long double __units) const
1321 const locale __loc = __io.getloc();
1322 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1323 #ifdef _GLIBCXX_USE_C99
1324 // First try a buffer perhaps big enough.
1326 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1327 int __len = std::__convert_from_v(__cs, __cs_size, "%.01Lf", __units,
1329 // If the buffer was not large enough, try again with the correct size.
1330 if (__len >= __cs_size)
1332 __cs_size = __len + 1;
1333 __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1334 __len = std::__convert_from_v(__cs, __cs_size, "%.01Lf", __units,
1338 // max_exponent10 + 1 for the integer part, + 4 for sign, decimal point,
1339 // decimal digit, '\0'.
1340 const int __cs_size = numeric_limits<long double>::max_exponent10 + 5;
1341 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1342 int __len = std::__convert_from_v(__cs, 0, "%.01Lf", __units,
1345 _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1347 __ctype.widen(__cs, __cs + __len, __ws);
1348 string_type __digits(__ws);
1349 return this->do_put(__s, __intl, __io, __fill, __digits);
1352 template<typename _CharT, typename _OutIter>
1354 money_put<_CharT, _OutIter>::
1355 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1356 const string_type& __digits) const
1358 typedef typename string_type::size_type size_type;
1359 typedef money_base::part part;
1361 const locale __loc = __io.getloc();
1362 const size_type __width = static_cast<size_type>(__io.width());
1364 // These contortions are quite unfortunate.
1365 typedef moneypunct<_CharT, true> __money_true;
1366 typedef moneypunct<_CharT, false> __money_false;
1367 const __money_true& __mpt = use_facet<__money_true>(__loc);
1368 const __money_false& __mpf = use_facet<__money_false>(__loc);
1369 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1371 // Determine if negative or positive formats are to be used, and
1372 // discard leading negative_sign if it is present.
1373 const char_type* __beg = __digits.data();
1374 const char_type* __end = __beg + __digits.size();
1375 money_base::pattern __p;
1377 if (*__beg != __ctype.widen('-'))
1379 __p = __intl ? __mpt.pos_format() : __mpf.pos_format();
1380 __sign = __intl ? __mpt.positive_sign() : __mpf.positive_sign();
1384 __p = __intl ? __mpt.neg_format() : __mpf.neg_format();
1385 __sign = __intl ? __mpt.negative_sign() : __mpf.negative_sign();
1389 // Look for valid numbers in the current ctype facet within input digits.
1390 __end = __ctype.scan_not(ctype_base::digit, __beg, __end);
1393 // Assume valid input, and attempt to format.
1394 // Break down input numbers into base components, as follows:
1395 // final_value = grouped units + (decimal point) + (digits)
1397 string_type __value;
1398 const string_type __symbol = __intl ? __mpt.curr_symbol()
1399 : __mpf.curr_symbol();
1401 // Deal with decimal point, decimal digits.
1402 const int __frac = __intl ? __mpt.frac_digits()
1403 : __mpf.frac_digits();
1406 const char_type __d = __intl ? __mpt.decimal_point()
1407 : __mpf.decimal_point();
1408 if (__end - __beg >= __frac)
1410 __value = string_type(__end - __frac, __end);
1411 __value.insert(__value.begin(), __d);
1416 // Have to pad zeros in the decimal position.
1417 __value = string_type(__beg, __end);
1418 const int __paddec = __frac - (__end - __beg);
1419 const char_type __zero = __ctype.widen('0');
1420 __value.insert(__value.begin(), __paddec, __zero);
1421 __value.insert(__value.begin(), __d);
1426 // Add thousands separators to non-decimal digits, per
1430 const string __grouping = __intl ? __mpt.grouping()
1432 if (__grouping.size())
1434 const char_type __sep = __intl ? __mpt.thousands_sep()
1435 : __mpf.thousands_sep();
1436 const char* __gbeg = __grouping.data();
1437 const char* __gend = __gbeg + __grouping.size();
1438 const int __n = (__end - __beg) * 2;
1440 static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n));
1441 _CharT* __ws_end = std::__add_grouping(__ws2, __sep, __gbeg,
1442 __gend, __beg, __end);
1443 __value.insert(0, __ws2, __ws_end - __ws2);
1446 __value.insert(0, string_type(__beg, __end));
1449 // Calculate length of resulting string.
1450 const ios_base::fmtflags __f = __io.flags() & ios_base::adjustfield;
1451 size_type __len = __value.size() + __sign.size();
1452 __len += (__io.flags() & ios_base::showbase) ? __symbol.size() : 0;
1453 const bool __testipad = __f == ios_base::internal && __len < __width;
1455 // Fit formatted digits into the required pattern.
1456 for (int __i = 0; __i < 4; ++__i)
1458 const part __which = static_cast<part>(__p.field[__i]);
1461 case money_base::symbol:
1462 if (__io.flags() & ios_base::showbase)
1465 case money_base::sign:
1466 // Sign might not exist, or be more than one
1467 // charater long. In that case, add in the rest
1472 case money_base::value:
1475 case money_base::space:
1476 // At least one space is required, but if internal
1477 // formatting is required, an arbitrary number of
1478 // fill spaces will be necessary.
1480 __res += string_type(__width - __len, __fill);
1482 __res += __ctype.widen(__fill);
1484 case money_base::none:
1486 __res += string_type(__width - __len, __fill);
1491 // Special case of multi-part sign parts.
1492 if (__sign.size() > 1)
1493 __res += string_type(__sign.begin() + 1, __sign.end());
1495 // Pad, if still necessary.
1496 __len = __res.size();
1497 if (__width > __len)
1499 if (__f == ios_base::left)
1501 __res.append(__width - __len, __fill);
1504 __res.insert(0, string_type(__width - __len, __fill));
1508 // Write resulting, fully-formatted string to output iterator.
1509 __s = std::__write(__s, __res.data(), __len);
1516 // NB: Not especially useful. Without an ios_base object or some
1517 // kind of locale reference, we are left clawing at the air where
1518 // the side of the mountain used to be...
1519 template<typename _CharT, typename _InIter>
1520 time_base::dateorder
1521 time_get<_CharT, _InIter>::do_date_order() const
1522 { return time_base::no_order; }
1524 template<typename _CharT, typename _InIter>
1526 time_get<_CharT, _InIter>::
1527 _M_extract_via_format(iter_type& __beg, iter_type& __end, ios_base& __io,
1528 ios_base::iostate& __err, tm* __tm,
1529 const _CharT* __format) const
1531 const locale __loc = __io.getloc();
1532 __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
1533 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1534 const size_t __len = char_traits<_CharT>::length(__format);
1536 for (size_t __i = 0; __beg != __end && __i < __len && !__err; ++__i)
1538 char __c = __format[__i];
1541 // Verify valid formatting code, attempt to extract.
1542 __c = __format[++__i];
1545 if (__c == 'E' || __c == 'O')
1548 __c = __format[++__i];
1555 // Abbreviated weekday name [tm_wday]
1556 const char_type* __days1[7];
1557 __tp._M_days_abbreviated(__days1);
1558 _M_extract_name(__beg, __end, __tm->tm_wday, __days1, 7,
1562 // Weekday name [tm_wday].
1563 const char_type* __days2[7];
1564 __tp._M_days(__days2);
1565 _M_extract_name(__beg, __end, __tm->tm_wday, __days2, 7,
1570 // Abbreviated month name [tm_mon]
1571 const char_type* __months1[12];
1572 __tp._M_months_abbreviated(__months1);
1573 _M_extract_name(__beg, __end, __tm->tm_mon, __months1, 12,
1577 // Month name [tm_mon].
1578 const char_type* __months2[12];
1579 __tp._M_months(__months2);
1580 _M_extract_name(__beg, __end, __tm->tm_mon, __months2, 12,
1584 // Default time and date representation.
1585 const char_type* __dt[2];
1586 __tp._M_date_time_formats(__dt);
1587 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1591 // Day [01, 31]. [tm_mday]
1592 _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
1596 // Day [1, 31], with single digits preceded by
1598 if (__ctype.is(ctype_base::space, *__beg))
1599 _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9, 1,
1602 _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31, 2,
1606 // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
1608 __ctype.widen(__cs, __cs + 9, __wcs);
1609 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1613 // Hour [00, 23]. [tm_hour]
1614 _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
1618 // Hour [01, 12]. [tm_hour]
1619 _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
1623 // Month [01, 12]. [tm_mon]
1624 _M_extract_num(__beg, __end, __mem, 1, 12, 2, __ctype,
1627 __tm->tm_mon = __mem - 1;
1630 // Minute [00, 59]. [tm_min]
1631 _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
1635 if (__ctype.narrow(*__beg, 0) == '\n')
1638 __err |= ios_base::failbit;
1641 // Equivalent to (%H:%M).
1643 __ctype.widen(__cs, __cs + 6, __wcs);
1644 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1649 _M_extract_num(__beg, __end, __tm->tm_sec, 0, 59, 2,
1653 if (__ctype.narrow(*__beg, 0) == '\t')
1656 __err |= ios_base::failbit;
1659 // Equivalent to (%H:%M:%S).
1661 __ctype.widen(__cs, __cs + 9, __wcs);
1662 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1667 const char_type* __dates[2];
1668 __tp._M_date_formats(__dates);
1669 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1674 const char_type* __times[2];
1675 __tp._M_time_formats(__times);
1676 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1681 // Two digit year. [tm_year]
1682 _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2,
1686 // Year [1900). [tm_year]
1687 _M_extract_num(__beg, __end, __mem, 0,
1688 numeric_limits<int>::max(), 4,
1691 __tm->tm_year = __mem - 1900;
1695 if (__ctype.is(ctype_base::upper, *__beg))
1698 _M_extract_name(__beg, __end, __tmp,
1699 __timepunct_cache<_CharT>::_S_timezones,
1702 // GMT requires special effort.
1703 if (__beg != __end && !__err && __tmp == 0
1704 && (*__beg == __ctype.widen('-')
1705 || *__beg == __ctype.widen('+')))
1707 _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
1709 _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
1714 __err |= ios_base::failbit;
1718 __err |= ios_base::failbit;
1723 // Verify format and input match, extract and discard.
1724 if (__c == __ctype.narrow(*__beg, 0))
1727 __err |= ios_base::failbit;
1732 template<typename _CharT, typename _InIter>
1734 time_get<_CharT, _InIter>::
1735 _M_extract_num(iter_type& __beg, iter_type& __end, int& __member,
1736 int __min, int __max, size_t __len,
1737 const ctype<_CharT>& __ctype,
1738 ios_base::iostate& __err) const
1742 bool __testvalid = true;
1743 for (; __beg != __end && __i < __len
1744 && __ctype.is(ctype_base::digit, *__beg); ++__beg, ++__i)
1745 __digits += __ctype.narrow(*__beg, 0);
1748 const int __value = std::atoi(__digits.c_str());
1749 if (__min <= __value && __value <= __max)
1752 __testvalid = false;
1755 __testvalid = false;
1757 __err |= ios_base::failbit;
1761 // All elements in __names are unique.
1762 template<typename _CharT, typename _InIter>
1764 time_get<_CharT, _InIter>::
1765 _M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
1766 const _CharT** __names, size_t __indexlen,
1767 ios_base::iostate& __err) const
1769 typedef char_traits<_CharT> __traits_type;
1770 int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)
1772 size_t __nmatches = 0;
1774 bool __testvalid = true;
1775 const char_type* __name;
1777 // Look for initial matches.
1780 const char_type __c = *__beg;
1781 for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
1782 if (__c == __names[__i1][0])
1783 __matches[__nmatches++] = __i1;
1786 while (__nmatches > 1)
1788 // Find smallest matching string.
1789 size_t __minlen = 10;
1790 for (size_t __i2 = 0; __i2 < __nmatches; ++__i2)
1791 __minlen = std::min(__minlen,
1792 __traits_type::length(__names[__matches[__i2]]));
1794 if (__pos < __minlen && __beg != __end)
1797 for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)
1799 __name = __names[__matches[__i3]];
1800 if (__name[__pos] != *__beg)
1801 __matches[__i3] = __matches[--__nmatches];
1808 if (__nmatches == 1)
1810 // Make sure found name is completely extracted.
1811 __name = __names[__matches[0]];
1812 const size_t __len = __traits_type::length(__name);
1813 while (__pos < __len && __beg != __end && __name[__pos] == *__beg)
1817 __member = __matches[0];
1819 __testvalid = false;
1822 __testvalid = false;
1824 __err |= ios_base::failbit;
1827 template<typename _CharT, typename _InIter>
1829 time_get<_CharT, _InIter>::
1830 do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
1831 ios_base::iostate& __err, tm* __tm) const
1834 const char* __cs = "%X";
1835 const locale __loc = __io.getloc();
1836 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1837 __ctype.widen(__cs, __cs + 3, __wcs);
1838 _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
1840 __err |= ios_base::eofbit;
1844 template<typename _CharT, typename _InIter>
1846 time_get<_CharT, _InIter>::
1847 do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
1848 ios_base::iostate& __err, tm* __tm) const
1851 const char* __cs = "%x";
1852 const locale __loc = __io.getloc();
1853 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1854 __ctype.widen(__cs, __cs + 3, __wcs);
1855 _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
1857 __err |= ios_base::eofbit;
1861 template<typename _CharT, typename _InIter>
1863 time_get<_CharT, _InIter>::
1864 do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
1865 ios_base::iostate& __err, tm* __tm) const
1867 typedef char_traits<_CharT> __traits_type;
1868 const locale __loc = __io.getloc();
1869 __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
1870 const char_type* __days[7];
1871 __tp._M_days_abbreviated(__days);
1873 _M_extract_name(__beg, __end, __tmpwday, __days, 7, __err);
1875 // Check to see if non-abbreviated name exists, and extract.
1876 // NB: Assumes both _M_days and _M_days_abbreviated organized in
1877 // exact same order, first to last, such that the resulting
1878 // __days array with the same index points to a day, and that
1879 // day's abbreviated form.
1880 // NB: Also assumes that an abbreviated name is a subset of the name.
1883 size_t __pos = __traits_type::length(__days[__tmpwday]);
1884 __tp._M_days(__days);
1885 const char_type* __name = __days[__tmpwday];
1886 if (__name[__pos] == *__beg)
1888 // Extract the rest of it.
1889 const size_t __len = __traits_type::length(__name);
1890 while (__pos < __len && __beg != __end
1891 && __name[__pos] == *__beg)
1894 __err |= ios_base::failbit;
1897 __tm->tm_wday = __tmpwday;
1900 __err |= ios_base::eofbit;
1904 template<typename _CharT, typename _InIter>
1906 time_get<_CharT, _InIter>::
1907 do_get_monthname(iter_type __beg, iter_type __end,
1908 ios_base& __io, ios_base::iostate& __err, tm* __tm) const
1910 typedef char_traits<_CharT> __traits_type;
1911 const locale __loc = __io.getloc();
1912 __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
1913 const char_type* __months[12];
1914 __tp._M_months_abbreviated(__months);
1916 _M_extract_name(__beg, __end, __tmpmon, __months, 12, __err);
1918 // Check to see if non-abbreviated name exists, and extract.
1919 // NB: Assumes both _M_months and _M_months_abbreviated organized in
1920 // exact same order, first to last, such that the resulting
1921 // __months array with the same index points to a month, and that
1922 // month's abbreviated form.
1923 // NB: Also assumes that an abbreviated name is a subset of the name.
1926 size_t __pos = __traits_type::length(__months[__tmpmon]);
1927 __tp._M_months(__months);
1928 const char_type* __name = __months[__tmpmon];
1929 if (__name[__pos] == *__beg)
1931 // Extract the rest of it.
1932 const size_t __len = __traits_type::length(__name);
1933 while (__pos < __len && __beg != __end
1934 && __name[__pos] == *__beg)
1937 __err |= ios_base::failbit;
1940 __tm->tm_mon = __tmpmon;
1944 __err |= ios_base::eofbit;
1948 template<typename _CharT, typename _InIter>
1950 time_get<_CharT, _InIter>::
1951 do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
1952 ios_base::iostate& __err, tm* __tm) const
1954 const locale __loc = __io.getloc();
1955 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1957 char_type __c = *__beg;
1960 while (__i < 4 && __beg != __end && __ctype.is(ctype_base::digit, __c))
1962 __digits += __ctype.narrow(__c, 0);
1966 if (__i == 2 || __i == 4)
1969 std::__convert_to_v(__digits.c_str(), __l, __err,
1971 if (!(__err & ios_base::failbit) && __l <= INT_MAX)
1973 __l = __i == 2 ? __l : __l - 1900;
1974 __tm->tm_year = static_cast<int>(__l);
1978 __err |= ios_base::failbit;
1980 __err |= ios_base::eofbit;
1984 template<typename _CharT, typename _OutIter>
1986 time_put<_CharT, _OutIter>::
1987 put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
1988 const _CharT* __beg, const _CharT* __end) const
1990 const locale __loc = __io.getloc();
1991 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1992 for (; __beg != __end; ++__beg)
1994 if (__ctype.narrow(*__beg, 0) != '%')
1999 else if (++__beg != __end)
2003 const char __c = __ctype.narrow(*__beg, 0);
2004 if (__c != 'E' && __c != 'O')
2006 else if (++__beg != __end)
2009 __format = __ctype.narrow(*__beg, 0);
2013 __s = this->do_put(__s, __io, __fill, __tm,
2022 template<typename _CharT, typename _OutIter>
2024 time_put<_CharT, _OutIter>::
2025 do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm,
2026 char __format, char __mod) const
2028 const locale __loc = __io.getloc();
2029 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
2030 __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
2032 // NB: This size is arbitrary. Should this be a data member,
2033 // initialized at construction?
2034 const size_t __maxlen = 64;
2035 char_type* __res = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen));
2037 // NB: In IEE 1003.1-200x, and perhaps other locale models, it
2038 // is possible that the format character will be longer than one
2039 // character. Possibilities include 'E' or 'O' followed by a
2040 // format character: if __mod is not the default argument, assume
2041 // it's a valid modifier.
2043 __fmt[0] = __ctype.widen('%');
2046 __fmt[1] = __format;
2047 __fmt[2] = char_type();
2052 __fmt[2] = __format;
2053 __fmt[3] = char_type();
2056 __tp._M_put(__res, __maxlen, __fmt, __tm);
2058 // Write resulting, fully-formatted string to output iterator.
2059 return std::__write(__s, __res, char_traits<char_type>::length(__res));
2063 // Generic version does nothing.
2064 template<typename _CharT>
2066 collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const
2069 // Generic version does nothing.
2070 template<typename _CharT>
2072 collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const
2075 template<typename _CharT>
2078 do_compare(const _CharT* __lo1, const _CharT* __hi1,
2079 const _CharT* __lo2, const _CharT* __hi2) const
2081 // strcoll assumes zero-terminated strings so we make a copy
2082 // and then put a zero at the end.
2083 const string_type __one(__lo1, __hi1);
2084 const string_type __two(__lo2, __hi2);
2086 const _CharT* __p = __one.c_str();
2087 const _CharT* __pend = __one.data() + __one.length();
2088 const _CharT* __q = __two.c_str();
2089 const _CharT* __qend = __two.data() + __two.length();
2091 // strcoll stops when it sees a nul character so we break
2092 // the strings into zero-terminated substrings and pass those
2096 const int __res = _M_compare(__p, __q);
2100 __p += char_traits<_CharT>::length(__p);
2101 __q += char_traits<_CharT>::length(__q);
2102 if (__p == __pend && __q == __qend)
2104 else if (__p == __pend)
2106 else if (__q == __qend)
2114 template<typename _CharT>
2115 typename collate<_CharT>::string_type
2117 do_transform(const _CharT* __lo, const _CharT* __hi) const
2119 // strxfrm assumes zero-terminated strings so we make a copy
2120 string_type __str(__lo, __hi);
2122 const _CharT* __p = __str.c_str();
2123 const _CharT* __pend = __str.data() + __str.length();
2125 size_t __len = (__hi - __lo) * 2;
2129 // strxfrm stops when it sees a nul character so we break
2130 // the string into zero-terminated substrings and pass those
2134 // First try a buffer perhaps big enough.
2136 static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
2137 size_t __res = _M_transform(__c, __p, __len);
2138 // If the buffer was not large enough, try again with the
2143 __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
2145 __res = _M_transform(__c, __p, __res + 1);
2148 __ret.append(__c, __res);
2149 __p += char_traits<_CharT>::length(__p);
2154 __ret.push_back(_CharT());
2158 template<typename _CharT>
2161 do_hash(const _CharT* __lo, const _CharT* __hi) const
2163 unsigned long __val = 0;
2164 for (; __lo < __hi; ++__lo)
2165 __val = *__lo + ((__val << 7) |
2166 (__val >> (numeric_limits<unsigned long>::digits - 7)));
2167 return static_cast<long>(__val);
2170 // Construct correctly padded string, as per 22.2.2.2.2
2172 // __newlen > __oldlen
2173 // __news is allocated for __newlen size
2174 // Used by both num_put and ostream inserters: if __num,
2175 // internal-adjusted objects are padded according to the rules below
2176 // concerning 0[xX] and +-, otherwise, exactly as right-adjusted
2179 // NB: Of the two parameters, _CharT can be deduced from the
2180 // function arguments. The other (_Traits) has to be explicitly specified.
2181 template<typename _CharT, typename _Traits>
2183 __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
2184 _CharT* __news, const _CharT* __olds,
2185 const streamsize __newlen,
2186 const streamsize __oldlen, const bool __num)
2188 const size_t __plen = static_cast<size_t>(__newlen - __oldlen);
2189 const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
2192 if (__adjust == ios_base::left)
2194 _Traits::copy(__news, const_cast<_CharT*>(__olds), __oldlen);
2195 _Traits::assign(__news + __oldlen, __plen, __fill);
2200 if (__adjust == ios_base::internal && __num)
2202 // Pad after the sign, if there is one.
2203 // Pad after 0[xX], if there is one.
2204 // Who came up with these rules, anyway? Jeeze.
2205 const locale& __loc = __io._M_getloc();
2206 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
2207 const _CharT __minus = __ctype.widen('-');
2208 const _CharT __plus = __ctype.widen('+');
2209 const bool __testsign = _Traits::eq(__olds[0], __minus)
2210 || _Traits::eq(__olds[0], __plus);
2212 const bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0])
2213 && (_Traits::eq(__ctype.widen('x'), __olds[1])
2214 || _Traits::eq(__ctype.widen('X'), __olds[1]));
2217 __news[0] = __olds[0];
2218 __news[1] = __olds[1];
2222 else if (__testsign)
2224 __news[0] = __olds[0];
2228 // else Padding first.
2230 _Traits::assign(__news, __plen, __fill);
2231 _Traits::copy(__news + __plen, const_cast<_CharT*>(__olds + __mod),
2235 template<typename _CharT>
2237 __verify_grouping(const basic_string<_CharT>& __grouping,
2238 const basic_string<_CharT>& __grouping_tmp)
2242 const size_t __len = __grouping.size();
2243 const size_t __n = __grouping_tmp.size();
2246 // Parsed number groupings have to match the
2247 // numpunct::grouping string exactly, starting at the
2248 // right-most point of the parsed sequence of elements ...
2249 while (__test && __i < __n - 1)
2250 for (__j = 0; __test && __j < __len && __i < __n - 1; ++__j, ++__i)
2251 __test = __grouping[__j] == __grouping_tmp[__n - __i - 1];
2252 // ... but the last parsed grouping can be <= numpunct
2254 __j == __len ? __j = 0 : __j;
2255 __test &= __grouping[__j] >= __grouping_tmp[__n - __i - 1];
2259 template<typename _CharT>
2261 __add_grouping(_CharT* __s, _CharT __sep,
2262 const char* __gbeg, const char* __gend,
2263 const _CharT* __first, const _CharT* __last)
2265 if (__last - __first > *__gbeg)
2267 const bool __bump = __gbeg + 1 != __gend;
2268 __s = std::__add_grouping(__s, __sep, __gbeg + __bump,
2269 __gend, __first, __last - *__gbeg);
2270 __first = __last - *__gbeg;
2274 *__s++ = *__first++;
2275 while (__first != __last);
2279 // Inhibit implicit instantiations for required instantiations,
2280 // which are defined via explicit instantiations elsewhere.
2281 // NB: This syntax is a GNU extension.
2282 #if _GLIBCXX_EXTERN_TEMPLATE
2283 extern template class moneypunct<char, false>;
2284 extern template class moneypunct<char, true>;
2285 extern template class moneypunct_byname<char, false>;
2286 extern template class moneypunct_byname<char, true>;
2287 extern template class money_get<char>;
2288 extern template class money_put<char>;
2289 extern template class numpunct<char>;
2290 extern template class numpunct_byname<char>;
2291 extern template class num_get<char>;
2292 extern template class num_put<char>;
2293 extern template class __timepunct<char>;
2294 extern template class time_put<char>;
2295 extern template class time_put_byname<char>;
2296 extern template class time_get<char>;
2297 extern template class time_get_byname<char>;
2298 extern template class messages<char>;
2299 extern template class messages_byname<char>;
2300 extern template class ctype_byname<char>;
2301 extern template class codecvt_byname<char, char, mbstate_t>;
2302 extern template class collate<char>;
2303 extern template class collate_byname<char>;
2306 const codecvt<char, char, mbstate_t>&
2307 use_facet<codecvt<char, char, mbstate_t> >(const locale&);
2310 const collate<char>&
2311 use_facet<collate<char> >(const locale&);
2314 const numpunct<char>&
2315 use_facet<numpunct<char> >(const locale&);
2318 const num_put<char>&
2319 use_facet<num_put<char> >(const locale&);
2322 const num_get<char>&
2323 use_facet<num_get<char> >(const locale&);
2326 const moneypunct<char, true>&
2327 use_facet<moneypunct<char, true> >(const locale&);
2330 const moneypunct<char, false>&
2331 use_facet<moneypunct<char, false> >(const locale&);
2334 const money_put<char>&
2335 use_facet<money_put<char> >(const locale&);
2338 const money_get<char>&
2339 use_facet<money_get<char> >(const locale&);
2342 const __timepunct<char>&
2343 use_facet<__timepunct<char> >(const locale&);
2346 const time_put<char>&
2347 use_facet<time_put<char> >(const locale&);
2350 const time_get<char>&
2351 use_facet<time_get<char> >(const locale&);
2354 const messages<char>&
2355 use_facet<messages<char> >(const locale&);
2359 has_facet<ctype<char> >(const locale&);
2363 has_facet<codecvt<char, char, mbstate_t> >(const locale&);
2367 has_facet<collate<char> >(const locale&);
2371 has_facet<numpunct<char> >(const locale&);
2375 has_facet<num_put<char> >(const locale&);
2379 has_facet<num_get<char> >(const locale&);
2383 has_facet<moneypunct<char> >(const locale&);
2387 has_facet<money_put<char> >(const locale&);
2391 has_facet<money_get<char> >(const locale&);
2395 has_facet<__timepunct<char> >(const locale&);
2399 has_facet<time_put<char> >(const locale&);
2403 has_facet<time_get<char> >(const locale&);
2407 has_facet<messages<char> >(const locale&);
2409 #ifdef _GLIBCXX_USE_WCHAR_T
2410 extern template class moneypunct<wchar_t, false>;
2411 extern template class moneypunct<wchar_t, true>;
2412 extern template class moneypunct_byname<wchar_t, false>;
2413 extern template class moneypunct_byname<wchar_t, true>;
2414 extern template class money_get<wchar_t>;
2415 extern template class money_put<wchar_t>;
2416 extern template class numpunct<wchar_t>;
2417 extern template class numpunct_byname<wchar_t>;
2418 extern template class num_get<wchar_t>;
2419 extern template class num_put<wchar_t>;
2420 extern template class __timepunct<wchar_t>;
2421 extern template class time_put<wchar_t>;
2422 extern template class time_put_byname<wchar_t>;
2423 extern template class time_get<wchar_t>;
2424 extern template class time_get_byname<wchar_t>;
2425 extern template class messages<wchar_t>;
2426 extern template class messages_byname<wchar_t>;
2427 extern template class ctype_byname<wchar_t>;
2428 extern template class codecvt_byname<wchar_t, char, mbstate_t>;
2429 extern template class collate<wchar_t>;
2430 extern template class collate_byname<wchar_t>;
2433 const codecvt<wchar_t, char, mbstate_t>&
2434 use_facet<codecvt<wchar_t, char, mbstate_t> >(locale const&);
2437 const collate<wchar_t>&
2438 use_facet<collate<wchar_t> >(const locale&);
2441 const numpunct<wchar_t>&
2442 use_facet<numpunct<wchar_t> >(const locale&);
2445 const num_put<wchar_t>&
2446 use_facet<num_put<wchar_t> >(const locale&);
2449 const num_get<wchar_t>&
2450 use_facet<num_get<wchar_t> >(const locale&);
2453 const moneypunct<wchar_t, true>&
2454 use_facet<moneypunct<wchar_t, true> >(const locale&);
2457 const moneypunct<wchar_t, false>&
2458 use_facet<moneypunct<wchar_t, false> >(const locale&);
2461 const money_put<wchar_t>&
2462 use_facet<money_put<wchar_t> >(const locale&);
2465 const money_get<wchar_t>&
2466 use_facet<money_get<wchar_t> >(const locale&);
2469 const __timepunct<wchar_t>&
2470 use_facet<__timepunct<wchar_t> >(const locale&);
2473 const time_put<wchar_t>&
2474 use_facet<time_put<wchar_t> >(const locale&);
2477 const time_get<wchar_t>&
2478 use_facet<time_get<wchar_t> >(const locale&);
2481 const messages<wchar_t>&
2482 use_facet<messages<wchar_t> >(const locale&);
2486 has_facet<ctype<wchar_t> >(const locale&);
2490 has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
2494 has_facet<collate<wchar_t> >(const locale&);
2498 has_facet<numpunct<wchar_t> >(const locale&);
2502 has_facet<num_put<wchar_t> >(const locale&);
2506 has_facet<num_get<wchar_t> >(const locale&);
2510 has_facet<moneypunct<wchar_t> >(const locale&);
2514 has_facet<money_put<wchar_t> >(const locale&);
2518 has_facet<money_get<wchar_t> >(const locale&);
2522 has_facet<__timepunct<wchar_t> >(const locale&);
2526 has_facet<time_put<wchar_t> >(const locale&);
2530 has_facet<time_get<wchar_t> >(const locale&);
2534 has_facet<messages<wchar_t> >(const locale&);