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,
180 // Try first for acceptable digit; record it if found.
181 __xtrc += _S_atoms_in[__p - __lit];
182 __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);
199 __err |= ios_base::failbit;
203 else if (__traits_type::eq(__c, __lc->_M_decimal_point)
206 // According to the standard, if no grouping chars are seen,
207 // no grouping check is applied. Therefore __found_grouping
208 // must be adjusted only if __dec comes after some __sep.
209 if (__found_grouping.size())
210 __found_grouping += static_cast<char>(__sep_pos);
215 else if ((__e = __traits_type::eq(__c, __lit[_S_ie])
216 || __traits_type::eq(__c, __lit[_S_iE]))
217 && __found_mantissa && !__found_sci)
219 // Scientific notation.
220 __xtrc += __e ? _S_atoms_in[_S_ie] : _S_atoms_in[_S_iE];
223 // Remove optional plus or minus sign, if they exist.
224 if (++__beg != __end)
226 const bool __plus = __traits_type::eq(*__beg, __lit[_S_iplus]);
227 if (__plus || __traits_type::eq(*__beg, __lit[_S_iminus]))
229 __xtrc += __plus ? _S_atoms_in[_S_iplus]
230 : _S_atoms_in[_S_iminus];
236 // Not a valid input item.
240 // Digit grouping is checked. If grouping and found_grouping don't
241 // match, then get very very upset, and set failbit.
242 if (__lc->_M_use_grouping && __found_grouping.size())
244 // Add the ending grouping if a decimal wasn't found.
246 __found_grouping += static_cast<char>(__sep_pos);
248 const string __grouping = __lc->_M_grouping;
249 if (!std::__verify_grouping(__grouping, __found_grouping))
250 __err |= ios_base::failbit;
256 __err |= ios_base::eofbit;
260 template<typename _CharT, typename _InIter>
262 num_get<_CharT, _InIter>::
263 _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
264 ios_base::iostate& __err, string& __xtrc, int& __base) const
266 typedef char_traits<_CharT> __traits_type;
267 typedef typename numpunct<_CharT>::__cache_type __cache_type;
268 __use_cache<__cache_type> __uc;
269 const locale& __loc = __io._M_getloc();
270 const __cache_type* __lc = __uc(__loc);
271 const _CharT* __lit = __lc->_M_atoms_in;
273 // NB: Iff __basefield == 0, this can change based on contents.
274 const ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
275 if (__basefield == ios_base::oct)
277 else if (__basefield == ios_base::hex)
282 // First check for sign.
285 const char_type __c = *__beg;
286 const bool __plus = __traits_type::eq(__c, __lit[_S_iplus]);
287 if (__plus || __traits_type::eq(__c, __lit[_S_iminus]))
289 __xtrc += __plus ? _S_atoms_in[_S_iplus]
290 : _S_atoms_in[_S_iminus];
295 // Next, look for leading zeros and check required digits for base formats.
296 if (__builtin_expect(__base == 10, true))
298 // Look for a zero...
299 if (__beg != __end && __traits_type::eq(*__beg, __lit[_S_izero]))
301 __xtrc += _S_atoms_in[_S_izero];
303 // ... and skip the additional ones.
304 for (; __beg != __end
305 && __traits_type::eq(*__beg, __lit[_S_izero]); ++__beg);
307 // Check required digits.
308 if (__beg != __end && __basefield == 0)
310 const bool __x = __traits_type::eq(*__beg, __lit[_S_ix]);
311 if (__x || __traits_type::eq(*__beg, __lit[_S_iX]))
313 __xtrc += __x ? _S_atoms_in[_S_ix]
314 : _S_atoms_in[_S_iX];
323 else if (__base == 16)
325 if (__beg != __end && __traits_type::eq(*__beg, __lit[_S_izero]))
327 __xtrc += _S_atoms_in[_S_izero];
329 if (++__beg != __end)
331 const bool __x = __traits_type::eq(*__beg, __lit[_S_ix]);
332 if (__x || __traits_type::eq(*__beg, __lit[_S_iX]))
334 __xtrc += __x ? _S_atoms_in[_S_ix]
335 : _S_atoms_in[_S_iX];
342 // At this point, base is determined. If not hex, only allow
343 // base digits as valid input.
344 const size_t __len = __base == 16 ? _S_iend : __base;
347 string __found_grouping;
349 for (; __beg != __end; ++__beg)
351 const char_type __c = *__beg;
352 const char_type* __p = __traits_type::find(__lit + _S_izero,
356 // Try first for acceptable digit; record it if found.
357 __xtrc += _S_atoms_in[__p - __lit];
360 else if (__traits_type::eq(__c, __lc->_M_thousands_sep)
361 && __lc->_M_use_grouping)
363 // NB: Thousands separator at the beginning of a string
364 // is a no-no, as is two consecutive thousands separators.
367 __found_grouping += static_cast<char>(__sep_pos);
372 __err |= ios_base::failbit;
377 // Not a valid input item.
381 // Digit grouping is checked. If grouping and found_grouping don't
382 // match, then get very very upset, and set failbit.
383 if (__lc->_M_use_grouping && __found_grouping.size())
385 // Add the ending grouping.
386 __found_grouping += static_cast<char>(__sep_pos);
388 const string __grouping = __lc->_M_grouping;
389 if (!std::__verify_grouping(__grouping, __found_grouping))
390 __err |= ios_base::failbit;
396 __err |= ios_base::eofbit;
400 // _GLIBCXX_RESOLVE_LIB_DEFECTS
401 // 17. Bad bool parsing
402 template<typename _CharT, typename _InIter>
404 num_get<_CharT, _InIter>::
405 do_get(iter_type __beg, iter_type __end, ios_base& __io,
406 ios_base::iostate& __err, bool& __v) const
408 if (!(__io.flags() & ios_base::boolalpha))
410 // Parse bool values as unsigned long.
411 // NB: We can't just call do_get(long) here, as it might
412 // refer to a derived class.
415 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
418 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
419 _S_get_c_locale(), __base);
420 if (!(__err & ios_base::failbit) && __ul <= 1)
423 __err |= ios_base::failbit;
427 // Parse bool values as alphanumeric.
428 typedef char_traits<_CharT> __traits_type;
429 typedef typename numpunct<_CharT>::__cache_type __cache_type;
430 __use_cache<__cache_type> __uc;
431 const locale& __loc = __io._M_getloc();
432 const __cache_type* __lc = __uc(__loc);
433 const size_t __tn = __traits_type::length(__lc->_M_truename) - 1;
434 const size_t __fn = __traits_type::length(__lc->_M_falsename) - 1;
436 bool __testf = false;
437 bool __testt = false;
438 for (size_t __n = 0; __beg != __end; ++__n)
440 const char_type __c = *__beg;
444 __testf = __traits_type::eq(__c, __lc->_M_falsename[__n]);
447 __testt = __traits_type::eq(__c, __lc->_M_truename[__n]);
449 if (!(__testf || __testt))
451 __err |= ios_base::failbit;
454 else if (__testf && __n == __fn)
459 else if (__testt && __n == __tn)
466 __err |= ios_base::eofbit;
471 template<typename _CharT, typename _InIter>
473 num_get<_CharT, _InIter>::
474 do_get(iter_type __beg, iter_type __end, ios_base& __io,
475 ios_base::iostate& __err, long& __v) const
479 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
480 std::__convert_to_v(__xtrc.c_str(), __v, __err,
481 _S_get_c_locale(), __base);
485 template<typename _CharT, typename _InIter>
487 num_get<_CharT, _InIter>::
488 do_get(iter_type __beg, iter_type __end, ios_base& __io,
489 ios_base::iostate& __err, unsigned short& __v) const
493 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
495 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
496 _S_get_c_locale(), __base);
497 if (!(__err & ios_base::failbit)
498 && __ul <= numeric_limits<unsigned short>::max())
499 __v = static_cast<unsigned short>(__ul);
501 __err |= ios_base::failbit;
505 template<typename _CharT, typename _InIter>
507 num_get<_CharT, _InIter>::
508 do_get(iter_type __beg, iter_type __end, ios_base& __io,
509 ios_base::iostate& __err, unsigned int& __v) const
513 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
515 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
516 _S_get_c_locale(), __base);
517 if (!(__err & ios_base::failbit)
518 && __ul <= numeric_limits<unsigned int>::max())
519 __v = static_cast<unsigned int>(__ul);
521 __err |= ios_base::failbit;
525 template<typename _CharT, typename _InIter>
527 num_get<_CharT, _InIter>::
528 do_get(iter_type __beg, iter_type __end, ios_base& __io,
529 ios_base::iostate& __err, unsigned long& __v) const
533 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
534 std::__convert_to_v(__xtrc.c_str(), __v, __err,
535 _S_get_c_locale(), __base);
539 #ifdef _GLIBCXX_USE_LONG_LONG
540 template<typename _CharT, typename _InIter>
542 num_get<_CharT, _InIter>::
543 do_get(iter_type __beg, iter_type __end, ios_base& __io,
544 ios_base::iostate& __err, long long& __v) const
548 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
549 std::__convert_to_v(__xtrc.c_str(), __v, __err,
550 _S_get_c_locale(), __base);
554 template<typename _CharT, typename _InIter>
556 num_get<_CharT, _InIter>::
557 do_get(iter_type __beg, iter_type __end, ios_base& __io,
558 ios_base::iostate& __err, unsigned long long& __v) const
562 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
563 std::__convert_to_v(__xtrc.c_str(), __v, __err,
564 _S_get_c_locale(), __base);
569 template<typename _CharT, typename _InIter>
571 num_get<_CharT, _InIter>::
572 do_get(iter_type __beg, iter_type __end, ios_base& __io,
573 ios_base::iostate& __err, float& __v) const
577 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
578 std::__convert_to_v(__xtrc.c_str(), __v, __err,
583 template<typename _CharT, typename _InIter>
585 num_get<_CharT, _InIter>::
586 do_get(iter_type __beg, iter_type __end, ios_base& __io,
587 ios_base::iostate& __err, double& __v) const
591 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
592 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
596 template<typename _CharT, typename _InIter>
598 num_get<_CharT, _InIter>::
599 do_get(iter_type __beg, iter_type __end, ios_base& __io,
600 ios_base::iostate& __err, long double& __v) const
604 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
605 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
609 template<typename _CharT, typename _InIter>
611 num_get<_CharT, _InIter>::
612 do_get(iter_type __beg, iter_type __end, ios_base& __io,
613 ios_base::iostate& __err, void*& __v) const
615 // Prepare for hex formatted input.
616 typedef ios_base::fmtflags fmtflags;
617 const fmtflags __fmt = __io.flags();
618 const fmtflags __fmtmask = ~(ios_base::showpos | ios_base::basefield
619 | ios_base::uppercase | ios_base::internal);
620 __io.flags(__fmt & __fmtmask | (ios_base::hex | ios_base::showbase));
624 __beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
626 // Reset from hex formatted input.
630 std::__convert_to_v(__xtrc.c_str(), __ul, __err,
631 _S_get_c_locale(), __base);
632 if (!(__err & ios_base::failbit))
633 __v = reinterpret_cast<void*>(__ul);
635 __err |= ios_base::failbit;
639 // For use by integer and floating-point types after they have been
640 // converted into a char_type string.
641 template<typename _CharT, typename _OutIter>
643 num_put<_CharT, _OutIter>::
644 _M_pad(_CharT __fill, streamsize __w, ios_base& __io,
645 _CharT* __new, const _CharT* __cs, int& __len) const
647 // [22.2.2.2.2] Stage 3.
648 // If necessary, pad.
649 __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, __cs,
651 __len = static_cast<int>(__w);
654 // Forwarding functions to peel signed from unsigned integer types.
655 template<typename _CharT>
657 __int_to_char(_CharT* __bufend, long __v, const _CharT* __lit,
658 ios_base::fmtflags __flags)
660 unsigned long __ul = static_cast<unsigned long>(__v);
667 return __int_to_char(__bufend, __ul, __lit, __flags, __neg);
670 template<typename _CharT>
672 __int_to_char(_CharT* __bufend, unsigned long __v, const _CharT* __lit,
673 ios_base::fmtflags __flags)
674 { return __int_to_char(__bufend, __v, __lit, __flags, false); }
676 #ifdef _GLIBCXX_USE_LONG_LONG
677 template<typename _CharT>
679 __int_to_char(_CharT* __bufend, long long __v, const _CharT* __lit,
680 ios_base::fmtflags __flags)
682 unsigned long long __ull = static_cast<unsigned long long>(__v);
689 return __int_to_char(__bufend, __ull, __lit, __flags, __neg);
692 template<typename _CharT>
694 __int_to_char(_CharT* __bufend, unsigned long long __v, const _CharT* __lit,
695 ios_base::fmtflags __flags)
696 { return __int_to_char(__bufend, __v, __lit, __flags, false); }
699 template<typename _CharT, typename _ValueT>
701 __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit,
702 ios_base::fmtflags __flags, bool __neg)
704 // Don't write base if already 0.
705 const bool __showbase = (__flags & ios_base::showbase) && __v;
706 const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
707 _CharT* __buf = __bufend - 1;
709 if (__builtin_expect(__basefield != ios_base::oct &&
710 __basefield != ios_base::hex, true))
715 *__buf-- = __lit[(__v % 10) + __num_base::_S_odigits];
720 *__buf-- = __lit[__num_base::_S_ominus];
721 else if (__flags & ios_base::showpos)
722 *__buf-- = __lit[__num_base::_S_oplus];
724 else if (__basefield == ios_base::oct)
729 *__buf-- = __lit[(__v & 0x7) + __num_base::_S_odigits];
734 *__buf-- = __lit[__num_base::_S_odigits];
739 const bool __uppercase = __flags & ios_base::uppercase;
740 const int __case_offset = __uppercase ? __num_base::_S_oudigits
741 : __num_base::_S_odigits;
744 *__buf-- = __lit[(__v & 0xf) + __case_offset];
751 *__buf-- = __lit[__num_base::_S_ox + __uppercase];
753 *__buf-- = __lit[__num_base::_S_odigits];
756 return __bufend - __buf - 1;
759 template<typename _CharT, typename _OutIter>
761 num_put<_CharT, _OutIter>::
762 _M_group_int(const string& __grouping, _CharT __sep, ios_base& __io,
763 _CharT* __new, _CharT* __cs, int& __len) const
765 // By itself __add_grouping cannot deal correctly with __cs when
766 // ios::showbase is set and ios_base::oct || ios_base::hex.
767 // Therefore we take care "by hand" of the initial 0, 0x or 0X.
768 // However, remember that the latter do not occur if the number
769 // printed is '0' (__len == 1).
770 streamsize __off = 0;
771 const ios_base::fmtflags __basefield = __io.flags()
772 & ios_base::basefield;
773 if ((__io.flags() & ios_base::showbase) && __len > 1)
774 if (__basefield == ios_base::oct)
779 else if (__basefield == ios_base::hex)
786 __p = std::__add_grouping(__new + __off, __sep, __grouping.data(),
787 __grouping.data() + __grouping.size(),
788 __cs + __off, __cs + __len);
792 template<typename _CharT, typename _OutIter>
793 template<typename _ValueT>
795 num_put<_CharT, _OutIter>::
796 _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
799 typedef typename numpunct<_CharT>::__cache_type __cache_type;
800 __use_cache<__cache_type> __uc;
801 const locale& __loc = __io._M_getloc();
802 const __cache_type* __lc = __uc(__loc);
803 const _CharT* __lit = __lc->_M_atoms_out;
805 // Long enough to hold hex, dec, and octal representations.
806 const int __ilen = 4 * sizeof(_ValueT);
807 _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
810 // [22.2.2.2.2] Stage 1, numeric conversion to character.
811 // Result is returned right-justified in the buffer.
813 __len = __int_to_char(__cs + __ilen, __v, __lit, __io.flags());
814 __cs += __ilen - __len;
816 // Add grouping, if necessary.
817 if (__lc->_M_use_grouping)
819 // Grouping can add (almost) as many separators as the
820 // number of digits, but no more.
821 _CharT* __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
823 _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 _CharT* __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.
966 if (__lc->_M_use_grouping)
968 // Grouping can add (almost) as many separators as the
969 // number of digits, but no more.
970 _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
972 _M_group_float(__lc->_M_grouping, __lc->_M_thousands_sep, __p,
978 const streamsize __w = __io.width();
979 if (__w > static_cast<streamsize>(__len))
981 _CharT* __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
983 _M_pad(__fill, __w, __io, __ws3, __ws, __len);
988 // [22.2.2.2.2] Stage 4.
989 // Write resulting, fully-formatted string to output iterator.
990 return std::__write(__s, __ws, __len);
993 template<typename _CharT, typename _OutIter>
995 num_put<_CharT, _OutIter>::
996 do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
998 const ios_base::fmtflags __flags = __io.flags();
999 if ((__flags & ios_base::boolalpha) == 0)
1001 unsigned long __uv = __v;
1002 __s = _M_insert_int(__s, __io, __fill, __uv);
1006 typedef typename numpunct<_CharT>::__cache_type __cache_type;
1007 __use_cache<__cache_type> __uc;
1008 const locale& __loc = __io._M_getloc();
1009 const __cache_type* __lc = __uc(__loc);
1011 const _CharT* __name;
1012 __name = __v ? __lc->_M_truename : __lc->_M_falsename;
1013 int __len = char_traits<_CharT>::length(__name);
1016 const streamsize __w = __io.width();
1017 if (__w > static_cast<streamsize>(__len))
1019 __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1021 _M_pad(__fill, __w, __io, __cs, __name, __len);
1025 __s = std::__write(__s, __name, __len);
1030 template<typename _CharT, typename _OutIter>
1032 num_put<_CharT, _OutIter>::
1033 do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
1034 { return _M_insert_int(__s, __io, __fill, __v); }
1036 template<typename _CharT, typename _OutIter>
1038 num_put<_CharT, _OutIter>::
1039 do_put(iter_type __s, ios_base& __io, char_type __fill,
1040 unsigned long __v) const
1041 { return _M_insert_int(__s, __io, __fill, __v); }
1043 #ifdef _GLIBCXX_USE_LONG_LONG
1044 template<typename _CharT, typename _OutIter>
1046 num_put<_CharT, _OutIter>::
1047 do_put(iter_type __s, ios_base& __b, char_type __fill, long long __v) const
1048 { return _M_insert_int(__s, __b, __fill, __v); }
1050 template<typename _CharT, typename _OutIter>
1052 num_put<_CharT, _OutIter>::
1053 do_put(iter_type __s, ios_base& __io, char_type __fill,
1054 unsigned long long __v) const
1055 { return _M_insert_int(__s, __io, __fill, __v); }
1058 template<typename _CharT, typename _OutIter>
1060 num_put<_CharT, _OutIter>::
1061 do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
1062 { return _M_insert_float(__s, __io, __fill, char(), __v); }
1064 template<typename _CharT, typename _OutIter>
1066 num_put<_CharT, _OutIter>::
1067 do_put(iter_type __s, ios_base& __io, char_type __fill,
1068 long double __v) const
1069 { return _M_insert_float(__s, __io, __fill, 'L', __v); }
1071 template<typename _CharT, typename _OutIter>
1073 num_put<_CharT, _OutIter>::
1074 do_put(iter_type __s, ios_base& __io, char_type __fill,
1075 const void* __v) const
1077 const ios_base::fmtflags __flags = __io.flags();
1078 const ios_base::fmtflags __fmt = ~(ios_base::showpos | ios_base::basefield
1079 | ios_base::uppercase | ios_base::internal);
1080 __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
1083 __s = _M_insert_int(__s, __io, __fill,
1084 reinterpret_cast<unsigned long>(__v));
1085 __io.flags(__flags);
1089 __io.flags(__flags);
1090 __throw_exception_again;
1096 template<typename _CharT, typename _InIter>
1098 money_get<_CharT, _InIter>::
1099 do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
1100 ios_base::iostate& __err, long double& __units) const
1103 __beg = this->do_get(__beg, __end, __intl, __io, __err, __str);
1105 const int __cs_size = __str.size() + 1;
1106 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1107 const locale __loc = __io.getloc();
1108 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1109 const _CharT* __wcs = __str.c_str();
1110 __ctype.narrow(__wcs, __wcs + __cs_size, char(), __cs);
1111 std::__convert_to_v(__cs, __units, __err, _S_get_c_locale());
1115 template<typename _CharT, typename _InIter>
1117 money_get<_CharT, _InIter>::
1118 do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
1119 ios_base::iostate& __err, string_type& __units) const
1121 // These contortions are quite unfortunate.
1122 typedef moneypunct<_CharT, true> __money_true;
1123 typedef moneypunct<_CharT, false> __money_false;
1124 typedef money_base::part part;
1125 typedef typename string_type::size_type size_type;
1127 const locale __loc = __io.getloc();
1128 const __money_true& __mpt = use_facet<__money_true>(__loc);
1129 const __money_false& __mpf = use_facet<__money_false>(__loc);
1130 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1132 const money_base::pattern __p = __intl ? __mpt.neg_format()
1133 : __mpf.neg_format();
1135 const string_type __pos_sign = __intl ? __mpt.positive_sign()
1136 : __mpf.positive_sign();
1137 const string_type __neg_sign = __intl ? __mpt.negative_sign()
1138 : __mpf.negative_sign();
1139 const char_type __d = __intl ? __mpt.decimal_point()
1140 : __mpf.decimal_point();
1141 const char_type __sep = __intl ? __mpt.thousands_sep()
1142 : __mpf.thousands_sep();
1144 const string __grouping = __intl ? __mpt.grouping() : __mpf.grouping();
1146 // Set to deduced positive or negative sign, depending.
1148 // String of grouping info from thousands_sep plucked from __units.
1149 string __grouping_tmp;
1150 // Marker for thousands_sep position.
1152 // If input iterator is in a valid state.
1153 bool __testvalid = true;
1154 // Flag marking when a decimal point is found.
1155 bool __testdecfound = false;
1157 // The tentative returned string is stored here.
1158 string_type __tmp_units;
1160 for (int __i = 0; __beg != __end && __i < 4 && __testvalid; ++__i)
1163 const part __which = static_cast<part>(__p.field[__i]);
1166 case money_base::symbol:
1167 if (__io.flags() & ios_base::showbase
1168 || __i < 2 || __sign.size() > 1
1169 || ((static_cast<part>(__p.field[3]) != money_base::none)
1172 // According to 22.2.6.1.2.2, symbol is required
1173 // if (__io.flags() & ios_base::showbase),
1174 // otherwise is optional and consumed only if
1175 // other characters are needed to complete the
1177 const string_type __symbol = __intl ? __mpt.curr_symbol()
1178 : __mpf.curr_symbol();
1179 const size_type __len = __symbol.size();
1181 for (; __beg != __end && __j < __len
1182 && *__beg == __symbol[__j]; ++__beg, ++__j);
1183 // When (__io.flags() & ios_base::showbase)
1184 // symbol is required.
1185 if (__j != __len && (__io.flags() & ios_base::showbase))
1186 __testvalid = false;
1189 case money_base::sign:
1190 // Sign might not exist, or be more than one character long.
1191 if (__pos_sign.size() && *__beg == __pos_sign[0])
1193 __sign = __pos_sign;
1196 else if (__neg_sign.size() && *__beg == __neg_sign[0])
1198 __sign = __neg_sign;
1201 else if (__pos_sign.size() && __neg_sign.size())
1203 // Sign is mandatory.
1204 __testvalid = false;
1207 case money_base::value:
1208 // Extract digits, remove and stash away the
1209 // grouping of found thousands separators.
1210 for (; __beg != __end; ++__beg)
1211 if (__ctype.is(ctype_base::digit, __c = *__beg))
1216 else if (__c == __d && !__testdecfound)
1218 __grouping_tmp += static_cast<char>(__sep_pos);
1220 __testdecfound = true;
1222 else if (__c == __sep)
1224 if (__grouping.size())
1226 // Mark position for later analysis.
1227 __grouping_tmp += static_cast<char>(__sep_pos);
1232 __testvalid = false;
1239 case money_base::space:
1240 case money_base::none:
1241 // Only if not at the end of the pattern.
1243 for (; __beg != __end
1244 && __ctype.is(ctype_base::space, *__beg); ++__beg);
1249 // Need to get the rest of the sign characters, if they exist.
1250 if (__sign.size() > 1)
1252 const size_type __len = __sign.size();
1254 for (; __beg != __end && __i < __len; ++__i)
1255 for (; __beg != __end
1256 && *__beg != __sign[__i]; ++__beg);
1259 __testvalid = false;
1262 if (__testvalid && __tmp_units.size())
1264 const char_type __zero = __ctype.widen('0');
1266 // Strip leading zeros.
1267 if (__tmp_units.size() > 1)
1269 const size_type __first = __tmp_units.find_first_not_of(__zero);
1270 const bool __only_zeros = __first == string_type::npos;
1272 __tmp_units.erase(0, __only_zeros ? __tmp_units.size() - 1
1277 if (__sign.size() && __sign == __neg_sign
1278 && __tmp_units[0] != __zero)
1279 __tmp_units.insert(__tmp_units.begin(), __ctype.widen('-'));
1281 // Test for grouping fidelity.
1282 if (__grouping.size() && __grouping_tmp.size())
1284 if (!std::__verify_grouping(__grouping, __grouping_tmp))
1285 __testvalid = false;
1288 // Iff not enough digits were supplied after the decimal-point.
1291 const int __frac = __intl ? __mpt.frac_digits()
1292 : __mpf.frac_digits();
1293 if (__frac > 0 && __sep_pos != __frac)
1294 __testvalid = false;
1298 __testvalid = false;
1300 // Iff no more characters are available.
1302 __err |= ios_base::eofbit;
1304 // Iff valid sequence is not recognized.
1306 __err |= ios_base::failbit;
1308 // Use the "swap trick" to copy __tmp_units into __units.
1309 __tmp_units.swap(__units);
1314 template<typename _CharT, typename _OutIter>
1316 money_put<_CharT, _OutIter>::
1317 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1318 long double __units) const
1320 const locale __loc = __io.getloc();
1321 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1322 #ifdef _GLIBCXX_USE_C99
1323 // First try a buffer perhaps big enough.
1325 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1326 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1327 // 328. Bad sprintf format modifier in money_put<>::do_put()
1328 int __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
1330 // If the buffer was not large enough, try again with the correct size.
1331 if (__len >= __cs_size)
1333 __cs_size = __len + 1;
1334 __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1335 __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
1339 // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
1340 const int __cs_size = numeric_limits<long double>::max_exponent10 + 3;
1341 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1342 int __len = std::__convert_from_v(__cs, 0, "%.0Lf", __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 const __timepunct<_CharT>& __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];
1544 if (__c == 'E' || __c == 'O')
1545 __c = __format[++__i];
1551 // Abbreviated weekday name [tm_wday]
1552 const char_type* __days1[7];
1553 __tp._M_days_abbreviated(__days1);
1554 _M_extract_name(__beg, __end, __tm->tm_wday, __days1, 7,
1558 // Weekday name [tm_wday].
1559 const char_type* __days2[7];
1560 __tp._M_days(__days2);
1561 _M_extract_name(__beg, __end, __tm->tm_wday, __days2, 7,
1566 // Abbreviated month name [tm_mon]
1567 const char_type* __months1[12];
1568 __tp._M_months_abbreviated(__months1);
1569 _M_extract_name(__beg, __end, __tm->tm_mon, __months1, 12,
1573 // Month name [tm_mon].
1574 const char_type* __months2[12];
1575 __tp._M_months(__months2);
1576 _M_extract_name(__beg, __end, __tm->tm_mon, __months2, 12,
1580 // Default time and date representation.
1581 const char_type* __dt[2];
1582 __tp._M_date_time_formats(__dt);
1583 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1587 // Day [01, 31]. [tm_mday]
1588 _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
1592 // Day [1, 31], with single digits preceded by
1594 if (__ctype.is(ctype_base::space, *__beg))
1595 _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9, 1,
1598 _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31, 2,
1602 // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
1604 __ctype.widen(__cs, __cs + 9, __wcs);
1605 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1609 // Hour [00, 23]. [tm_hour]
1610 _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
1614 // Hour [01, 12]. [tm_hour]
1615 _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
1619 // Month [01, 12]. [tm_mon]
1620 _M_extract_num(__beg, __end, __mem, 1, 12, 2, __ctype,
1623 __tm->tm_mon = __mem - 1;
1626 // Minute [00, 59]. [tm_min]
1627 _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
1631 if (__ctype.narrow(*__beg, 0) == '\n')
1634 __err |= ios_base::failbit;
1637 // Equivalent to (%H:%M).
1639 __ctype.widen(__cs, __cs + 6, __wcs);
1640 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1645 _M_extract_num(__beg, __end, __tm->tm_sec, 0, 59, 2,
1649 if (__ctype.narrow(*__beg, 0) == '\t')
1652 __err |= ios_base::failbit;
1655 // Equivalent to (%H:%M:%S).
1657 __ctype.widen(__cs, __cs + 9, __wcs);
1658 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1663 const char_type* __dates[2];
1664 __tp._M_date_formats(__dates);
1665 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1670 const char_type* __times[2];
1671 __tp._M_time_formats(__times);
1672 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1677 // Two digit year. [tm_year]
1678 _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2,
1682 // Year [1900). [tm_year]
1683 _M_extract_num(__beg, __end, __mem, 0,
1684 numeric_limits<int>::max(), 4,
1687 __tm->tm_year = __mem - 1900;
1691 if (__ctype.is(ctype_base::upper, *__beg))
1694 _M_extract_name(__beg, __end, __tmp,
1695 __timepunct_cache<_CharT>::_S_timezones,
1696 14, __ctype, __err);
1698 // GMT requires special effort.
1699 if (__beg != __end && !__err && __tmp == 0
1700 && (*__beg == __ctype.widen('-')
1701 || *__beg == __ctype.widen('+')))
1703 _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
1705 _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
1710 __err |= ios_base::failbit;
1714 __err |= ios_base::failbit;
1719 // Verify format and input match, extract and discard.
1720 if (__c == __ctype.narrow(*__beg, 0))
1723 __err |= ios_base::failbit;
1728 template<typename _CharT, typename _InIter>
1730 time_get<_CharT, _InIter>::
1731 _M_extract_num(iter_type& __beg, iter_type& __end, int& __member,
1732 int __min, int __max, size_t __len,
1733 const ctype<_CharT>& __ctype,
1734 ios_base::iostate& __err) const
1738 bool __testvalid = true;
1739 for (; __beg != __end && __i < __len
1740 && __ctype.is(ctype_base::digit, *__beg); ++__beg, ++__i)
1741 __digits += __ctype.narrow(*__beg, 0);
1744 const int __value = std::atoi(__digits.c_str());
1745 if (__min <= __value && __value <= __max)
1748 __testvalid = false;
1751 __testvalid = false;
1753 __err |= ios_base::failbit;
1757 // All elements in __names are unique.
1758 template<typename _CharT, typename _InIter>
1760 time_get<_CharT, _InIter>::
1761 _M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
1762 const _CharT** __names, size_t __indexlen,
1763 const ctype<_CharT>& __ctype,
1764 ios_base::iostate& __err) const
1766 typedef char_traits<_CharT> __traits_type;
1767 int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)
1769 size_t __nmatches = 0;
1771 bool __testvalid = true;
1772 const char_type* __name;
1774 // Look for initial matches.
1775 // NB: Some of the locale data is in the form of all lowercase
1776 // names, and some is in the form of initially-capitalized
1777 // names. Look for both.
1780 const char_type __c = *__beg;
1781 for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
1782 if (__c == __names[__i1][0]
1783 || __c == __ctype.toupper(__names[__i1][0]))
1784 __matches[__nmatches++] = __i1;
1787 while (__nmatches > 1)
1789 // Find smallest matching string.
1790 size_t __minlen = 10;
1791 for (size_t __i2 = 0; __i2 < __nmatches; ++__i2)
1792 __minlen = std::min(__minlen,
1793 __traits_type::length(__names[__matches[__i2]]));
1795 if (__pos < __minlen && __beg != __end)
1798 for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)
1800 __name = __names[__matches[__i3]];
1801 if (__name[__pos] != *__beg)
1802 __matches[__i3] = __matches[--__nmatches];
1809 if (__nmatches == 1)
1811 // If there was only one match, the first compare is redundant.
1818 // Make sure found name is completely extracted.
1819 __name = __names[__matches[0]];
1820 const size_t __len = __traits_type::length(__name);
1821 while (__pos < __len && __beg != __end && __name[__pos] == *__beg)
1825 __member = __matches[0];
1827 __testvalid = false;
1830 __testvalid = false;
1832 __err |= ios_base::failbit;
1835 template<typename _CharT, typename _InIter>
1837 time_get<_CharT, _InIter>::
1838 do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
1839 ios_base::iostate& __err, tm* __tm) const
1842 const char* __cs = "%X";
1843 const locale __loc = __io.getloc();
1844 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1845 __ctype.widen(__cs, __cs + 3, __wcs);
1846 _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
1848 __err |= ios_base::eofbit;
1852 template<typename _CharT, typename _InIter>
1854 time_get<_CharT, _InIter>::
1855 do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
1856 ios_base::iostate& __err, tm* __tm) const
1859 const char* __cs = "%x";
1860 const locale __loc = __io.getloc();
1861 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1862 __ctype.widen(__cs, __cs + 3, __wcs);
1863 _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
1865 __err |= ios_base::eofbit;
1869 template<typename _CharT, typename _InIter>
1871 time_get<_CharT, _InIter>::
1872 do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
1873 ios_base::iostate& __err, tm* __tm) const
1875 typedef char_traits<_CharT> __traits_type;
1876 const locale __loc = __io.getloc();
1877 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1878 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1879 const char_type* __days[7];
1880 __tp._M_days_abbreviated(__days);
1882 _M_extract_name(__beg, __end, __tmpwday, __days, 7, __ctype, __err);
1884 // Check to see if non-abbreviated name exists, and extract.
1885 // NB: Assumes both _M_days and _M_days_abbreviated organized in
1886 // exact same order, first to last, such that the resulting
1887 // __days array with the same index points to a day, and that
1888 // day's abbreviated form.
1889 // NB: Also assumes that an abbreviated name is a subset of the name.
1892 size_t __pos = __traits_type::length(__days[__tmpwday]);
1893 __tp._M_days(__days);
1894 const char_type* __name = __days[__tmpwday];
1895 if (__name[__pos] == *__beg)
1897 // Extract the rest of it.
1898 const size_t __len = __traits_type::length(__name);
1899 while (__pos < __len && __beg != __end
1900 && __name[__pos] == *__beg)
1903 __err |= ios_base::failbit;
1906 __tm->tm_wday = __tmpwday;
1909 __err |= ios_base::eofbit;
1913 template<typename _CharT, typename _InIter>
1915 time_get<_CharT, _InIter>::
1916 do_get_monthname(iter_type __beg, iter_type __end,
1917 ios_base& __io, ios_base::iostate& __err, tm* __tm) const
1919 typedef char_traits<_CharT> __traits_type;
1920 const locale __loc = __io.getloc();
1921 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1922 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1923 const char_type* __months[12];
1924 __tp._M_months_abbreviated(__months);
1926 _M_extract_name(__beg, __end, __tmpmon, __months, 12, __ctype, __err);
1928 // Check to see if non-abbreviated name exists, and extract.
1929 // NB: Assumes both _M_months and _M_months_abbreviated organized in
1930 // exact same order, first to last, such that the resulting
1931 // __months array with the same index points to a month, and that
1932 // month's abbreviated form.
1933 // NB: Also assumes that an abbreviated name is a subset of the name.
1936 size_t __pos = __traits_type::length(__months[__tmpmon]);
1937 __tp._M_months(__months);
1938 const char_type* __name = __months[__tmpmon];
1939 if (__name[__pos] == *__beg)
1941 // Extract the rest of it.
1942 const size_t __len = __traits_type::length(__name);
1943 while (__pos < __len && __beg != __end
1944 && __name[__pos] == *__beg)
1947 __err |= ios_base::failbit;
1950 __tm->tm_mon = __tmpmon;
1954 __err |= ios_base::eofbit;
1958 template<typename _CharT, typename _InIter>
1960 time_get<_CharT, _InIter>::
1961 do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
1962 ios_base::iostate& __err, tm* __tm) const
1964 const locale __loc = __io.getloc();
1965 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1969 for (; __i < 4 && __beg != __end
1970 && __ctype.is(ctype_base::digit, *__beg); ++__beg, ++__i)
1971 __digits += __ctype.narrow(*__beg, 0);
1972 if (__i == 2 || __i == 4)
1975 std::__convert_to_v(__digits.c_str(), __l, __err,
1977 if (!(__err & ios_base::failbit) && __l <= INT_MAX)
1979 __l = __i == 2 ? __l : __l - 1900;
1980 __tm->tm_year = static_cast<int>(__l);
1984 __err |= ios_base::failbit;
1986 __err |= ios_base::eofbit;
1990 template<typename _CharT, typename _OutIter>
1992 time_put<_CharT, _OutIter>::
1993 put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
1994 const _CharT* __beg, const _CharT* __end) const
1996 const locale __loc = __io.getloc();
1997 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1998 for (; __beg != __end; ++__beg)
1999 if (__ctype.narrow(*__beg, 0) != '%')
2004 else if (++__beg != __end)
2008 const char __c = __ctype.narrow(*__beg, 0);
2009 if (__c != 'E' && __c != 'O')
2011 else if (++__beg != __end)
2014 __format = __ctype.narrow(*__beg, 0);
2018 __s = this->do_put(__s, __io, __fill, __tm,
2026 template<typename _CharT, typename _OutIter>
2028 time_put<_CharT, _OutIter>::
2029 do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm,
2030 char __format, char __mod) const
2032 const locale __loc = __io.getloc();
2033 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
2034 __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
2036 // NB: This size is arbitrary. Should this be a data member,
2037 // initialized at construction?
2038 const size_t __maxlen = 64;
2039 char_type* __res = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen));
2041 // NB: In IEE 1003.1-200x, and perhaps other locale models, it
2042 // is possible that the format character will be longer than one
2043 // character. Possibilities include 'E' or 'O' followed by a
2044 // format character: if __mod is not the default argument, assume
2045 // it's a valid modifier.
2047 __fmt[0] = __ctype.widen('%');
2050 __fmt[1] = __format;
2051 __fmt[2] = char_type();
2056 __fmt[2] = __format;
2057 __fmt[3] = char_type();
2060 __tp._M_put(__res, __maxlen, __fmt, __tm);
2062 // Write resulting, fully-formatted string to output iterator.
2063 return std::__write(__s, __res, char_traits<char_type>::length(__res));
2067 // Generic version does nothing.
2068 template<typename _CharT>
2070 collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const
2073 // Generic version does nothing.
2074 template<typename _CharT>
2076 collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const
2079 template<typename _CharT>
2082 do_compare(const _CharT* __lo1, const _CharT* __hi1,
2083 const _CharT* __lo2, const _CharT* __hi2) const
2085 // strcoll assumes zero-terminated strings so we make a copy
2086 // and then put a zero at the end.
2087 const string_type __one(__lo1, __hi1);
2088 const string_type __two(__lo2, __hi2);
2090 const _CharT* __p = __one.c_str();
2091 const _CharT* __pend = __one.data() + __one.length();
2092 const _CharT* __q = __two.c_str();
2093 const _CharT* __qend = __two.data() + __two.length();
2095 // strcoll stops when it sees a nul character so we break
2096 // the strings into zero-terminated substrings and pass those
2100 const int __res = _M_compare(__p, __q);
2104 __p += char_traits<_CharT>::length(__p);
2105 __q += char_traits<_CharT>::length(__q);
2106 if (__p == __pend && __q == __qend)
2108 else if (__p == __pend)
2110 else if (__q == __qend)
2118 template<typename _CharT>
2119 typename collate<_CharT>::string_type
2121 do_transform(const _CharT* __lo, const _CharT* __hi) const
2123 // strxfrm assumes zero-terminated strings so we make a copy
2124 string_type __str(__lo, __hi);
2126 const _CharT* __p = __str.c_str();
2127 const _CharT* __pend = __str.data() + __str.length();
2129 size_t __len = (__hi - __lo) * 2;
2133 // strxfrm stops when it sees a nul character so we break
2134 // the string into zero-terminated substrings and pass those
2138 // First try a buffer perhaps big enough.
2140 static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
2141 size_t __res = _M_transform(__c, __p, __len);
2142 // If the buffer was not large enough, try again with the
2147 __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
2149 __res = _M_transform(__c, __p, __res + 1);
2152 __ret.append(__c, __res);
2153 __p += char_traits<_CharT>::length(__p);
2158 __ret.push_back(_CharT());
2162 template<typename _CharT>
2165 do_hash(const _CharT* __lo, const _CharT* __hi) const
2167 unsigned long __val = 0;
2168 for (; __lo < __hi; ++__lo)
2169 __val = *__lo + ((__val << 7) |
2170 (__val >> (numeric_limits<unsigned long>::digits - 7)));
2171 return static_cast<long>(__val);
2174 // Construct correctly padded string, as per 22.2.2.2.2
2176 // __newlen > __oldlen
2177 // __news is allocated for __newlen size
2178 // Used by both num_put and ostream inserters: if __num,
2179 // internal-adjusted objects are padded according to the rules below
2180 // concerning 0[xX] and +-, otherwise, exactly as right-adjusted
2183 // NB: Of the two parameters, _CharT can be deduced from the
2184 // function arguments. The other (_Traits) has to be explicitly specified.
2185 template<typename _CharT, typename _Traits>
2187 __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
2188 _CharT* __news, const _CharT* __olds,
2189 const streamsize __newlen,
2190 const streamsize __oldlen, const bool __num)
2192 const size_t __plen = static_cast<size_t>(__newlen - __oldlen);
2193 const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
2196 if (__adjust == ios_base::left)
2198 _Traits::copy(__news, const_cast<_CharT*>(__olds), __oldlen);
2199 _Traits::assign(__news + __oldlen, __plen, __fill);
2204 if (__adjust == ios_base::internal && __num)
2206 // Pad after the sign, if there is one.
2207 // Pad after 0[xX], if there is one.
2208 // Who came up with these rules, anyway? Jeeze.
2209 const locale& __loc = __io._M_getloc();
2210 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
2211 const _CharT __minus = __ctype.widen('-');
2212 const _CharT __plus = __ctype.widen('+');
2213 const bool __testsign = _Traits::eq(__olds[0], __minus)
2214 || _Traits::eq(__olds[0], __plus);
2216 const bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0])
2217 && (_Traits::eq(__ctype.widen('x'), __olds[1])
2218 || _Traits::eq(__ctype.widen('X'), __olds[1]));
2221 __news[0] = __olds[0];
2222 __news[1] = __olds[1];
2226 else if (__testsign)
2228 __news[0] = __olds[0];
2232 // else Padding first.
2234 _Traits::assign(__news, __plen, __fill);
2235 _Traits::copy(__news + __plen, const_cast<_CharT*>(__olds + __mod),
2239 template<typename _CharT>
2241 __verify_grouping(const basic_string<_CharT>& __grouping,
2242 const basic_string<_CharT>& __grouping_tmp)
2246 const size_t __len = __grouping.size();
2247 const size_t __n = __grouping_tmp.size();
2250 // Parsed number groupings have to match the
2251 // numpunct::grouping string exactly, starting at the
2252 // right-most point of the parsed sequence of elements ...
2253 while (__test && __i < __n - 1)
2254 for (__j = 0; __test && __j < __len && __i < __n - 1; ++__j, ++__i)
2255 __test = __grouping[__j] == __grouping_tmp[__n - __i - 1];
2256 // ... but the last parsed grouping can be <= numpunct
2258 __j == __len ? __j = 0 : __j;
2259 __test &= __grouping[__j] >= __grouping_tmp[__n - __i - 1];
2263 template<typename _CharT>
2265 __add_grouping(_CharT* __s, _CharT __sep,
2266 const char* __gbeg, const char* __gend,
2267 const _CharT* __first, const _CharT* __last)
2269 if (__last - __first > *__gbeg)
2271 const bool __bump = __gbeg + 1 != __gend;
2272 __s = std::__add_grouping(__s, __sep, __gbeg + __bump,
2273 __gend, __first, __last - *__gbeg);
2274 __first = __last - *__gbeg;
2278 *__s++ = *__first++;
2279 while (__first != __last);
2283 // Inhibit implicit instantiations for required instantiations,
2284 // which are defined via explicit instantiations elsewhere.
2285 // NB: This syntax is a GNU extension.
2286 #if _GLIBCXX_EXTERN_TEMPLATE
2287 extern template class moneypunct<char, false>;
2288 extern template class moneypunct<char, true>;
2289 extern template class moneypunct_byname<char, false>;
2290 extern template class moneypunct_byname<char, true>;
2291 extern template class money_get<char>;
2292 extern template class money_put<char>;
2293 extern template class numpunct<char>;
2294 extern template class numpunct_byname<char>;
2295 extern template class num_get<char>;
2296 extern template class num_put<char>;
2297 extern template class __timepunct<char>;
2298 extern template class time_put<char>;
2299 extern template class time_put_byname<char>;
2300 extern template class time_get<char>;
2301 extern template class time_get_byname<char>;
2302 extern template class messages<char>;
2303 extern template class messages_byname<char>;
2304 extern template class ctype_byname<char>;
2305 extern template class codecvt_byname<char, char, mbstate_t>;
2306 extern template class collate<char>;
2307 extern template class collate_byname<char>;
2310 const codecvt<char, char, mbstate_t>&
2311 use_facet<codecvt<char, char, mbstate_t> >(const locale&);
2314 const collate<char>&
2315 use_facet<collate<char> >(const locale&);
2318 const numpunct<char>&
2319 use_facet<numpunct<char> >(const locale&);
2322 const num_put<char>&
2323 use_facet<num_put<char> >(const locale&);
2326 const num_get<char>&
2327 use_facet<num_get<char> >(const locale&);
2330 const moneypunct<char, true>&
2331 use_facet<moneypunct<char, true> >(const locale&);
2334 const moneypunct<char, false>&
2335 use_facet<moneypunct<char, false> >(const locale&);
2338 const money_put<char>&
2339 use_facet<money_put<char> >(const locale&);
2342 const money_get<char>&
2343 use_facet<money_get<char> >(const locale&);
2346 const __timepunct<char>&
2347 use_facet<__timepunct<char> >(const locale&);
2350 const time_put<char>&
2351 use_facet<time_put<char> >(const locale&);
2354 const time_get<char>&
2355 use_facet<time_get<char> >(const locale&);
2358 const messages<char>&
2359 use_facet<messages<char> >(const locale&);
2363 has_facet<ctype<char> >(const locale&);
2367 has_facet<codecvt<char, char, mbstate_t> >(const locale&);
2371 has_facet<collate<char> >(const locale&);
2375 has_facet<numpunct<char> >(const locale&);
2379 has_facet<num_put<char> >(const locale&);
2383 has_facet<num_get<char> >(const locale&);
2387 has_facet<moneypunct<char> >(const locale&);
2391 has_facet<money_put<char> >(const locale&);
2395 has_facet<money_get<char> >(const locale&);
2399 has_facet<__timepunct<char> >(const locale&);
2403 has_facet<time_put<char> >(const locale&);
2407 has_facet<time_get<char> >(const locale&);
2411 has_facet<messages<char> >(const locale&);
2413 #ifdef _GLIBCXX_USE_WCHAR_T
2414 extern template class moneypunct<wchar_t, false>;
2415 extern template class moneypunct<wchar_t, true>;
2416 extern template class moneypunct_byname<wchar_t, false>;
2417 extern template class moneypunct_byname<wchar_t, true>;
2418 extern template class money_get<wchar_t>;
2419 extern template class money_put<wchar_t>;
2420 extern template class numpunct<wchar_t>;
2421 extern template class numpunct_byname<wchar_t>;
2422 extern template class num_get<wchar_t>;
2423 extern template class num_put<wchar_t>;
2424 extern template class __timepunct<wchar_t>;
2425 extern template class time_put<wchar_t>;
2426 extern template class time_put_byname<wchar_t>;
2427 extern template class time_get<wchar_t>;
2428 extern template class time_get_byname<wchar_t>;
2429 extern template class messages<wchar_t>;
2430 extern template class messages_byname<wchar_t>;
2431 extern template class ctype_byname<wchar_t>;
2432 extern template class codecvt_byname<wchar_t, char, mbstate_t>;
2433 extern template class collate<wchar_t>;
2434 extern template class collate_byname<wchar_t>;
2437 const codecvt<wchar_t, char, mbstate_t>&
2438 use_facet<codecvt<wchar_t, char, mbstate_t> >(locale const&);
2441 const collate<wchar_t>&
2442 use_facet<collate<wchar_t> >(const locale&);
2445 const numpunct<wchar_t>&
2446 use_facet<numpunct<wchar_t> >(const locale&);
2449 const num_put<wchar_t>&
2450 use_facet<num_put<wchar_t> >(const locale&);
2453 const num_get<wchar_t>&
2454 use_facet<num_get<wchar_t> >(const locale&);
2457 const moneypunct<wchar_t, true>&
2458 use_facet<moneypunct<wchar_t, true> >(const locale&);
2461 const moneypunct<wchar_t, false>&
2462 use_facet<moneypunct<wchar_t, false> >(const locale&);
2465 const money_put<wchar_t>&
2466 use_facet<money_put<wchar_t> >(const locale&);
2469 const money_get<wchar_t>&
2470 use_facet<money_get<wchar_t> >(const locale&);
2473 const __timepunct<wchar_t>&
2474 use_facet<__timepunct<wchar_t> >(const locale&);
2477 const time_put<wchar_t>&
2478 use_facet<time_put<wchar_t> >(const locale&);
2481 const time_get<wchar_t>&
2482 use_facet<time_get<wchar_t> >(const locale&);
2485 const messages<wchar_t>&
2486 use_facet<messages<wchar_t> >(const locale&);
2490 has_facet<ctype<wchar_t> >(const locale&);
2494 has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
2498 has_facet<collate<wchar_t> >(const locale&);
2502 has_facet<numpunct<wchar_t> >(const locale&);
2506 has_facet<num_put<wchar_t> >(const locale&);
2510 has_facet<num_get<wchar_t> >(const locale&);
2514 has_facet<moneypunct<wchar_t> >(const locale&);
2518 has_facet<money_put<wchar_t> >(const locale&);
2522 has_facet<money_get<wchar_t> >(const locale&);
2526 has_facet<__timepunct<wchar_t> >(const locale&);
2530 has_facet<time_put<wchar_t> >(const locale&);
2534 has_facet<time_get<wchar_t> >(const locale&);
2538 has_facet<messages<wchar_t> >(const locale&);