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 while (__beg != __end)
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;
187 else if (__traits_type::eq(__c, __lc->_M_thousands_sep)
188 && __lc->_M_use_grouping && !__found_dec)
190 // NB: Thousands separator at the beginning of a string
191 // is a no-no, as is two consecutive thousands separators.
194 __found_grouping += static_cast<char>(__sep_pos);
200 __err |= ios_base::failbit;
204 else if (__traits_type::eq(__c, __lc->_M_decimal_point)
207 // According to the standard, if no grouping chars are seen,
208 // no grouping check is applied. Therefore __found_grouping
209 // must be adjusted only if __dec comes after some __sep.
210 if (__found_grouping.size())
211 __found_grouping += static_cast<char>(__sep_pos);
216 else if ((__e = __traits_type::eq(__c, __lit[_S_ie])
217 || __traits_type::eq(__c, __lit[_S_iE]))
218 && __found_mantissa && !__found_sci)
220 // Scientific notation.
221 __xtrc += __e ? _S_atoms_in[_S_ie] : _S_atoms_in[_S_iE];
224 // Remove optional plus or minus sign, if they exist.
225 if (++__beg != __end)
227 const bool __plus = __traits_type::eq(*__beg, __lit[_S_iplus]);
228 if (__plus || __traits_type::eq(*__beg, __lit[_S_iminus]))
230 __xtrc += __plus ? _S_atoms_in[_S_iplus]
231 : _S_atoms_in[_S_iminus];
237 // Not a valid input item.
241 // Digit grouping is checked. If grouping and found_grouping don't
242 // match, then get very very upset, and set failbit.
243 if (__lc->_M_use_grouping && __found_grouping.size())
245 // Add the ending grouping if a decimal wasn't found.
247 __found_grouping += static_cast<char>(__sep_pos);
249 const string __grouping = __lc->_M_grouping;
250 if (!std::__verify_grouping(__grouping, __found_grouping))
251 __err |= ios_base::failbit;
257 __err |= ios_base::eofbit;
261 template<typename _CharT, typename _InIter>
263 num_get<_CharT, _InIter>::
264 _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
265 ios_base::iostate& __err, string& __xtrc, int& __base) const
267 typedef char_traits<_CharT> __traits_type;
268 typedef typename numpunct<_CharT>::__cache_type __cache_type;
269 __use_cache<__cache_type> __uc;
270 const locale& __loc = __io._M_getloc();
271 const __cache_type* __lc = __uc(__loc);
272 const _CharT* __lit = __lc->_M_atoms_in;
274 // NB: Iff __basefield == 0, this can change based on contents.
275 const ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
276 if (__basefield == ios_base::oct)
278 else if (__basefield == ios_base::hex)
283 // First check for sign.
286 const char_type __c = *__beg;
287 const bool __plus = __traits_type::eq(__c, __lit[_S_iplus]);
288 if (__plus || __traits_type::eq(__c, __lit[_S_iminus]))
290 __xtrc += __plus ? _S_atoms_in[_S_iplus]
291 : _S_atoms_in[_S_iminus];
296 // Next, look for leading zeros and check required digits for base formats.
297 if (__builtin_expect(__base == 10, true))
299 // Look for a zero...
300 if (__beg != __end && __traits_type::eq(*__beg, __lit[_S_izero]))
302 __xtrc += _S_atoms_in[_S_izero];
304 // ... and skip the additional ones.
305 for (; __beg != __end
306 && __traits_type::eq(*__beg, __lit[_S_izero]); ++__beg);
308 // Check required digits.
309 if (__beg != __end && __basefield == 0)
311 const bool __x = __traits_type::eq(*__beg, __lit[_S_ix]);
312 if (__x || __traits_type::eq(*__beg, __lit[_S_iX]))
314 __xtrc += __x ? _S_atoms_in[_S_ix]
315 : _S_atoms_in[_S_iX];
324 else if (__base == 16)
326 if (__beg != __end && __traits_type::eq(*__beg, __lit[_S_izero]))
328 __xtrc += _S_atoms_in[_S_izero];
330 if (++__beg != __end)
332 const bool __x = __traits_type::eq(*__beg, __lit[_S_ix]);
333 if (__x || __traits_type::eq(*__beg, __lit[_S_iX]))
335 __xtrc += __x ? _S_atoms_in[_S_ix]
336 : _S_atoms_in[_S_iX];
343 // At this point, base is determined. If not hex, only allow
344 // base digits as valid input.
345 const size_t __len = __base == 16 ? _S_iend : __base;
348 string __found_grouping;
350 for (; __beg != __end; ++__beg)
352 const char_type __c = *__beg;
353 const char_type* __p = __traits_type::find(__lit + _S_izero,
355 // NB: strchr returns true for __c == 0x0
356 if (__p && !__traits_type::eq(__c, char_type()))
358 // Try first for acceptable digit; record it if found.
359 __xtrc += _S_atoms_in[__p - __lit];
362 else if (__traits_type::eq(__c, __lc->_M_thousands_sep)
363 && __lc->_M_use_grouping)
365 // NB: Thousands separator at the beginning of a string
366 // is a no-no, as is two consecutive thousands separators.
369 __found_grouping += static_cast<char>(__sep_pos);
374 __err |= ios_base::failbit;
379 // Not a valid input item.
383 // Digit grouping is checked. If grouping and found_grouping don't
384 // match, then get very very upset, and set failbit.
385 if (__lc->_M_use_grouping && __found_grouping.size())
387 // Add the ending grouping.
388 __found_grouping += static_cast<char>(__sep_pos);
390 const string __grouping = __lc->_M_grouping;
391 if (!std::__verify_grouping(__grouping, __found_grouping))
392 __err |= ios_base::failbit;
398 __err |= ios_base::eofbit;
402 // _GLIBCXX_RESOLVE_LIB_DEFECTS
403 // 17. Bad bool parsing
404 template<typename _CharT, typename _InIter>
406 num_get<_CharT, _InIter>::
407 do_get(iter_type __beg, iter_type __end, ios_base& __io,
408 ios_base::iostate& __err, bool& __v) const
410 if (!(__io.flags() & ios_base::boolalpha))
412 // Parse bool values as unsigned long.
413 // NB: We can't just call do_get(long) here, as it might
414 // refer to a derived class.
417 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
420 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
421 _S_get_c_locale(), __base);
422 if (!(__err & ios_base::failbit) && __ul <= 1)
425 __err |= ios_base::failbit;
429 // Parse bool values as alphanumeric.
430 typedef char_traits<_CharT> __traits_type;
431 typedef typename numpunct<_CharT>::__cache_type __cache_type;
432 __use_cache<__cache_type> __uc;
433 const locale& __loc = __io._M_getloc();
434 const __cache_type* __lc = __uc(__loc);
435 const size_t __tn = __traits_type::length(__lc->_M_truename) - 1;
436 const size_t __fn = __traits_type::length(__lc->_M_falsename) - 1;
438 bool __testf = false;
439 bool __testt = false;
440 for (size_t __n = 0; __beg != __end; ++__n)
442 const char_type __c = *__beg;
446 __testf = __traits_type::eq(__c, __lc->_M_falsename[__n]);
449 __testt = __traits_type::eq(__c, __lc->_M_truename[__n]);
451 if (!(__testf || __testt))
453 __err |= ios_base::failbit;
456 else if (__testf && __n == __fn)
461 else if (__testt && __n == __tn)
468 __err |= ios_base::eofbit;
473 template<typename _CharT, typename _InIter>
475 num_get<_CharT, _InIter>::
476 do_get(iter_type __beg, iter_type __end, ios_base& __io,
477 ios_base::iostate& __err, long& __v) const
481 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
482 std::__convert_to_v(__xtrc.c_str(), __v, __err,
483 _S_get_c_locale(), __base);
487 template<typename _CharT, typename _InIter>
489 num_get<_CharT, _InIter>::
490 do_get(iter_type __beg, iter_type __end, ios_base& __io,
491 ios_base::iostate& __err, unsigned short& __v) const
495 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
497 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
498 _S_get_c_locale(), __base);
499 if (!(__err & ios_base::failbit)
500 && __ul <= numeric_limits<unsigned short>::max())
501 __v = static_cast<unsigned short>(__ul);
503 __err |= ios_base::failbit;
507 template<typename _CharT, typename _InIter>
509 num_get<_CharT, _InIter>::
510 do_get(iter_type __beg, iter_type __end, ios_base& __io,
511 ios_base::iostate& __err, unsigned int& __v) const
515 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
517 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
518 _S_get_c_locale(), __base);
519 if (!(__err & ios_base::failbit)
520 && __ul <= numeric_limits<unsigned int>::max())
521 __v = static_cast<unsigned int>(__ul);
523 __err |= ios_base::failbit;
527 template<typename _CharT, typename _InIter>
529 num_get<_CharT, _InIter>::
530 do_get(iter_type __beg, iter_type __end, ios_base& __io,
531 ios_base::iostate& __err, unsigned long& __v) const
535 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
536 std::__convert_to_v(__xtrc.c_str(), __v, __err,
537 _S_get_c_locale(), __base);
541 #ifdef _GLIBCXX_USE_LONG_LONG
542 template<typename _CharT, typename _InIter>
544 num_get<_CharT, _InIter>::
545 do_get(iter_type __beg, iter_type __end, ios_base& __io,
546 ios_base::iostate& __err, long long& __v) const
550 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
551 std::__convert_to_v(__xtrc.c_str(), __v, __err,
552 _S_get_c_locale(), __base);
556 template<typename _CharT, typename _InIter>
558 num_get<_CharT, _InIter>::
559 do_get(iter_type __beg, iter_type __end, ios_base& __io,
560 ios_base::iostate& __err, unsigned long long& __v) const
564 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
565 std::__convert_to_v(__xtrc.c_str(), __v, __err,
566 _S_get_c_locale(), __base);
571 template<typename _CharT, typename _InIter>
573 num_get<_CharT, _InIter>::
574 do_get(iter_type __beg, iter_type __end, ios_base& __io,
575 ios_base::iostate& __err, float& __v) const
579 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
580 std::__convert_to_v(__xtrc.c_str(), __v, __err,
585 template<typename _CharT, typename _InIter>
587 num_get<_CharT, _InIter>::
588 do_get(iter_type __beg, iter_type __end, ios_base& __io,
589 ios_base::iostate& __err, double& __v) const
593 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
594 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
598 template<typename _CharT, typename _InIter>
600 num_get<_CharT, _InIter>::
601 do_get(iter_type __beg, iter_type __end, ios_base& __io,
602 ios_base::iostate& __err, long double& __v) const
606 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
607 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
611 template<typename _CharT, typename _InIter>
613 num_get<_CharT, _InIter>::
614 do_get(iter_type __beg, iter_type __end, ios_base& __io,
615 ios_base::iostate& __err, void*& __v) const
617 // Prepare for hex formatted input.
618 typedef ios_base::fmtflags fmtflags;
619 const fmtflags __fmt = __io.flags();
620 const fmtflags __fmtmask = ~(ios_base::showpos | ios_base::basefield
621 | ios_base::uppercase | ios_base::internal);
622 __io.flags(__fmt & __fmtmask | (ios_base::hex | ios_base::showbase));
626 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
628 // Reset from hex formatted input.
632 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
633 _S_get_c_locale(), __base);
634 if (!(__err & ios_base::failbit))
635 __v = reinterpret_cast<void*>(__ul);
637 __err |= ios_base::failbit;
641 // For use by integer and floating-point types after they have been
642 // converted into a char_type string.
643 template<typename _CharT, typename _OutIter>
645 num_put<_CharT, _OutIter>::
646 _M_pad(_CharT __fill, streamsize __w, ios_base& __io,
647 _CharT* __new, const _CharT* __cs, int& __len) const
649 // [22.2.2.2.2] Stage 3.
650 // If necessary, pad.
651 __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, __cs,
653 __len = static_cast<int>(__w);
656 // Forwarding functions to peel signed from unsigned integer types.
657 template<typename _CharT>
659 __int_to_char(_CharT* __bufend, long __v, const _CharT* __lit,
660 ios_base::fmtflags __flags)
662 unsigned long __ul = static_cast<unsigned long>(__v);
669 return __int_to_char(__bufend, __ul, __lit, __flags, __neg);
672 template<typename _CharT>
674 __int_to_char(_CharT* __bufend, unsigned long __v, const _CharT* __lit,
675 ios_base::fmtflags __flags)
676 { return __int_to_char(__bufend, __v, __lit, __flags, false); }
678 #ifdef _GLIBCXX_USE_LONG_LONG
679 template<typename _CharT>
681 __int_to_char(_CharT* __bufend, long long __v, const _CharT* __lit,
682 ios_base::fmtflags __flags)
684 unsigned long long __ull = static_cast<unsigned long long>(__v);
691 return __int_to_char(__bufend, __ull, __lit, __flags, __neg);
694 template<typename _CharT>
696 __int_to_char(_CharT* __bufend, unsigned long long __v, const _CharT* __lit,
697 ios_base::fmtflags __flags)
698 { return __int_to_char(__bufend, __v, __lit, __flags, false); }
701 template<typename _CharT, typename _ValueT>
703 __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit,
704 ios_base::fmtflags __flags, bool __neg)
706 // Don't write base if already 0.
707 const bool __showbase = (__flags & ios_base::showbase) && __v;
708 const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
709 _CharT* __buf = __bufend - 1;
711 if (__builtin_expect(__basefield != ios_base::oct &&
712 __basefield != ios_base::hex, true))
717 *__buf-- = __lit[(__v % 10) + __num_base::_S_odigits];
722 *__buf-- = __lit[__num_base::_S_ominus];
723 else if (__flags & ios_base::showpos)
724 *__buf-- = __lit[__num_base::_S_oplus];
726 else if (__basefield == ios_base::oct)
731 *__buf-- = __lit[(__v & 0x7) + __num_base::_S_odigits];
736 *__buf-- = __lit[__num_base::_S_odigits];
741 const bool __uppercase = __flags & ios_base::uppercase;
742 const int __case_offset = __uppercase ? __num_base::_S_oudigits
743 : __num_base::_S_odigits;
746 *__buf-- = __lit[(__v & 0xf) + __case_offset];
753 *__buf-- = __lit[__num_base::_S_ox + __uppercase];
755 *__buf-- = __lit[__num_base::_S_odigits];
758 return __bufend - __buf - 1;
761 template<typename _CharT, typename _OutIter>
763 num_put<_CharT, _OutIter>::
764 _M_group_int(const string& __grouping, _CharT __sep, ios_base& __io,
765 _CharT* __new, _CharT* __cs, int& __len) const
767 // By itself __add_grouping cannot deal correctly with __ws when
768 // ios::showbase is set and ios_base::oct || ios_base::hex.
769 // Therefore we take care "by hand" of the initial 0, 0x or 0X.
770 // However, remember that the latter do not occur if the number
771 // printed is '0' (__len == 1).
772 streamsize __off = 0;
773 const ios_base::fmtflags __basefield = __io.flags()
774 & ios_base::basefield;
775 if ((__io.flags() & ios_base::showbase) && __len > 1)
776 if (__basefield == ios_base::oct)
781 else if (__basefield == ios_base::hex)
788 __p = std::__add_grouping(__new + __off, __sep, __grouping.data(),
789 __grouping.data() + __grouping.size(),
790 __cs + __off, __cs + __len);
794 template<typename _CharT, typename _OutIter>
795 template<typename _ValueT>
797 num_put<_CharT, _OutIter>::
798 _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
801 typedef typename numpunct<_CharT>::__cache_type __cache_type;
802 __use_cache<__cache_type> __uc;
803 const locale& __loc = __io._M_getloc();
804 const __cache_type* __lc = __uc(__loc);
805 const _CharT* __lit = __lc->_M_atoms_out;
807 // Long enough to hold hex, dec, and octal representations.
808 const int __ilen = 4 * sizeof(_ValueT);
809 _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
812 // [22.2.2.2.2] Stage 1, numeric conversion to character.
813 // Result is returned right-justified in the buffer.
815 __len = __int_to_char(__cs + __ilen, __v, __lit, __io.flags());
816 __cs += __ilen - __len;
818 // Add grouping, if necessary.
820 if (__lc->_M_use_grouping)
822 // Grouping can add (almost) as many separators as the
823 // number of digits, but no more.
824 __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
826 _M_group_int(__lc->_M_grouping, __lc->_M_thousands_sep, __io,
833 const streamsize __w = __io.width();
834 if (__w > static_cast<streamsize>(__len))
836 __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
838 _M_pad(__fill, __w, __io, __cs3, __cs, __len);
843 // [22.2.2.2.2] Stage 4.
844 // Write resulting, fully-formatted string to output iterator.
845 return std::__write(__s, __cs, __len);
848 template<typename _CharT, typename _OutIter>
850 num_put<_CharT, _OutIter>::
851 _M_group_float(const string& __grouping, _CharT __sep, const _CharT* __p,
852 _CharT* __new, _CharT* __cs, int& __len) const
854 // _GLIBCXX_RESOLVE_LIB_DEFECTS
855 // 282. What types does numpunct grouping refer to?
856 // Add grouping, if necessary.
858 const int __declen = __p ? __p - __cs : __len;
859 __p2 = std::__add_grouping(__new, __sep, __grouping.data(),
860 __grouping.data() + __grouping.size(),
861 __cs, __cs + __declen);
863 // Tack on decimal part.
864 int __newlen = __p2 - __new;
867 char_traits<_CharT>::copy(__p2, __p, __len - __declen);
868 __newlen += __len - __declen;
873 // The following code uses snprintf (or sprintf(), when
874 // _GLIBCXX_USE_C99 is not defined) to convert floating point values
875 // for insertion into a stream. An optimization would be to replace
876 // them with code that works directly on a wide buffer and then use
877 // __pad to do the padding. It would be good to replace them anyway
878 // to gain back the efficiency that C++ provides by knowing up front
879 // the type of the values to insert. Also, sprintf is dangerous
880 // since may lead to accidental buffer overruns. This
881 // implementation follows the C++ standard fairly directly as
882 // outlined in 22.2.2.2 [lib.locale.num.put]
883 template<typename _CharT, typename _OutIter>
884 template<typename _ValueT>
886 num_put<_CharT, _OutIter>::
887 _M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
890 typedef typename numpunct<_CharT>::__cache_type __cache_type;
891 __use_cache<__cache_type> __uc;
892 const locale& __loc = __io._M_getloc();
893 const __cache_type* __lc = __uc(__loc);
895 // Note: digits10 is rounded down: add 1 to ensure the maximum
896 // available precision. Then, in general, one more 1 needs to
897 // be added since, when the %{g,G} conversion specifiers are
898 // chosen inside _S_format_float, the precision field is "the
899 // maximum number of significant digits", *not* the "number of
900 // digits to appear after the decimal point", as happens for
901 // %{e,E,f,F} (C99, 7.19.6.1,4).
902 const int __max_digits = numeric_limits<_ValueT>::digits10 + 2;
904 // Use default precision if out of range.
905 streamsize __prec = __io.precision();
906 if (__prec > static_cast<streamsize>(__max_digits))
907 __prec = static_cast<streamsize>(__max_digits);
908 else if (__prec < static_cast<streamsize>(0))
909 __prec = static_cast<streamsize>(6);
911 // [22.2.2.2.2] Stage 1, numeric conversion to character.
913 // Long enough for the max format spec.
916 #ifdef _GLIBCXX_USE_C99
917 // First try a buffer perhaps big enough (for sure sufficient
918 // for non-ios_base::fixed outputs)
919 int __cs_size = __max_digits * 3;
920 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
922 _S_format_float(__io, __fbuf, __mod);
923 __len = std::__convert_from_v(__cs, __cs_size, __fbuf, __v,
924 _S_get_c_locale(), __prec);
926 // If the buffer was not large enough, try again with the correct size.
927 if (__len >= __cs_size)
929 __cs_size = __len + 1;
930 __cs = static_cast<char*>(__builtin_alloca(__cs_size));
931 __len = std::__convert_from_v(__cs, __cs_size, __fbuf, __v,
932 _S_get_c_locale(), __prec);
935 // Consider the possibility of long ios_base::fixed outputs
936 const bool __fixed = __io.flags() & ios_base::fixed;
937 const int __max_exp = numeric_limits<_ValueT>::max_exponent10;
939 // The size of the output string is computed as follows.
940 // ios_base::fixed outputs may need up to __max_exp+1 chars
941 // for the integer part + up to __max_digits chars for the
942 // fractional part + 3 chars for sign, decimal point, '\0'. On
943 // the other hand, for non-fixed outputs __max_digits*3 chars
944 // are largely sufficient.
945 const int __cs_size = __fixed ? __max_exp + __max_digits + 4
947 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
949 _S_format_float(__io, __fbuf, __mod);
950 __len = std::__convert_from_v(__cs, 0, __fbuf, __v,
951 _S_get_c_locale(), __prec);
954 // [22.2.2.2.2] Stage 2, convert to char_type, using correct
955 // numpunct.decimal_point() values for '.' and adding grouping.
956 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
958 _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
960 __ctype.widen(__cs, __cs + __len, __ws);
962 // Replace decimal point.
963 const _CharT __cdec = __ctype.widen('.');
964 const _CharT __dec = __lc->_M_decimal_point;
966 if (__p = char_traits<_CharT>::find(__ws, __len, __cdec))
967 __ws[__p - __ws] = __dec;
969 // Add grouping, if necessary.
971 if (__lc->_M_use_grouping)
973 // Grouping can add (almost) as many separators as the
974 // number of digits, but no more.
975 __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
977 _M_group_float(__lc->_M_grouping, __lc->_M_thousands_sep, __p,
984 const streamsize __w = __io.width();
985 if (__w > static_cast<streamsize>(__len))
987 __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
988 _M_pad(__fill, __w, __io, __ws3, __ws, __len);
993 // [22.2.2.2.2] Stage 4.
994 // Write resulting, fully-formatted string to output iterator.
995 return std::__write(__s, __ws, __len);
998 template<typename _CharT, typename _OutIter>
1000 num_put<_CharT, _OutIter>::
1001 do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
1003 const ios_base::fmtflags __flags = __io.flags();
1004 if ((__flags & ios_base::boolalpha) == 0)
1006 unsigned long __uv = __v;
1007 __s = _M_insert_int(__s, __io, __fill, __uv);
1011 typedef typename numpunct<_CharT>::__cache_type __cache_type;
1012 __use_cache<__cache_type> __uc;
1013 const locale& __loc = __io._M_getloc();
1014 const __cache_type* __lc = __uc(__loc);
1016 const _CharT* __name;
1017 __name = __v ? __lc->_M_truename : __lc->_M_falsename;
1018 int __len = char_traits<_CharT>::length(__name);
1021 const streamsize __w = __io.width();
1022 if (__w > static_cast<streamsize>(__len))
1024 __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1026 _M_pad(__fill, __w, __io, __cs, __name, __len);
1030 __s = std::__write(__s, __name, __len);
1035 template<typename _CharT, typename _OutIter>
1037 num_put<_CharT, _OutIter>::
1038 do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
1039 { return _M_insert_int(__s, __io, __fill, __v); }
1041 template<typename _CharT, typename _OutIter>
1043 num_put<_CharT, _OutIter>::
1044 do_put(iter_type __s, ios_base& __io, char_type __fill,
1045 unsigned long __v) const
1046 { return _M_insert_int(__s, __io, __fill, __v); }
1048 #ifdef _GLIBCXX_USE_LONG_LONG
1049 template<typename _CharT, typename _OutIter>
1051 num_put<_CharT, _OutIter>::
1052 do_put(iter_type __s, ios_base& __b, char_type __fill, long long __v) const
1053 { return _M_insert_int(__s, __b, __fill, __v); }
1055 template<typename _CharT, typename _OutIter>
1057 num_put<_CharT, _OutIter>::
1058 do_put(iter_type __s, ios_base& __io, char_type __fill,
1059 unsigned long long __v) const
1060 { return _M_insert_int(__s, __io, __fill, __v); }
1063 template<typename _CharT, typename _OutIter>
1065 num_put<_CharT, _OutIter>::
1066 do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
1067 { return _M_insert_float(__s, __io, __fill, char(), __v); }
1069 template<typename _CharT, typename _OutIter>
1071 num_put<_CharT, _OutIter>::
1072 do_put(iter_type __s, ios_base& __io, char_type __fill,
1073 long double __v) const
1074 { return _M_insert_float(__s, __io, __fill, 'L', __v); }
1076 template<typename _CharT, typename _OutIter>
1078 num_put<_CharT, _OutIter>::
1079 do_put(iter_type __s, ios_base& __io, char_type __fill,
1080 const void* __v) const
1082 const ios_base::fmtflags __flags = __io.flags();
1083 const ios_base::fmtflags __fmt = ~(ios_base::showpos | ios_base::basefield
1084 | ios_base::uppercase | ios_base::internal);
1085 __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
1088 __s = _M_insert_int(__s, __io, __fill,
1089 reinterpret_cast<unsigned long>(__v));
1090 __io.flags(__flags);
1094 __io.flags(__flags);
1095 __throw_exception_again;
1101 template<typename _CharT, typename _InIter>
1103 money_get<_CharT, _InIter>::
1104 do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
1105 ios_base::iostate& __err, long double& __units) const
1108 __beg = this->do_get(__beg, __end, __intl, __io, __err, __str);
1110 const int __cs_size = __str.size() + 1;
1111 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1112 const locale __loc = __io.getloc();
1113 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1114 const _CharT* __wcs = __str.c_str();
1115 __ctype.narrow(__wcs, __wcs + __cs_size, char(), __cs);
1116 std::__convert_to_v(__cs, __units, __err, _S_get_c_locale());
1120 template<typename _CharT, typename _InIter>
1122 money_get<_CharT, _InIter>::
1123 do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
1124 ios_base::iostate& __err, string_type& __units) const
1126 // These contortions are quite unfortunate.
1127 typedef moneypunct<_CharT, true> __money_true;
1128 typedef moneypunct<_CharT, false> __money_false;
1129 typedef money_base::part part;
1130 typedef typename string_type::size_type size_type;
1132 const locale __loc = __io.getloc();
1133 const __money_true& __mpt = use_facet<__money_true>(__loc);
1134 const __money_false& __mpf = use_facet<__money_false>(__loc);
1135 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1137 const money_base::pattern __p = __intl ? __mpt.neg_format()
1138 : __mpf.neg_format();
1140 const string_type __pos_sign = __intl ? __mpt.positive_sign()
1141 : __mpf.positive_sign();
1142 const string_type __neg_sign = __intl ? __mpt.negative_sign()
1143 : __mpf.negative_sign();
1144 const char_type __d = __intl ? __mpt.decimal_point()
1145 : __mpf.decimal_point();
1146 const char_type __sep = __intl ? __mpt.thousands_sep()
1147 : __mpf.thousands_sep();
1149 const string __grouping = __intl ? __mpt.grouping() : __mpf.grouping();
1151 // Set to deduced positive or negative sign, depending.
1153 // String of grouping info from thousands_sep plucked from __units.
1154 string __grouping_tmp;
1155 // Marker for thousands_sep position.
1157 // If input iterator is in a valid state.
1158 bool __testvalid = true;
1159 // Flag marking when a decimal point is found.
1160 bool __testdecfound = false;
1162 // The tentative returned string is stored here.
1163 string_type __tmp_units;
1165 for (int __i = 0; __beg != __end && __i < 4 && __testvalid; ++__i)
1168 const part __which = static_cast<part>(__p.field[__i]);
1171 case money_base::symbol:
1172 if (__io.flags() & ios_base::showbase
1173 || __i < 2 || __sign.size() > 1
1174 || ((static_cast<part>(__p.field[3]) != money_base::none)
1177 // According to 22.2.6.1.2.2, symbol is required
1178 // if (__io.flags() & ios_base::showbase),
1179 // otherwise is optional and consumed only if
1180 // other characters are needed to complete the
1182 const string_type __symbol = __intl ? __mpt.curr_symbol()
1183 : __mpf.curr_symbol();
1184 const size_type __len = __symbol.size();
1186 for (; __beg != __end && __j < __len
1187 && *__beg == __symbol[__j]; ++__beg, ++__j);
1188 // When (__io.flags() & ios_base::showbase)
1189 // symbol is required.
1190 if (__j != __len && (__io.flags() & ios_base::showbase))
1191 __testvalid = false;
1194 case money_base::sign:
1195 // Sign might not exist, or be more than one character long.
1196 if (__pos_sign.size() && *__beg == __pos_sign[0])
1198 __sign = __pos_sign;
1201 else if (__neg_sign.size() && *__beg == __neg_sign[0])
1203 __sign = __neg_sign;
1206 else if (__pos_sign.size() && __neg_sign.size())
1208 // Sign is mandatory.
1209 __testvalid = false;
1212 case money_base::value:
1213 // Extract digits, remove and stash away the
1214 // grouping of found thousands separators.
1215 for (; __beg != __end; ++__beg)
1216 if (__ctype.is(ctype_base::digit, __c = *__beg))
1221 else if (__c == __d && !__testdecfound)
1223 __grouping_tmp += static_cast<char>(__sep_pos);
1225 __testdecfound = true;
1227 else if (__c == __sep)
1229 if (__grouping.size())
1231 // Mark position for later analysis.
1232 __grouping_tmp += static_cast<char>(__sep_pos);
1237 __testvalid = false;
1244 case money_base::space:
1245 case money_base::none:
1246 // Only if not at the end of the pattern.
1248 for (; __beg != __end
1249 && __ctype.is(ctype_base::space, *__beg); ++__beg);
1254 // Need to get the rest of the sign characters, if they exist.
1255 if (__sign.size() > 1)
1257 const size_type __len = __sign.size();
1259 for (; __beg != __end && __i < __len; ++__i)
1260 for (; __beg != __end
1261 && *__beg != __sign[__i]; ++__beg);
1264 __testvalid = false;
1267 if (__testvalid && __tmp_units.size())
1269 const char_type __zero = __ctype.widen('0');
1271 // Strip leading zeros.
1272 if (__tmp_units.size() > 1)
1274 const size_type __first = __tmp_units.find_first_not_of(__zero);
1275 const bool __only_zeros = __first == string_type::npos;
1277 __tmp_units.erase(0, __only_zeros ? __tmp_units.size() - 1
1282 if (__sign.size() && __sign == __neg_sign
1283 && __tmp_units[0] != __zero)
1284 __tmp_units.insert(__tmp_units.begin(), __ctype.widen('-'));
1286 // Test for grouping fidelity.
1287 if (__grouping.size() && __grouping_tmp.size())
1289 if (!std::__verify_grouping(__grouping, __grouping_tmp))
1290 __testvalid = false;
1293 // Iff not enough digits were supplied after the decimal-point.
1296 const int __frac = __intl ? __mpt.frac_digits()
1297 : __mpf.frac_digits();
1298 if (__frac > 0 && __sep_pos != __frac)
1299 __testvalid = false;
1303 __testvalid = false;
1305 // Iff no more characters are available.
1307 __err |= ios_base::eofbit;
1309 // Iff valid sequence is not recognized.
1311 __err |= ios_base::failbit;
1313 // Use the "swap trick" to copy __tmp_units into __units.
1314 __tmp_units.swap(__units);
1319 template<typename _CharT, typename _OutIter>
1321 money_put<_CharT, _OutIter>::
1322 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1323 long double __units) const
1325 const locale __loc = __io.getloc();
1326 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1327 #ifdef _GLIBCXX_USE_C99
1328 // First try a buffer perhaps big enough.
1330 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1331 int __len = std::__convert_from_v(__cs, __cs_size, "%.01Lf", __units,
1333 // If the buffer was not large enough, try again with the correct size.
1334 if (__len >= __cs_size)
1336 __cs_size = __len + 1;
1337 __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1338 __len = std::__convert_from_v(__cs, __cs_size, "%.01Lf", __units,
1342 // max_exponent10 + 1 for the integer part, + 4 for sign, decimal point,
1343 // decimal digit, '\0'.
1344 const int __cs_size = numeric_limits<long double>::max_exponent10 + 5;
1345 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1346 int __len = std::__convert_from_v(__cs, 0, "%.01Lf", __units,
1349 _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1351 __ctype.widen(__cs, __cs + __len, __ws);
1352 string_type __digits(__ws);
1353 return this->do_put(__s, __intl, __io, __fill, __digits);
1356 template<typename _CharT, typename _OutIter>
1358 money_put<_CharT, _OutIter>::
1359 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1360 const string_type& __digits) const
1362 typedef typename string_type::size_type size_type;
1363 typedef money_base::part part;
1365 const locale __loc = __io.getloc();
1366 const size_type __width = static_cast<size_type>(__io.width());
1368 // These contortions are quite unfortunate.
1369 typedef moneypunct<_CharT, true> __money_true;
1370 typedef moneypunct<_CharT, false> __money_false;
1371 const __money_true& __mpt = use_facet<__money_true>(__loc);
1372 const __money_false& __mpf = use_facet<__money_false>(__loc);
1373 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1375 // Determine if negative or positive formats are to be used, and
1376 // discard leading negative_sign if it is present.
1377 const char_type* __beg = __digits.data();
1378 const char_type* __end = __beg + __digits.size();
1379 money_base::pattern __p;
1381 if (*__beg != __ctype.widen('-'))
1383 __p = __intl ? __mpt.pos_format() : __mpf.pos_format();
1384 __sign = __intl ? __mpt.positive_sign() : __mpf.positive_sign();
1388 __p = __intl ? __mpt.neg_format() : __mpf.neg_format();
1389 __sign = __intl ? __mpt.negative_sign() : __mpf.negative_sign();
1393 // Look for valid numbers in the current ctype facet within input digits.
1394 __end = __ctype.scan_not(ctype_base::digit, __beg, __end);
1397 // Assume valid input, and attempt to format.
1398 // Break down input numbers into base components, as follows:
1399 // final_value = grouped units + (decimal point) + (digits)
1401 string_type __value;
1402 const string_type __symbol = __intl ? __mpt.curr_symbol()
1403 : __mpf.curr_symbol();
1405 // Deal with decimal point, decimal digits.
1406 const int __frac = __intl ? __mpt.frac_digits()
1407 : __mpf.frac_digits();
1410 const char_type __d = __intl ? __mpt.decimal_point()
1411 : __mpf.decimal_point();
1412 if (__end - __beg >= __frac)
1414 __value = string_type(__end - __frac, __end);
1415 __value.insert(__value.begin(), __d);
1420 // Have to pad zeros in the decimal position.
1421 __value = string_type(__beg, __end);
1422 const int __paddec = __frac - (__end - __beg);
1423 const char_type __zero = __ctype.widen('0');
1424 __value.insert(__value.begin(), __paddec, __zero);
1425 __value.insert(__value.begin(), __d);
1430 // Add thousands separators to non-decimal digits, per
1434 const string __grouping = __intl ? __mpt.grouping()
1436 if (__grouping.size())
1438 const char_type __sep = __intl ? __mpt.thousands_sep()
1439 : __mpf.thousands_sep();
1440 const char* __gbeg = __grouping.data();
1441 const char* __gend = __gbeg + __grouping.size();
1442 const int __n = (__end - __beg) * 2;
1444 static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n));
1445 _CharT* __ws_end = std::__add_grouping(__ws2, __sep, __gbeg,
1446 __gend, __beg, __end);
1447 __value.insert(0, __ws2, __ws_end - __ws2);
1450 __value.insert(0, string_type(__beg, __end));
1453 // Calculate length of resulting string.
1454 const ios_base::fmtflags __f = __io.flags() & ios_base::adjustfield;
1455 size_type __len = __value.size() + __sign.size();
1456 __len += (__io.flags() & ios_base::showbase) ? __symbol.size() : 0;
1457 const bool __testipad = __f == ios_base::internal && __len < __width;
1459 // Fit formatted digits into the required pattern.
1460 for (int __i = 0; __i < 4; ++__i)
1462 const part __which = static_cast<part>(__p.field[__i]);
1465 case money_base::symbol:
1466 if (__io.flags() & ios_base::showbase)
1469 case money_base::sign:
1470 // Sign might not exist, or be more than one
1471 // charater long. In that case, add in the rest
1476 case money_base::value:
1479 case money_base::space:
1480 // At least one space is required, but if internal
1481 // formatting is required, an arbitrary number of
1482 // fill spaces will be necessary.
1484 __res += string_type(__width - __len, __fill);
1486 __res += __ctype.widen(__fill);
1488 case money_base::none:
1490 __res += string_type(__width - __len, __fill);
1495 // Special case of multi-part sign parts.
1496 if (__sign.size() > 1)
1497 __res += string_type(__sign.begin() + 1, __sign.end());
1499 // Pad, if still necessary.
1500 __len = __res.size();
1501 if (__width > __len)
1503 if (__f == ios_base::left)
1505 __res.append(__width - __len, __fill);
1508 __res.insert(0, string_type(__width - __len, __fill));
1512 // Write resulting, fully-formatted string to output iterator.
1513 __s = std::__write(__s, __res.data(), __len);
1520 // NB: Not especially useful. Without an ios_base object or some
1521 // kind of locale reference, we are left clawing at the air where
1522 // the side of the mountain used to be...
1523 template<typename _CharT, typename _InIter>
1524 time_base::dateorder
1525 time_get<_CharT, _InIter>::do_date_order() const
1526 { return time_base::no_order; }
1528 template<typename _CharT, typename _InIter>
1530 time_get<_CharT, _InIter>::
1531 _M_extract_via_format(iter_type& __beg, iter_type& __end, ios_base& __io,
1532 ios_base::iostate& __err, tm* __tm,
1533 const _CharT* __format) const
1535 const locale __loc = __io.getloc();
1536 __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
1537 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1538 const size_t __len = char_traits<_CharT>::length(__format);
1540 for (size_t __i = 0; __beg != __end && __i < __len && !__err; ++__i)
1542 char __c = __format[__i];
1545 // Verify valid formatting code, attempt to extract.
1546 __c = __format[++__i];
1549 if (__c == 'E' || __c == 'O')
1552 __c = __format[++__i];
1559 // Abbreviated weekday name [tm_wday]
1560 const char_type* __days1[7];
1561 __tp._M_days_abbreviated(__days1);
1562 _M_extract_name(__beg, __end, __tm->tm_wday, __days1, 7,
1566 // Weekday name [tm_wday].
1567 const char_type* __days2[7];
1568 __tp._M_days(__days2);
1569 _M_extract_name(__beg, __end, __tm->tm_wday, __days2, 7,
1574 // Abbreviated month name [tm_mon]
1575 const char_type* __months1[12];
1576 __tp._M_months_abbreviated(__months1);
1577 _M_extract_name(__beg, __end, __tm->tm_mon, __months1, 12,
1581 // Month name [tm_mon].
1582 const char_type* __months2[12];
1583 __tp._M_months(__months2);
1584 _M_extract_name(__beg, __end, __tm->tm_mon, __months2, 12,
1588 // Default time and date representation.
1589 const char_type* __dt[2];
1590 __tp._M_date_time_formats(__dt);
1591 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1595 // Day [01, 31]. [tm_mday]
1596 _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
1600 // Day [1, 31], with single digits preceded by
1602 if (__ctype.is(ctype_base::space, *__beg))
1603 _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9, 1,
1606 _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31, 2,
1610 // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
1612 __ctype.widen(__cs, __cs + 9, __wcs);
1613 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1617 // Hour [00, 23]. [tm_hour]
1618 _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
1622 // Hour [01, 12]. [tm_hour]
1623 _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
1627 // Month [01, 12]. [tm_mon]
1628 _M_extract_num(__beg, __end, __mem, 1, 12, 2, __ctype,
1631 __tm->tm_mon = __mem - 1;
1634 // Minute [00, 59]. [tm_min]
1635 _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
1639 if (__ctype.narrow(*__beg, 0) == '\n')
1642 __err |= ios_base::failbit;
1645 // Equivalent to (%H:%M).
1647 __ctype.widen(__cs, __cs + 6, __wcs);
1648 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1653 _M_extract_num(__beg, __end, __tm->tm_sec, 0, 59, 2,
1657 if (__ctype.narrow(*__beg, 0) == '\t')
1660 __err |= ios_base::failbit;
1663 // Equivalent to (%H:%M:%S).
1665 __ctype.widen(__cs, __cs + 9, __wcs);
1666 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1671 const char_type* __dates[2];
1672 __tp._M_date_formats(__dates);
1673 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1678 const char_type* __times[2];
1679 __tp._M_time_formats(__times);
1680 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1685 // Two digit year. [tm_year]
1686 _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2,
1690 // Year [1900). [tm_year]
1691 _M_extract_num(__beg, __end, __mem, 0,
1692 numeric_limits<int>::max(), 4,
1695 __tm->tm_year = __mem - 1900;
1699 if (__ctype.is(ctype_base::upper, *__beg))
1702 _M_extract_name(__beg, __end, __tmp,
1703 __timepunct_cache<_CharT>::_S_timezones,
1706 // GMT requires special effort.
1707 if (__beg != __end && !__err && __tmp == 0
1708 && (*__beg == __ctype.widen('-')
1709 || *__beg == __ctype.widen('+')))
1711 _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
1713 _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
1718 __err |= ios_base::failbit;
1722 __err |= ios_base::failbit;
1727 // Verify format and input match, extract and discard.
1728 if (__c == __ctype.narrow(*__beg, 0))
1731 __err |= ios_base::failbit;
1736 template<typename _CharT, typename _InIter>
1738 time_get<_CharT, _InIter>::
1739 _M_extract_num(iter_type& __beg, iter_type& __end, int& __member,
1740 int __min, int __max, size_t __len,
1741 const ctype<_CharT>& __ctype,
1742 ios_base::iostate& __err) const
1746 bool __testvalid = true;
1747 for (; __beg != __end && __i < __len
1748 && __ctype.is(ctype_base::digit, *__beg); ++__beg, ++__i)
1749 __digits += __ctype.narrow(*__beg, 0);
1752 const int __value = std::atoi(__digits.c_str());
1753 if (__min <= __value && __value <= __max)
1756 __testvalid = false;
1759 __testvalid = false;
1761 __err |= ios_base::failbit;
1765 // All elements in __names are unique.
1766 template<typename _CharT, typename _InIter>
1768 time_get<_CharT, _InIter>::
1769 _M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
1770 const _CharT** __names, size_t __indexlen,
1771 ios_base::iostate& __err) const
1773 typedef char_traits<_CharT> __traits_type;
1774 int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)
1776 size_t __nmatches = 0;
1778 bool __testvalid = true;
1779 const char_type* __name;
1781 // Look for initial matches.
1784 const char_type __c = *__beg;
1785 for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
1786 if (__c == __names[__i1][0])
1787 __matches[__nmatches++] = __i1;
1790 while (__nmatches > 1)
1792 // Find smallest matching string.
1793 size_t __minlen = 10;
1794 for (size_t __i2 = 0; __i2 < __nmatches; ++__i2)
1795 __minlen = std::min(__minlen,
1796 __traits_type::length(__names[__matches[__i2]]));
1798 if (__pos < __minlen && __beg != __end)
1801 for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)
1803 __name = __names[__matches[__i3]];
1804 if (__name[__pos] != *__beg)
1805 __matches[__i3] = __matches[--__nmatches];
1812 if (__nmatches == 1)
1814 // Make sure found name is completely extracted.
1815 __name = __names[__matches[0]];
1816 const size_t __len = __traits_type::length(__name);
1817 while (__pos < __len && __beg != __end && __name[__pos] == *__beg)
1821 __member = __matches[0];
1823 __testvalid = false;
1826 __testvalid = false;
1828 __err |= ios_base::failbit;
1831 template<typename _CharT, typename _InIter>
1833 time_get<_CharT, _InIter>::
1834 do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
1835 ios_base::iostate& __err, tm* __tm) const
1838 const char* __cs = "%X";
1839 const locale __loc = __io.getloc();
1840 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1841 __ctype.widen(__cs, __cs + 3, __wcs);
1842 _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
1844 __err |= ios_base::eofbit;
1848 template<typename _CharT, typename _InIter>
1850 time_get<_CharT, _InIter>::
1851 do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
1852 ios_base::iostate& __err, tm* __tm) const
1855 const char* __cs = "%x";
1856 const locale __loc = __io.getloc();
1857 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1858 __ctype.widen(__cs, __cs + 3, __wcs);
1859 _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
1861 __err |= ios_base::eofbit;
1865 template<typename _CharT, typename _InIter>
1867 time_get<_CharT, _InIter>::
1868 do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
1869 ios_base::iostate& __err, tm* __tm) const
1871 typedef char_traits<_CharT> __traits_type;
1872 const locale __loc = __io.getloc();
1873 __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
1874 const char_type* __days[7];
1875 __tp._M_days_abbreviated(__days);
1877 _M_extract_name(__beg, __end, __tmpwday, __days, 7, __err);
1879 // Check to see if non-abbreviated name exists, and extract.
1880 // NB: Assumes both _M_days and _M_days_abbreviated organized in
1881 // exact same order, first to last, such that the resulting
1882 // __days array with the same index points to a day, and that
1883 // day's abbreviated form.
1884 // NB: Also assumes that an abbreviated name is a subset of the name.
1887 size_t __pos = __traits_type::length(__days[__tmpwday]);
1888 __tp._M_days(__days);
1889 const char_type* __name = __days[__tmpwday];
1890 if (__name[__pos] == *__beg)
1892 // Extract the rest of it.
1893 const size_t __len = __traits_type::length(__name);
1894 while (__pos < __len && __beg != __end
1895 && __name[__pos] == *__beg)
1898 __err |= ios_base::failbit;
1901 __tm->tm_wday = __tmpwday;
1904 __err |= ios_base::eofbit;
1908 template<typename _CharT, typename _InIter>
1910 time_get<_CharT, _InIter>::
1911 do_get_monthname(iter_type __beg, iter_type __end,
1912 ios_base& __io, ios_base::iostate& __err, tm* __tm) const
1914 typedef char_traits<_CharT> __traits_type;
1915 const locale __loc = __io.getloc();
1916 __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
1917 const char_type* __months[12];
1918 __tp._M_months_abbreviated(__months);
1920 _M_extract_name(__beg, __end, __tmpmon, __months, 12, __err);
1922 // Check to see if non-abbreviated name exists, and extract.
1923 // NB: Assumes both _M_months and _M_months_abbreviated organized in
1924 // exact same order, first to last, such that the resulting
1925 // __months array with the same index points to a month, and that
1926 // month's abbreviated form.
1927 // NB: Also assumes that an abbreviated name is a subset of the name.
1930 size_t __pos = __traits_type::length(__months[__tmpmon]);
1931 __tp._M_months(__months);
1932 const char_type* __name = __months[__tmpmon];
1933 if (__name[__pos] == *__beg)
1935 // Extract the rest of it.
1936 const size_t __len = __traits_type::length(__name);
1937 while (__pos < __len && __beg != __end
1938 && __name[__pos] == *__beg)
1941 __err |= ios_base::failbit;
1944 __tm->tm_mon = __tmpmon;
1948 __err |= ios_base::eofbit;
1952 template<typename _CharT, typename _InIter>
1954 time_get<_CharT, _InIter>::
1955 do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
1956 ios_base::iostate& __err, tm* __tm) const
1958 const locale __loc = __io.getloc();
1959 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1963 for (; __i < 4 && __beg != __end
1964 && __ctype.is(ctype_base::digit, *__beg); ++__beg, ++__i)
1965 __digits += __ctype.narrow(*__beg, 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)
1993 if (__ctype.narrow(*__beg, 0) != '%')
1998 else if (++__beg != __end)
2002 const char __c = __ctype.narrow(*__beg, 0);
2003 if (__c != 'E' && __c != 'O')
2005 else if (++__beg != __end)
2008 __format = __ctype.narrow(*__beg, 0);
2012 __s = this->do_put(__s, __io, __fill, __tm,
2020 template<typename _CharT, typename _OutIter>
2022 time_put<_CharT, _OutIter>::
2023 do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm,
2024 char __format, char __mod) const
2026 const locale __loc = __io.getloc();
2027 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
2028 __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
2030 // NB: This size is arbitrary. Should this be a data member,
2031 // initialized at construction?
2032 const size_t __maxlen = 64;
2033 char_type* __res = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen));
2035 // NB: In IEE 1003.1-200x, and perhaps other locale models, it
2036 // is possible that the format character will be longer than one
2037 // character. Possibilities include 'E' or 'O' followed by a
2038 // format character: if __mod is not the default argument, assume
2039 // it's a valid modifier.
2041 __fmt[0] = __ctype.widen('%');
2044 __fmt[1] = __format;
2045 __fmt[2] = char_type();
2050 __fmt[2] = __format;
2051 __fmt[3] = char_type();
2054 __tp._M_put(__res, __maxlen, __fmt, __tm);
2056 // Write resulting, fully-formatted string to output iterator.
2057 return std::__write(__s, __res, char_traits<char_type>::length(__res));
2061 // Generic version does nothing.
2062 template<typename _CharT>
2064 collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const
2067 // Generic version does nothing.
2068 template<typename _CharT>
2070 collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const
2073 template<typename _CharT>
2076 do_compare(const _CharT* __lo1, const _CharT* __hi1,
2077 const _CharT* __lo2, const _CharT* __hi2) const
2079 // strcoll assumes zero-terminated strings so we make a copy
2080 // and then put a zero at the end.
2081 const string_type __one(__lo1, __hi1);
2082 const string_type __two(__lo2, __hi2);
2084 const _CharT* __p = __one.c_str();
2085 const _CharT* __pend = __one.data() + __one.length();
2086 const _CharT* __q = __two.c_str();
2087 const _CharT* __qend = __two.data() + __two.length();
2089 // strcoll stops when it sees a nul character so we break
2090 // the strings into zero-terminated substrings and pass those
2094 const int __res = _M_compare(__p, __q);
2098 __p += char_traits<_CharT>::length(__p);
2099 __q += char_traits<_CharT>::length(__q);
2100 if (__p == __pend && __q == __qend)
2102 else if (__p == __pend)
2104 else if (__q == __qend)
2112 template<typename _CharT>
2113 typename collate<_CharT>::string_type
2115 do_transform(const _CharT* __lo, const _CharT* __hi) const
2117 // strxfrm assumes zero-terminated strings so we make a copy
2118 string_type __str(__lo, __hi);
2120 const _CharT* __p = __str.c_str();
2121 const _CharT* __pend = __str.data() + __str.length();
2123 size_t __len = (__hi - __lo) * 2;
2127 // strxfrm stops when it sees a nul character so we break
2128 // the string into zero-terminated substrings and pass those
2132 // First try a buffer perhaps big enough.
2134 static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
2135 size_t __res = _M_transform(__c, __p, __len);
2136 // If the buffer was not large enough, try again with the
2141 __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
2143 __res = _M_transform(__c, __p, __res + 1);
2146 __ret.append(__c, __res);
2147 __p += char_traits<_CharT>::length(__p);
2152 __ret.push_back(_CharT());
2156 template<typename _CharT>
2159 do_hash(const _CharT* __lo, const _CharT* __hi) const
2161 unsigned long __val = 0;
2162 for (; __lo < __hi; ++__lo)
2163 __val = *__lo + ((__val << 7) |
2164 (__val >> (numeric_limits<unsigned long>::digits - 7)));
2165 return static_cast<long>(__val);
2168 // Construct correctly padded string, as per 22.2.2.2.2
2170 // __newlen > __oldlen
2171 // __news is allocated for __newlen size
2172 // Used by both num_put and ostream inserters: if __num,
2173 // internal-adjusted objects are padded according to the rules below
2174 // concerning 0[xX] and +-, otherwise, exactly as right-adjusted
2177 // NB: Of the two parameters, _CharT can be deduced from the
2178 // function arguments. The other (_Traits) has to be explicitly specified.
2179 template<typename _CharT, typename _Traits>
2181 __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
2182 _CharT* __news, const _CharT* __olds,
2183 const streamsize __newlen,
2184 const streamsize __oldlen, const bool __num)
2186 const size_t __plen = static_cast<size_t>(__newlen - __oldlen);
2187 const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
2190 if (__adjust == ios_base::left)
2192 _Traits::copy(__news, const_cast<_CharT*>(__olds), __oldlen);
2193 _Traits::assign(__news + __oldlen, __plen, __fill);
2198 if (__adjust == ios_base::internal && __num)
2200 // Pad after the sign, if there is one.
2201 // Pad after 0[xX], if there is one.
2202 // Who came up with these rules, anyway? Jeeze.
2203 const locale& __loc = __io._M_getloc();
2204 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
2205 const _CharT __minus = __ctype.widen('-');
2206 const _CharT __plus = __ctype.widen('+');
2207 const bool __testsign = _Traits::eq(__olds[0], __minus)
2208 || _Traits::eq(__olds[0], __plus);
2210 const bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0])
2211 && (_Traits::eq(__ctype.widen('x'), __olds[1])
2212 || _Traits::eq(__ctype.widen('X'), __olds[1]));
2215 __news[0] = __olds[0];
2216 __news[1] = __olds[1];
2220 else if (__testsign)
2222 __news[0] = __olds[0];
2226 // else Padding first.
2228 _Traits::assign(__news, __plen, __fill);
2229 _Traits::copy(__news + __plen, const_cast<_CharT*>(__olds + __mod),
2233 template<typename _CharT>
2235 __verify_grouping(const basic_string<_CharT>& __grouping,
2236 const basic_string<_CharT>& __grouping_tmp)
2240 const size_t __len = __grouping.size();
2241 const size_t __n = __grouping_tmp.size();
2244 // Parsed number groupings have to match the
2245 // numpunct::grouping string exactly, starting at the
2246 // right-most point of the parsed sequence of elements ...
2247 while (__test && __i < __n - 1)
2248 for (__j = 0; __test && __j < __len && __i < __n - 1; ++__j, ++__i)
2249 __test = __grouping[__j] == __grouping_tmp[__n - __i - 1];
2250 // ... but the last parsed grouping can be <= numpunct
2252 __j == __len ? __j = 0 : __j;
2253 __test &= __grouping[__j] >= __grouping_tmp[__n - __i - 1];
2257 template<typename _CharT>
2259 __add_grouping(_CharT* __s, _CharT __sep,
2260 const char* __gbeg, const char* __gend,
2261 const _CharT* __first, const _CharT* __last)
2263 if (__last - __first > *__gbeg)
2265 const bool __bump = __gbeg + 1 != __gend;
2266 __s = std::__add_grouping(__s, __sep, __gbeg + __bump,
2267 __gend, __first, __last - *__gbeg);
2268 __first = __last - *__gbeg;
2272 *__s++ = *__first++;
2273 while (__first != __last);
2277 // Inhibit implicit instantiations for required instantiations,
2278 // which are defined via explicit instantiations elsewhere.
2279 // NB: This syntax is a GNU extension.
2280 #if _GLIBCXX_EXTERN_TEMPLATE
2281 extern template class moneypunct<char, false>;
2282 extern template class moneypunct<char, true>;
2283 extern template class moneypunct_byname<char, false>;
2284 extern template class moneypunct_byname<char, true>;
2285 extern template class money_get<char>;
2286 extern template class money_put<char>;
2287 extern template class numpunct<char>;
2288 extern template class numpunct_byname<char>;
2289 extern template class num_get<char>;
2290 extern template class num_put<char>;
2291 extern template class __timepunct<char>;
2292 extern template class time_put<char>;
2293 extern template class time_put_byname<char>;
2294 extern template class time_get<char>;
2295 extern template class time_get_byname<char>;
2296 extern template class messages<char>;
2297 extern template class messages_byname<char>;
2298 extern template class ctype_byname<char>;
2299 extern template class codecvt_byname<char, char, mbstate_t>;
2300 extern template class collate<char>;
2301 extern template class collate_byname<char>;
2304 const codecvt<char, char, mbstate_t>&
2305 use_facet<codecvt<char, char, mbstate_t> >(const locale&);
2308 const collate<char>&
2309 use_facet<collate<char> >(const locale&);
2312 const numpunct<char>&
2313 use_facet<numpunct<char> >(const locale&);
2316 const num_put<char>&
2317 use_facet<num_put<char> >(const locale&);
2320 const num_get<char>&
2321 use_facet<num_get<char> >(const locale&);
2324 const moneypunct<char, true>&
2325 use_facet<moneypunct<char, true> >(const locale&);
2328 const moneypunct<char, false>&
2329 use_facet<moneypunct<char, false> >(const locale&);
2332 const money_put<char>&
2333 use_facet<money_put<char> >(const locale&);
2336 const money_get<char>&
2337 use_facet<money_get<char> >(const locale&);
2340 const __timepunct<char>&
2341 use_facet<__timepunct<char> >(const locale&);
2344 const time_put<char>&
2345 use_facet<time_put<char> >(const locale&);
2348 const time_get<char>&
2349 use_facet<time_get<char> >(const locale&);
2352 const messages<char>&
2353 use_facet<messages<char> >(const locale&);
2357 has_facet<ctype<char> >(const locale&);
2361 has_facet<codecvt<char, char, mbstate_t> >(const locale&);
2365 has_facet<collate<char> >(const locale&);
2369 has_facet<numpunct<char> >(const locale&);
2373 has_facet<num_put<char> >(const locale&);
2377 has_facet<num_get<char> >(const locale&);
2381 has_facet<moneypunct<char> >(const locale&);
2385 has_facet<money_put<char> >(const locale&);
2389 has_facet<money_get<char> >(const locale&);
2393 has_facet<__timepunct<char> >(const locale&);
2397 has_facet<time_put<char> >(const locale&);
2401 has_facet<time_get<char> >(const locale&);
2405 has_facet<messages<char> >(const locale&);
2407 #ifdef _GLIBCXX_USE_WCHAR_T
2408 extern template class moneypunct<wchar_t, false>;
2409 extern template class moneypunct<wchar_t, true>;
2410 extern template class moneypunct_byname<wchar_t, false>;
2411 extern template class moneypunct_byname<wchar_t, true>;
2412 extern template class money_get<wchar_t>;
2413 extern template class money_put<wchar_t>;
2414 extern template class numpunct<wchar_t>;
2415 extern template class numpunct_byname<wchar_t>;
2416 extern template class num_get<wchar_t>;
2417 extern template class num_put<wchar_t>;
2418 extern template class __timepunct<wchar_t>;
2419 extern template class time_put<wchar_t>;
2420 extern template class time_put_byname<wchar_t>;
2421 extern template class time_get<wchar_t>;
2422 extern template class time_get_byname<wchar_t>;
2423 extern template class messages<wchar_t>;
2424 extern template class messages_byname<wchar_t>;
2425 extern template class ctype_byname<wchar_t>;
2426 extern template class codecvt_byname<wchar_t, char, mbstate_t>;
2427 extern template class collate<wchar_t>;
2428 extern template class collate_byname<wchar_t>;
2431 const codecvt<wchar_t, char, mbstate_t>&
2432 use_facet<codecvt<wchar_t, char, mbstate_t> >(locale const&);
2435 const collate<wchar_t>&
2436 use_facet<collate<wchar_t> >(const locale&);
2439 const numpunct<wchar_t>&
2440 use_facet<numpunct<wchar_t> >(const locale&);
2443 const num_put<wchar_t>&
2444 use_facet<num_put<wchar_t> >(const locale&);
2447 const num_get<wchar_t>&
2448 use_facet<num_get<wchar_t> >(const locale&);
2451 const moneypunct<wchar_t, true>&
2452 use_facet<moneypunct<wchar_t, true> >(const locale&);
2455 const moneypunct<wchar_t, false>&
2456 use_facet<moneypunct<wchar_t, false> >(const locale&);
2459 const money_put<wchar_t>&
2460 use_facet<money_put<wchar_t> >(const locale&);
2463 const money_get<wchar_t>&
2464 use_facet<money_get<wchar_t> >(const locale&);
2467 const __timepunct<wchar_t>&
2468 use_facet<__timepunct<wchar_t> >(const locale&);
2471 const time_put<wchar_t>&
2472 use_facet<time_put<wchar_t> >(const locale&);
2475 const time_get<wchar_t>&
2476 use_facet<time_get<wchar_t> >(const locale&);
2479 const messages<wchar_t>&
2480 use_facet<messages<wchar_t> >(const locale&);
2484 has_facet<ctype<wchar_t> >(const locale&);
2488 has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
2492 has_facet<collate<wchar_t> >(const locale&);
2496 has_facet<numpunct<wchar_t> >(const locale&);
2500 has_facet<num_put<wchar_t> >(const locale&);
2504 has_facet<num_get<wchar_t> >(const locale&);
2508 has_facet<moneypunct<wchar_t> >(const locale&);
2512 has_facet<money_put<wchar_t> >(const locale&);
2516 has_facet<money_get<wchar_t> >(const locale&);
2520 has_facet<__timepunct<wchar_t> >(const locale&);
2524 has_facet<time_put<wchar_t> >(const locale&);
2528 has_facet<time_get<wchar_t> >(const locale&);
2532 has_facet<messages<wchar_t> >(const locale&);