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);
73 * @brief Test for the presence of a facet.
75 * has_facet tests the locale argument for the presence of the facet type
76 * provided as the template parameter. Facets derived from the facet
77 * parameter will also return true.
79 * @param Facet The facet type to test the presence of.
80 * @param locale The locale to test.
81 * @return true if locale contains a facet of type Facet, else false.
82 * @throw std::bad_cast if locale doesn't contain the facet.
84 template<typename _Facet>
86 has_facet(const locale& __loc) throw()
88 const size_t __i = _Facet::id._M_id();
89 const locale::facet** __facets = __loc._M_impl->_M_facets;
90 return (__i < __loc._M_impl->_M_facets_size && __facets[__i]);
94 * @brief Return a facet.
96 * use_facet looks for and returns a reference to a facet of type Facet
97 * where Facet is the template parameter. If has_facet(locale) is true,
98 * there is a suitable facet to return. It throws std::bad_cast if the
99 * locale doesn't contain a facet of type Facet.
101 * @param Facet The facet type to access.
102 * @param locale The locale to use.
103 * @return Reference to facet of type Facet.
104 * @throw std::bad_cast if locale doesn't contain a facet of type Facet.
106 template<typename _Facet>
108 use_facet(const locale& __loc)
110 const size_t __i = _Facet::id._M_id();
111 const locale::facet** __facets = __loc._M_impl->_M_facets;
112 if (!(__i < __loc._M_impl->_M_facets_size && __facets[__i]))
114 return static_cast<const _Facet&>(*__facets[__i]);
117 // Routine to access a cache for the facet. If the cache didn't
118 // exist before, it gets constructed on the fly.
119 template<typename _Facet>
123 operator() (const locale& __loc) const;
126 template<typename _CharT>
127 struct __use_cache<__numpunct_cache<_CharT> >
129 const __numpunct_cache<_CharT>*
130 operator() (const locale& __loc) const
132 const size_t __i = numpunct<_CharT>::id._M_id();
133 const locale::facet** __caches = __loc._M_impl->_M_caches;
136 __numpunct_cache<_CharT>* __tmp = NULL;
139 __tmp = new __numpunct_cache<_CharT>;
140 __tmp->_M_cache(__loc);
145 __throw_exception_again;
147 __loc._M_impl->_M_install_cache(__tmp, __i);
149 return static_cast<const __numpunct_cache<_CharT>*>(__caches[__i]);
153 template<typename _CharT, typename _InIter>
155 num_get<_CharT, _InIter>::
156 _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io,
157 ios_base::iostate& __err, string& __xtrc) const
159 typedef char_traits<_CharT> __traits_type;
160 typedef typename numpunct<_CharT>::__cache_type __cache_type;
161 __use_cache<__cache_type> __uc;
162 const locale& __loc = __io._M_getloc();
163 const __cache_type* __lc = __uc(__loc);
164 const _CharT* __lit = __lc->_M_atoms_in;
166 // True if a mantissa is found.
167 bool __found_mantissa = false;
169 // First check for sign.
172 const char_type __c = *__beg;
173 const bool __plus = __traits_type::eq(__c, __lit[_S_iplus]);
174 if ((__plus || __traits_type::eq(__c, __lit[_S_iminus]))
175 && !__traits_type::eq(__c, __lc->_M_decimal_point)
176 && (!__lc->_M_use_grouping
177 || !__traits_type::eq(__c, __lc->_M_thousands_sep)))
179 __xtrc += __plus ? _S_atoms_in[_S_iplus]
180 : _S_atoms_in[_S_iminus];
185 // Next, look for leading zeros.
186 while (__beg != __end)
188 const char_type __c = *__beg;
189 if (__traits_type::eq(__c, __lc->_M_decimal_point)
190 || (__lc->_M_use_grouping
191 && __traits_type::eq(__c, __lc->_M_thousands_sep)))
193 else if (__traits_type::eq(__c, __lit[_S_izero]))
195 if (!__found_mantissa)
197 __xtrc += _S_atoms_in[_S_izero];
198 __found_mantissa = true;
206 // Only need acceptable digits for floating point numbers.
207 bool __found_dec = false;
208 bool __found_sci = false;
209 string __found_grouping;
212 const char_type* __p;
213 while (__beg != __end)
215 // According to 22.2.2.1.2, p8-9, first look for decimal_point
216 // and thousands_sep.
217 const char_type __c = *__beg;
218 if (__traits_type::eq(__c, __lc->_M_decimal_point)
219 && !__found_dec && !__found_sci)
221 // According to the standard, if no grouping chars are seen,
222 // no grouping check is applied. Therefore __found_grouping
223 // must be adjusted only if __dec comes after some __sep.
224 if (__found_grouping.size())
225 __found_grouping += static_cast<char>(__sep_pos);
230 else if (__lc->_M_use_grouping
231 && __traits_type::eq(__c, __lc->_M_thousands_sep)
232 && !__found_dec && !__found_sci)
234 // NB: Thousands separator at the beginning of a string
235 // is a no-no, as is two consecutive thousands separators.
238 __found_grouping += static_cast<char>(__sep_pos);
244 __err |= ios_base::failbit;
248 else if (__p = __traits_type::find(__lit + _S_izero, 10, __c))
250 __xtrc += _S_atoms_in[__p - __lit];
251 __found_mantissa = true;
255 else if ((__e = __traits_type::eq(__c, __lit[_S_ie])
256 || __traits_type::eq(__c, __lit[_S_iE]))
257 && __found_mantissa && !__found_sci)
259 // Scientific notation.
260 __xtrc += __e ? _S_atoms_in[_S_ie] : _S_atoms_in[_S_iE];
263 // Remove optional plus or minus sign, if they exist.
264 if (++__beg != __end)
266 const bool __plus = __traits_type::eq(*__beg, __lit[_S_iplus]);
267 if (__plus || __traits_type::eq(*__beg, __lit[_S_iminus]))
269 __xtrc += __plus ? _S_atoms_in[_S_iplus]
270 : _S_atoms_in[_S_iminus];
276 // Not a valid input item.
280 // Digit grouping is checked. If grouping and found_grouping don't
281 // match, then get very very upset, and set failbit.
282 if (__lc->_M_use_grouping && __found_grouping.size())
284 // Add the ending grouping if a decimal wasn't found.
286 __found_grouping += static_cast<char>(__sep_pos);
288 const string __grouping = __lc->_M_grouping;
289 if (!std::__verify_grouping(__grouping, __found_grouping))
290 __err |= ios_base::failbit;
296 __err |= ios_base::eofbit;
300 template<typename _CharT, typename _InIter>
301 template<typename _ValueT>
303 num_get<_CharT, _InIter>::
304 _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
305 ios_base::iostate& __err, _ValueT& __v) const
307 typedef char_traits<_CharT> __traits_type;
308 typedef typename numpunct<_CharT>::__cache_type __cache_type;
309 __use_cache<__cache_type> __uc;
310 const locale& __loc = __io._M_getloc();
311 const __cache_type* __lc = __uc(__loc);
312 const _CharT* __lit = __lc->_M_atoms_in;
314 // NB: Iff __basefield == 0, __base can change based on contents.
315 const ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
316 const bool __oct = __basefield == ios_base::oct;
317 int __base = __oct ? 8 : (__basefield == ios_base::hex ? 16 : 10);
319 // True if numeric digits are found.
320 bool __found_num = false;
322 // First check for sign.
323 bool __negative = false;
326 const char_type __c = *__beg;
327 if (numeric_limits<_ValueT>::is_signed)
328 __negative = __traits_type::eq(__c, __lit[_S_iminus]);
329 if ((__negative || __traits_type::eq(__c, __lit[_S_iplus]))
330 && !__traits_type::eq(__c, __lc->_M_decimal_point)
331 && (!__lc->_M_use_grouping
332 || !__traits_type::eq(__c, __lc->_M_thousands_sep)))
336 // Next, look for leading zeros and check required digits
338 while (__beg != __end)
340 const char_type __c = *__beg;
341 if (__traits_type::eq(__c, __lc->_M_decimal_point)
342 || (__lc->_M_use_grouping
343 && __traits_type::eq(__c, __lc->_M_thousands_sep)))
345 else if (__traits_type::eq(__c, __lit[_S_izero])
346 && (!__found_num || __base == 10))
351 else if (__found_num)
353 if (__traits_type::eq(__c, __lit[_S_ix])
354 || __traits_type::eq(__c, __lit[_S_iX]))
356 if (__basefield == 0)
364 else if (__basefield == 0)
372 // At this point, base is determined. If not hex, only allow
373 // base digits as valid input.
374 const size_t __len = __base == 16 ? _S_iend : __base;
377 string __found_grouping;
379 bool __overflow = false;
380 _ValueT __result = 0;
381 const char_type* __lit_zero = __lit + _S_izero;
382 const char_type* __p;
385 const _ValueT __min = numeric_limits<_ValueT>::min() / __base;
386 for (; __beg != __end; ++__beg)
388 // According to 22.2.2.1.2, p8-9, first look for decimal_point
389 // and thousands_sep.
390 const char_type __c = *__beg;
391 if (__traits_type::eq(__c, __lc->_M_decimal_point))
393 else if (__lc->_M_use_grouping
394 && __traits_type::eq(__c, __lc->_M_thousands_sep))
396 // NB: Thousands separator at the beginning of a string
397 // is a no-no, as is two consecutive thousands separators.
400 __found_grouping += static_cast<char>(__sep_pos);
405 __err |= ios_base::failbit;
409 else if (__p = __traits_type::find(__lit_zero, __len, __c))
411 int __digit = __p - __lit_zero;
414 if (__result < __min)
418 const _ValueT __new_result = __result * __base - __digit;
419 __overflow |= __new_result > __result;
420 __result = __new_result;
426 // Not a valid input item.
432 const _ValueT __max = numeric_limits<_ValueT>::max() / __base;
433 for (; __beg != __end; ++__beg)
435 const char_type __c = *__beg;
436 if (__traits_type::eq(__c, __lc->_M_decimal_point))
438 else if (__lc->_M_use_grouping
439 && __traits_type::eq(__c, __lc->_M_thousands_sep))
443 __found_grouping += static_cast<char>(__sep_pos);
448 __err |= ios_base::failbit;
452 else if (__p = __traits_type::find(__lit_zero, __len, __c))
454 int __digit = __p - __lit_zero;
457 if (__result > __max)
461 const _ValueT __new_result = __result * __base + __digit;
462 __overflow |= __new_result < __result;
463 __result = __new_result;
473 // Digit grouping is checked. If grouping and found_grouping don't
474 // match, then get very very upset, and set failbit.
475 if (__lc->_M_use_grouping && __found_grouping.size())
477 // Add the ending grouping.
478 __found_grouping += static_cast<char>(__sep_pos);
480 const string __grouping = __lc->_M_grouping;
481 if (!std::__verify_grouping(__grouping, __found_grouping))
482 __err |= ios_base::failbit;
485 if (!(__err & ios_base::failbit) && !__overflow
489 __err |= ios_base::failbit;
492 __err |= ios_base::eofbit;
496 // _GLIBCXX_RESOLVE_LIB_DEFECTS
497 // 17. Bad bool parsing
498 template<typename _CharT, typename _InIter>
500 num_get<_CharT, _InIter>::
501 do_get(iter_type __beg, iter_type __end, ios_base& __io,
502 ios_base::iostate& __err, bool& __v) const
504 if (!(__io.flags() & ios_base::boolalpha))
506 // Parse bool values as long.
507 // NB: We can't just call do_get(long) here, as it might
508 // refer to a derived class.
510 __beg = _M_extract_int(__beg, __end, __io, __err, __l);
511 if (__l == 0 || __l == 1)
514 __err |= ios_base::failbit;
518 // Parse bool values as alphanumeric.
519 typedef char_traits<_CharT> __traits_type;
520 typedef typename numpunct<_CharT>::__cache_type __cache_type;
521 __use_cache<__cache_type> __uc;
522 const locale& __loc = __io._M_getloc();
523 const __cache_type* __lc = __uc(__loc);
524 const size_t __tn = __traits_type::length(__lc->_M_truename);
525 const size_t __fn = __traits_type::length(__lc->_M_falsename);
530 for (__n = 0; __beg != __end; ++__n, ++__beg)
534 __testf = __traits_type::eq(*__beg, __lc->_M_falsename[__n]);
540 __testt = __traits_type::eq(*__beg, __lc->_M_truename[__n]);
544 if (!__testf && !__testt)
547 if (__testf && __n == __fn)
549 else if (__testt && __n == __tn)
552 __err |= ios_base::failbit;
555 __err |= ios_base::eofbit;
560 template<typename _CharT, typename _InIter>
562 num_get<_CharT, _InIter>::
563 do_get(iter_type __beg, iter_type __end, ios_base& __io,
564 ios_base::iostate& __err, long& __v) const
565 { return _M_extract_int(__beg, __end, __io, __err, __v); }
567 template<typename _CharT, typename _InIter>
569 num_get<_CharT, _InIter>::
570 do_get(iter_type __beg, iter_type __end, ios_base& __io,
571 ios_base::iostate& __err, unsigned short& __v) const
572 { return _M_extract_int(__beg, __end, __io, __err, __v); }
574 template<typename _CharT, typename _InIter>
576 num_get<_CharT, _InIter>::
577 do_get(iter_type __beg, iter_type __end, ios_base& __io,
578 ios_base::iostate& __err, unsigned int& __v) const
579 { return _M_extract_int(__beg, __end, __io, __err, __v); }
581 template<typename _CharT, typename _InIter>
583 num_get<_CharT, _InIter>::
584 do_get(iter_type __beg, iter_type __end, ios_base& __io,
585 ios_base::iostate& __err, unsigned long& __v) const
586 { return _M_extract_int(__beg, __end, __io, __err, __v); }
588 #ifdef _GLIBCXX_USE_LONG_LONG
589 template<typename _CharT, typename _InIter>
591 num_get<_CharT, _InIter>::
592 do_get(iter_type __beg, iter_type __end, ios_base& __io,
593 ios_base::iostate& __err, long long& __v) const
594 { return _M_extract_int(__beg, __end, __io, __err, __v); }
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, unsigned long long& __v) const
601 { return _M_extract_int(__beg, __end, __io, __err, __v); }
604 template<typename _CharT, typename _InIter>
606 num_get<_CharT, _InIter>::
607 do_get(iter_type __beg, iter_type __end, ios_base& __io,
608 ios_base::iostate& __err, float& __v) const
612 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
613 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
617 template<typename _CharT, typename _InIter>
619 num_get<_CharT, _InIter>::
620 do_get(iter_type __beg, iter_type __end, ios_base& __io,
621 ios_base::iostate& __err, double& __v) const
625 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
626 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
630 template<typename _CharT, typename _InIter>
632 num_get<_CharT, _InIter>::
633 do_get(iter_type __beg, iter_type __end, ios_base& __io,
634 ios_base::iostate& __err, long double& __v) const
638 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
639 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
643 template<typename _CharT, typename _InIter>
645 num_get<_CharT, _InIter>::
646 do_get(iter_type __beg, iter_type __end, ios_base& __io,
647 ios_base::iostate& __err, void*& __v) const
649 // Prepare for hex formatted input.
650 typedef ios_base::fmtflags fmtflags;
651 const fmtflags __fmt = __io.flags();
652 const fmtflags __fmtmask = ~(ios_base::showpos | ios_base::basefield
653 | ios_base::uppercase | ios_base::internal);
654 __io.flags(__fmt & __fmtmask | (ios_base::hex | ios_base::showbase));
657 __beg = _M_extract_int(__beg, __end, __io, __err, __ul);
659 // Reset from hex formatted input.
662 if (!(__err & ios_base::failbit))
663 __v = reinterpret_cast<void*>(__ul);
665 __err |= ios_base::failbit;
669 // For use by integer and floating-point types after they have been
670 // converted into a char_type string.
671 template<typename _CharT, typename _OutIter>
673 num_put<_CharT, _OutIter>::
674 _M_pad(_CharT __fill, streamsize __w, ios_base& __io,
675 _CharT* __new, const _CharT* __cs, int& __len) const
677 // [22.2.2.2.2] Stage 3.
678 // If necessary, pad.
679 __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, __cs,
681 __len = static_cast<int>(__w);
684 // Forwarding functions to peel signed from unsigned integer types.
685 template<typename _CharT>
687 __int_to_char(_CharT* __bufend, long __v, const _CharT* __lit,
688 ios_base::fmtflags __flags)
690 unsigned long __ul = static_cast<unsigned long>(__v);
697 return __int_to_char(__bufend, __ul, __lit, __flags, __neg);
700 template<typename _CharT>
702 __int_to_char(_CharT* __bufend, unsigned long __v, const _CharT* __lit,
703 ios_base::fmtflags __flags)
704 { return __int_to_char(__bufend, __v, __lit, __flags, false); }
706 #ifdef _GLIBCXX_USE_LONG_LONG
707 template<typename _CharT>
709 __int_to_char(_CharT* __bufend, long long __v, const _CharT* __lit,
710 ios_base::fmtflags __flags)
712 unsigned long long __ull = static_cast<unsigned long long>(__v);
719 return __int_to_char(__bufend, __ull, __lit, __flags, __neg);
722 template<typename _CharT>
724 __int_to_char(_CharT* __bufend, unsigned long long __v, const _CharT* __lit,
725 ios_base::fmtflags __flags)
726 { return __int_to_char(__bufend, __v, __lit, __flags, false); }
729 template<typename _CharT, typename _ValueT>
731 __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit,
732 ios_base::fmtflags __flags, bool __neg)
734 // Don't write base if already 0.
735 const bool __showbase = (__flags & ios_base::showbase) && __v;
736 const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
737 _CharT* __buf = __bufend - 1;
739 if (__builtin_expect(__basefield != ios_base::oct &&
740 __basefield != ios_base::hex, true))
745 *__buf-- = __lit[(__v % 10) + __num_base::_S_odigits];
750 *__buf-- = __lit[__num_base::_S_ominus];
751 else if (__flags & ios_base::showpos)
752 *__buf-- = __lit[__num_base::_S_oplus];
754 else if (__basefield == ios_base::oct)
759 *__buf-- = __lit[(__v & 0x7) + __num_base::_S_odigits];
764 *__buf-- = __lit[__num_base::_S_odigits];
769 const bool __uppercase = __flags & ios_base::uppercase;
770 const int __case_offset = __uppercase ? __num_base::_S_oudigits
771 : __num_base::_S_odigits;
774 *__buf-- = __lit[(__v & 0xf) + __case_offset];
781 *__buf-- = __lit[__num_base::_S_ox + __uppercase];
783 *__buf-- = __lit[__num_base::_S_odigits];
786 return __bufend - __buf - 1;
789 template<typename _CharT, typename _OutIter>
791 num_put<_CharT, _OutIter>::
792 _M_group_int(const string& __grouping, _CharT __sep, ios_base& __io,
793 _CharT* __new, _CharT* __cs, int& __len) const
795 // By itself __add_grouping cannot deal correctly with __cs when
796 // ios::showbase is set and ios_base::oct || ios_base::hex.
797 // Therefore we take care "by hand" of the initial 0, 0x or 0X.
798 // However, remember that the latter do not occur if the number
799 // printed is '0' (__len == 1).
800 streamsize __off = 0;
801 const ios_base::fmtflags __basefield = __io.flags()
802 & ios_base::basefield;
803 if ((__io.flags() & ios_base::showbase) && __len > 1)
804 if (__basefield == ios_base::oct)
809 else if (__basefield == ios_base::hex)
816 __p = std::__add_grouping(__new + __off, __sep, __grouping.data(),
817 __grouping.data() + __grouping.size(),
818 __cs + __off, __cs + __len);
822 template<typename _CharT, typename _OutIter>
823 template<typename _ValueT>
825 num_put<_CharT, _OutIter>::
826 _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
829 typedef typename numpunct<_CharT>::__cache_type __cache_type;
830 __use_cache<__cache_type> __uc;
831 const locale& __loc = __io._M_getloc();
832 const __cache_type* __lc = __uc(__loc);
833 const _CharT* __lit = __lc->_M_atoms_out;
835 // Long enough to hold hex, dec, and octal representations.
836 const int __ilen = 4 * sizeof(_ValueT);
837 _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
840 // [22.2.2.2.2] Stage 1, numeric conversion to character.
841 // Result is returned right-justified in the buffer.
843 __len = __int_to_char(__cs + __ilen, __v, __lit, __io.flags());
844 __cs += __ilen - __len;
846 // Add grouping, if necessary.
847 if (__lc->_M_use_grouping)
849 // Grouping can add (almost) as many separators as the
850 // number of digits, but no more.
851 _CharT* __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
853 _M_group_int(__lc->_M_grouping, __lc->_M_thousands_sep, __io,
859 const streamsize __w = __io.width();
860 if (__w > static_cast<streamsize>(__len))
862 _CharT* __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
864 _M_pad(__fill, __w, __io, __cs3, __cs, __len);
869 // [22.2.2.2.2] Stage 4.
870 // Write resulting, fully-formatted string to output iterator.
871 return std::__write(__s, __cs, __len);
874 template<typename _CharT, typename _OutIter>
876 num_put<_CharT, _OutIter>::
877 _M_group_float(const string& __grouping, _CharT __sep, const _CharT* __p,
878 _CharT* __new, _CharT* __cs, int& __len) const
880 // _GLIBCXX_RESOLVE_LIB_DEFECTS
881 // 282. What types does numpunct grouping refer to?
882 // Add grouping, if necessary.
884 const int __declen = __p ? __p - __cs : __len;
885 __p2 = std::__add_grouping(__new, __sep, __grouping.data(),
886 __grouping.data() + __grouping.size(),
887 __cs, __cs + __declen);
889 // Tack on decimal part.
890 int __newlen = __p2 - __new;
893 char_traits<_CharT>::copy(__p2, __p, __len - __declen);
894 __newlen += __len - __declen;
899 // The following code uses snprintf (or sprintf(), when
900 // _GLIBCXX_USE_C99 is not defined) to convert floating point values
901 // for insertion into a stream. An optimization would be to replace
902 // them with code that works directly on a wide buffer and then use
903 // __pad to do the padding. It would be good to replace them anyway
904 // to gain back the efficiency that C++ provides by knowing up front
905 // the type of the values to insert. Also, sprintf is dangerous
906 // since may lead to accidental buffer overruns. This
907 // implementation follows the C++ standard fairly directly as
908 // outlined in 22.2.2.2 [lib.locale.num.put]
909 template<typename _CharT, typename _OutIter>
910 template<typename _ValueT>
912 num_put<_CharT, _OutIter>::
913 _M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
916 typedef typename numpunct<_CharT>::__cache_type __cache_type;
917 __use_cache<__cache_type> __uc;
918 const locale& __loc = __io._M_getloc();
919 const __cache_type* __lc = __uc(__loc);
921 // Note: digits10 is rounded down: add 1 to ensure the maximum
922 // available precision. Then, in general, one more 1 needs to
923 // be added since, when the %{g,G} conversion specifiers are
924 // chosen inside _S_format_float, the precision field is "the
925 // maximum number of significant digits", *not* the "number of
926 // digits to appear after the decimal point", as happens for
927 // %{e,E,f,F} (C99, 7.19.6.1,4).
928 const int __max_digits = numeric_limits<_ValueT>::digits10 + 2;
930 // Use default precision if out of range.
931 streamsize __prec = __io.precision();
932 if (__prec > static_cast<streamsize>(__max_digits))
933 __prec = static_cast<streamsize>(__max_digits);
934 else if (__prec < static_cast<streamsize>(0))
935 __prec = static_cast<streamsize>(6);
937 // [22.2.2.2.2] Stage 1, numeric conversion to character.
939 // Long enough for the max format spec.
942 #ifdef _GLIBCXX_USE_C99
943 // First try a buffer perhaps big enough (for sure sufficient
944 // for non-ios_base::fixed outputs)
945 int __cs_size = __max_digits * 3;
946 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
948 _S_format_float(__io, __fbuf, __mod);
949 __len = std::__convert_from_v(__cs, __cs_size, __fbuf, __v,
950 _S_get_c_locale(), __prec);
952 // If the buffer was not large enough, try again with the correct size.
953 if (__len >= __cs_size)
955 __cs_size = __len + 1;
956 __cs = static_cast<char*>(__builtin_alloca(__cs_size));
957 __len = std::__convert_from_v(__cs, __cs_size, __fbuf, __v,
958 _S_get_c_locale(), __prec);
961 // Consider the possibility of long ios_base::fixed outputs
962 const bool __fixed = __io.flags() & ios_base::fixed;
963 const int __max_exp = numeric_limits<_ValueT>::max_exponent10;
965 // The size of the output string is computed as follows.
966 // ios_base::fixed outputs may need up to __max_exp+1 chars
967 // for the integer part + up to __max_digits chars for the
968 // fractional part + 3 chars for sign, decimal point, '\0'. On
969 // the other hand, for non-fixed outputs __max_digits*3 chars
970 // are largely sufficient.
971 const int __cs_size = __fixed ? __max_exp + __max_digits + 4
973 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
975 _S_format_float(__io, __fbuf, __mod);
976 __len = std::__convert_from_v(__cs, 0, __fbuf, __v,
977 _S_get_c_locale(), __prec);
980 // [22.2.2.2.2] Stage 2, convert to char_type, using correct
981 // numpunct.decimal_point() values for '.' and adding grouping.
982 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
984 _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
986 __ctype.widen(__cs, __cs + __len, __ws);
988 // Replace decimal point.
989 const _CharT __cdec = __ctype.widen('.');
990 const _CharT __dec = __lc->_M_decimal_point;
992 if (__p = char_traits<_CharT>::find(__ws, __len, __cdec))
993 __ws[__p - __ws] = __dec;
995 // Add grouping, if necessary.
996 if (__lc->_M_use_grouping)
998 // Grouping can add (almost) as many separators as the
999 // number of digits, but no more.
1000 _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1002 _M_group_float(__lc->_M_grouping, __lc->_M_thousands_sep, __p,
1003 __ws2, __ws, __len);
1008 const streamsize __w = __io.width();
1009 if (__w > static_cast<streamsize>(__len))
1011 _CharT* __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1013 _M_pad(__fill, __w, __io, __ws3, __ws, __len);
1018 // [22.2.2.2.2] Stage 4.
1019 // Write resulting, fully-formatted string to output iterator.
1020 return std::__write(__s, __ws, __len);
1023 template<typename _CharT, typename _OutIter>
1025 num_put<_CharT, _OutIter>::
1026 do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
1028 const ios_base::fmtflags __flags = __io.flags();
1029 if ((__flags & ios_base::boolalpha) == 0)
1031 unsigned long __uv = __v;
1032 __s = _M_insert_int(__s, __io, __fill, __uv);
1036 typedef typename numpunct<_CharT>::__cache_type __cache_type;
1037 __use_cache<__cache_type> __uc;
1038 const locale& __loc = __io._M_getloc();
1039 const __cache_type* __lc = __uc(__loc);
1041 const _CharT* __name = __v ? __lc->_M_truename
1042 : __lc->_M_falsename;
1043 int __len = char_traits<_CharT>::length(__name);
1045 const streamsize __w = __io.width();
1046 if (__w > static_cast<streamsize>(__len))
1048 _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1050 _M_pad(__fill, __w, __io, __cs, __name, __len);
1054 __s = std::__write(__s, __name, __len);
1059 template<typename _CharT, typename _OutIter>
1061 num_put<_CharT, _OutIter>::
1062 do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
1063 { return _M_insert_int(__s, __io, __fill, __v); }
1065 template<typename _CharT, typename _OutIter>
1067 num_put<_CharT, _OutIter>::
1068 do_put(iter_type __s, ios_base& __io, char_type __fill,
1069 unsigned long __v) const
1070 { return _M_insert_int(__s, __io, __fill, __v); }
1072 #ifdef _GLIBCXX_USE_LONG_LONG
1073 template<typename _CharT, typename _OutIter>
1075 num_put<_CharT, _OutIter>::
1076 do_put(iter_type __s, ios_base& __b, char_type __fill, long long __v) const
1077 { return _M_insert_int(__s, __b, __fill, __v); }
1079 template<typename _CharT, typename _OutIter>
1081 num_put<_CharT, _OutIter>::
1082 do_put(iter_type __s, ios_base& __io, char_type __fill,
1083 unsigned long long __v) const
1084 { return _M_insert_int(__s, __io, __fill, __v); }
1087 template<typename _CharT, typename _OutIter>
1089 num_put<_CharT, _OutIter>::
1090 do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
1091 { return _M_insert_float(__s, __io, __fill, char(), __v); }
1093 template<typename _CharT, typename _OutIter>
1095 num_put<_CharT, _OutIter>::
1096 do_put(iter_type __s, ios_base& __io, char_type __fill,
1097 long double __v) const
1098 { return _M_insert_float(__s, __io, __fill, 'L', __v); }
1100 template<typename _CharT, typename _OutIter>
1102 num_put<_CharT, _OutIter>::
1103 do_put(iter_type __s, ios_base& __io, char_type __fill,
1104 const void* __v) const
1106 const ios_base::fmtflags __flags = __io.flags();
1107 const ios_base::fmtflags __fmt = ~(ios_base::showpos | ios_base::basefield
1108 | ios_base::uppercase | ios_base::internal);
1109 __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
1111 __s = _M_insert_int(__s, __io, __fill,
1112 reinterpret_cast<unsigned long>(__v));
1113 __io.flags(__flags);
1118 template<typename _CharT, typename _InIter>
1120 money_get<_CharT, _InIter>::
1121 do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
1122 ios_base::iostate& __err, long double& __units) const
1125 __beg = this->do_get(__beg, __end, __intl, __io, __err, __str);
1127 const int __cs_size = __str.size() + 1;
1128 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1129 const locale __loc = __io.getloc();
1130 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1131 const _CharT* __wcs = __str.c_str();
1132 __ctype.narrow(__wcs, __wcs + __cs_size, char(), __cs);
1133 std::__convert_to_v(__cs, __units, __err, _S_get_c_locale());
1137 template<typename _CharT, typename _InIter>
1139 money_get<_CharT, _InIter>::
1140 do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
1141 ios_base::iostate& __err, string_type& __units) const
1143 // These contortions are quite unfortunate.
1144 typedef moneypunct<_CharT, true> __money_true;
1145 typedef moneypunct<_CharT, false> __money_false;
1146 typedef money_base::part part;
1147 typedef typename string_type::size_type size_type;
1149 const locale __loc = __io.getloc();
1150 const __money_true& __mpt = use_facet<__money_true>(__loc);
1151 const __money_false& __mpf = use_facet<__money_false>(__loc);
1152 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1154 const money_base::pattern __p = __intl ? __mpt.neg_format()
1155 : __mpf.neg_format();
1157 const string_type __pos_sign = __intl ? __mpt.positive_sign()
1158 : __mpf.positive_sign();
1159 const string_type __neg_sign = __intl ? __mpt.negative_sign()
1160 : __mpf.negative_sign();
1161 const char_type __d = __intl ? __mpt.decimal_point()
1162 : __mpf.decimal_point();
1163 const char_type __sep = __intl ? __mpt.thousands_sep()
1164 : __mpf.thousands_sep();
1166 const string __grouping = __intl ? __mpt.grouping() : __mpf.grouping();
1168 // Set to deduced positive or negative sign, depending.
1170 // String of grouping info from thousands_sep plucked from __units.
1171 string __grouping_tmp;
1172 // Marker for thousands_sep position.
1174 // If input iterator is in a valid state.
1175 bool __testvalid = true;
1176 // Flag marking when a decimal point is found.
1177 bool __testdecfound = false;
1179 // The tentative returned string is stored here.
1180 string_type __tmp_units;
1182 for (int __i = 0; __beg != __end && __i < 4 && __testvalid; ++__i)
1185 const part __which = static_cast<part>(__p.field[__i]);
1188 case money_base::symbol:
1189 if (__io.flags() & ios_base::showbase
1190 || __i < 2 || __sign.size() > 1
1191 || ((static_cast<part>(__p.field[3]) != money_base::none)
1194 // According to 22.2.6.1.2.2, symbol is required
1195 // if (__io.flags() & ios_base::showbase),
1196 // otherwise is optional and consumed only if
1197 // other characters are needed to complete the
1199 const string_type __symbol = __intl ? __mpt.curr_symbol()
1200 : __mpf.curr_symbol();
1201 const size_type __len = __symbol.size();
1203 for (; __beg != __end && __j < __len
1204 && *__beg == __symbol[__j]; ++__beg, ++__j);
1205 // When (__io.flags() & ios_base::showbase)
1206 // symbol is required.
1207 if (__j != __len && (__io.flags() & ios_base::showbase))
1208 __testvalid = false;
1211 case money_base::sign:
1212 // Sign might not exist, or be more than one character long.
1213 if (__pos_sign.size() && *__beg == __pos_sign[0])
1215 __sign = __pos_sign;
1218 else if (__neg_sign.size() && *__beg == __neg_sign[0])
1220 __sign = __neg_sign;
1223 else if (__pos_sign.size() && __neg_sign.size())
1225 // Sign is mandatory.
1226 __testvalid = false;
1229 case money_base::value:
1230 // Extract digits, remove and stash away the
1231 // grouping of found thousands separators.
1232 for (; __beg != __end; ++__beg)
1233 if (__ctype.is(ctype_base::digit, __c = *__beg))
1238 else if (__c == __d && !__testdecfound)
1240 __grouping_tmp += static_cast<char>(__sep_pos);
1242 __testdecfound = true;
1244 else if (__c == __sep)
1246 if (__grouping.size())
1248 // Mark position for later analysis.
1249 __grouping_tmp += static_cast<char>(__sep_pos);
1254 __testvalid = false;
1261 case money_base::space:
1262 case money_base::none:
1263 // Only if not at the end of the pattern.
1265 for (; __beg != __end
1266 && __ctype.is(ctype_base::space, *__beg); ++__beg);
1271 // Need to get the rest of the sign characters, if they exist.
1272 if (__sign.size() > 1)
1274 const size_type __len = __sign.size();
1276 for (; __beg != __end && __i < __len; ++__i)
1277 for (; __beg != __end
1278 && *__beg != __sign[__i]; ++__beg);
1281 __testvalid = false;
1284 if (__testvalid && __tmp_units.size())
1286 const char_type __zero = __ctype.widen('0');
1288 // Strip leading zeros.
1289 if (__tmp_units.size() > 1)
1291 const size_type __first = __tmp_units.find_first_not_of(__zero);
1292 const bool __only_zeros = __first == string_type::npos;
1294 __tmp_units.erase(0, __only_zeros ? __tmp_units.size() - 1
1299 if (__sign.size() && __sign == __neg_sign
1300 && __tmp_units[0] != __zero)
1301 __tmp_units.insert(__tmp_units.begin(), __ctype.widen('-'));
1303 // Test for grouping fidelity.
1304 if (__grouping.size() && __grouping_tmp.size())
1306 if (!std::__verify_grouping(__grouping, __grouping_tmp))
1307 __testvalid = false;
1310 // Iff not enough digits were supplied after the decimal-point.
1313 const int __frac = __intl ? __mpt.frac_digits()
1314 : __mpf.frac_digits();
1315 if (__frac > 0 && __sep_pos != __frac)
1316 __testvalid = false;
1320 __testvalid = false;
1322 // Iff no more characters are available.
1324 __err |= ios_base::eofbit;
1326 // Iff valid sequence is not recognized.
1328 __err |= ios_base::failbit;
1330 // Use the "swap trick" to copy __tmp_units into __units.
1331 __tmp_units.swap(__units);
1336 template<typename _CharT, typename _OutIter>
1338 money_put<_CharT, _OutIter>::
1339 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1340 long double __units) const
1342 const locale __loc = __io.getloc();
1343 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1344 #ifdef _GLIBCXX_USE_C99
1345 // First try a buffer perhaps big enough.
1347 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1348 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1349 // 328. Bad sprintf format modifier in money_put<>::do_put()
1350 int __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
1352 // If the buffer was not large enough, try again with the correct size.
1353 if (__len >= __cs_size)
1355 __cs_size = __len + 1;
1356 __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1357 __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
1361 // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
1362 const int __cs_size = numeric_limits<long double>::max_exponent10 + 3;
1363 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1364 int __len = std::__convert_from_v(__cs, 0, "%.0Lf", __units,
1367 _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1369 __ctype.widen(__cs, __cs + __len, __ws);
1370 string_type __digits(__ws);
1371 return this->do_put(__s, __intl, __io, __fill, __digits);
1374 template<typename _CharT, typename _OutIter>
1376 money_put<_CharT, _OutIter>::
1377 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1378 const string_type& __digits) const
1380 typedef typename string_type::size_type size_type;
1381 typedef money_base::part part;
1383 const locale __loc = __io.getloc();
1384 const size_type __width = static_cast<size_type>(__io.width());
1386 // These contortions are quite unfortunate.
1387 typedef moneypunct<_CharT, true> __money_true;
1388 typedef moneypunct<_CharT, false> __money_false;
1389 const __money_true& __mpt = use_facet<__money_true>(__loc);
1390 const __money_false& __mpf = use_facet<__money_false>(__loc);
1391 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1393 // Determine if negative or positive formats are to be used, and
1394 // discard leading negative_sign if it is present.
1395 const char_type* __beg = __digits.data();
1396 const char_type* __end = __beg + __digits.size();
1397 money_base::pattern __p;
1399 if (*__beg != __ctype.widen('-'))
1401 __p = __intl ? __mpt.pos_format() : __mpf.pos_format();
1402 __sign = __intl ? __mpt.positive_sign() : __mpf.positive_sign();
1406 __p = __intl ? __mpt.neg_format() : __mpf.neg_format();
1407 __sign = __intl ? __mpt.negative_sign() : __mpf.negative_sign();
1411 // Look for valid numbers in the current ctype facet within input digits.
1412 __end = __ctype.scan_not(ctype_base::digit, __beg, __end);
1415 // Assume valid input, and attempt to format.
1416 // Break down input numbers into base components, as follows:
1417 // final_value = grouped units + (decimal point) + (digits)
1419 string_type __value;
1420 const string_type __symbol = __intl ? __mpt.curr_symbol()
1421 : __mpf.curr_symbol();
1423 // Deal with decimal point, decimal digits.
1424 const int __frac = __intl ? __mpt.frac_digits()
1425 : __mpf.frac_digits();
1428 const char_type __d = __intl ? __mpt.decimal_point()
1429 : __mpf.decimal_point();
1430 if (__end - __beg >= __frac)
1432 __value = string_type(__end - __frac, __end);
1433 __value.insert(__value.begin(), __d);
1438 // Have to pad zeros in the decimal position.
1439 __value = string_type(__beg, __end);
1440 const int __paddec = __frac - (__end - __beg);
1441 const char_type __zero = __ctype.widen('0');
1442 __value.insert(__value.begin(), __paddec, __zero);
1443 __value.insert(__value.begin(), __d);
1448 // Add thousands separators to non-decimal digits, per
1452 const string __grouping = __intl ? __mpt.grouping()
1454 if (__grouping.size())
1456 const char_type __sep = __intl ? __mpt.thousands_sep()
1457 : __mpf.thousands_sep();
1458 const char* __gbeg = __grouping.data();
1459 const char* __gend = __gbeg + __grouping.size();
1460 const int __n = (__end - __beg) * 2;
1462 static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n));
1463 _CharT* __ws_end = std::__add_grouping(__ws2, __sep, __gbeg,
1464 __gend, __beg, __end);
1465 __value.insert(0, __ws2, __ws_end - __ws2);
1468 __value.insert(0, string_type(__beg, __end));
1471 // Calculate length of resulting string.
1472 const ios_base::fmtflags __f = __io.flags() & ios_base::adjustfield;
1473 size_type __len = __value.size() + __sign.size();
1474 __len += (__io.flags() & ios_base::showbase) ? __symbol.size() : 0;
1475 const bool __testipad = __f == ios_base::internal && __len < __width;
1477 // Fit formatted digits into the required pattern.
1478 for (int __i = 0; __i < 4; ++__i)
1480 const part __which = static_cast<part>(__p.field[__i]);
1483 case money_base::symbol:
1484 if (__io.flags() & ios_base::showbase)
1487 case money_base::sign:
1488 // Sign might not exist, or be more than one
1489 // charater long. In that case, add in the rest
1494 case money_base::value:
1497 case money_base::space:
1498 // At least one space is required, but if internal
1499 // formatting is required, an arbitrary number of
1500 // fill spaces will be necessary.
1502 __res += string_type(__width - __len, __fill);
1504 __res += __ctype.widen(__fill);
1506 case money_base::none:
1508 __res += string_type(__width - __len, __fill);
1513 // Special case of multi-part sign parts.
1514 if (__sign.size() > 1)
1515 __res += string_type(__sign.begin() + 1, __sign.end());
1517 // Pad, if still necessary.
1518 __len = __res.size();
1519 if (__width > __len)
1521 if (__f == ios_base::left)
1523 __res.append(__width - __len, __fill);
1526 __res.insert(0, string_type(__width - __len, __fill));
1530 // Write resulting, fully-formatted string to output iterator.
1531 __s = std::__write(__s, __res.data(), __len);
1538 // NB: Not especially useful. Without an ios_base object or some
1539 // kind of locale reference, we are left clawing at the air where
1540 // the side of the mountain used to be...
1541 template<typename _CharT, typename _InIter>
1542 time_base::dateorder
1543 time_get<_CharT, _InIter>::do_date_order() const
1544 { return time_base::no_order; }
1546 template<typename _CharT, typename _InIter>
1548 time_get<_CharT, _InIter>::
1549 _M_extract_via_format(iter_type& __beg, iter_type& __end, ios_base& __io,
1550 ios_base::iostate& __err, tm* __tm,
1551 const _CharT* __format) const
1553 const locale __loc = __io.getloc();
1554 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1555 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1556 const size_t __len = char_traits<_CharT>::length(__format);
1558 for (size_t __i = 0; __beg != __end && __i < __len && !__err; ++__i)
1560 if (__ctype.narrow(__format[__i], 0) == '%')
1562 // Verify valid formatting code, attempt to extract.
1563 char __c = __ctype.narrow(__format[++__i], 0);
1565 if (__c == 'E' || __c == 'O')
1566 __c = __ctype.narrow(__format[++__i], 0);
1572 // Abbreviated weekday name [tm_wday]
1573 const char_type* __days1[7];
1574 __tp._M_days_abbreviated(__days1);
1575 _M_extract_name(__beg, __end, __tm->tm_wday, __days1, 7,
1579 // Weekday name [tm_wday].
1580 const char_type* __days2[7];
1581 __tp._M_days(__days2);
1582 _M_extract_name(__beg, __end, __tm->tm_wday, __days2, 7,
1587 // Abbreviated month name [tm_mon]
1588 const char_type* __months1[12];
1589 __tp._M_months_abbreviated(__months1);
1590 _M_extract_name(__beg, __end, __tm->tm_mon, __months1, 12,
1594 // Month name [tm_mon].
1595 const char_type* __months2[12];
1596 __tp._M_months(__months2);
1597 _M_extract_name(__beg, __end, __tm->tm_mon, __months2, 12,
1601 // Default time and date representation.
1602 const char_type* __dt[2];
1603 __tp._M_date_time_formats(__dt);
1604 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1608 // Day [01, 31]. [tm_mday]
1609 _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
1613 // Day [1, 31], with single digits preceded by
1615 if (__ctype.is(ctype_base::space, *__beg))
1616 _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9, 1,
1619 _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31, 2,
1623 // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
1625 __ctype.widen(__cs, __cs + 9, __wcs);
1626 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1630 // Hour [00, 23]. [tm_hour]
1631 _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
1635 // Hour [01, 12]. [tm_hour]
1636 _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
1640 // Month [01, 12]. [tm_mon]
1641 _M_extract_num(__beg, __end, __mem, 1, 12, 2, __ctype,
1644 __tm->tm_mon = __mem - 1;
1647 // Minute [00, 59]. [tm_min]
1648 _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
1652 if (__ctype.narrow(*__beg, 0) == '\n')
1655 __err |= ios_base::failbit;
1658 // Equivalent to (%H:%M).
1660 __ctype.widen(__cs, __cs + 6, __wcs);
1661 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1666 _M_extract_num(__beg, __end, __tm->tm_sec, 0, 59, 2,
1670 if (__ctype.narrow(*__beg, 0) == '\t')
1673 __err |= ios_base::failbit;
1676 // Equivalent to (%H:%M:%S).
1678 __ctype.widen(__cs, __cs + 9, __wcs);
1679 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1684 const char_type* __dates[2];
1685 __tp._M_date_formats(__dates);
1686 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1691 const char_type* __times[2];
1692 __tp._M_time_formats(__times);
1693 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1698 // Two digit year. [tm_year]
1699 _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2,
1703 // Year [1900). [tm_year]
1704 _M_extract_num(__beg, __end, __mem, 0, 9999, 4,
1707 __tm->tm_year = __mem - 1900;
1711 if (__ctype.is(ctype_base::upper, *__beg))
1714 _M_extract_name(__beg, __end, __tmp,
1715 __timepunct_cache<_CharT>::_S_timezones,
1716 14, __ctype, __err);
1718 // GMT requires special effort.
1719 if (__beg != __end && !__err && __tmp == 0
1720 && (*__beg == __ctype.widen('-')
1721 || *__beg == __ctype.widen('+')))
1723 _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
1725 _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
1730 __err |= ios_base::failbit;
1734 __err |= ios_base::failbit;
1739 // Verify format and input match, extract and discard.
1740 if (__format[__i] == *__beg)
1743 __err |= ios_base::failbit;
1748 template<typename _CharT, typename _InIter>
1750 time_get<_CharT, _InIter>::
1751 _M_extract_num(iter_type& __beg, iter_type& __end, int& __member,
1752 int __min, int __max, size_t __len,
1753 const ctype<_CharT>& __ctype,
1754 ios_base::iostate& __err) const
1756 // As-is works for __len = 1, 2, 4, the values actually used.
1757 int __mult = __len == 2 ? 10 : (__len == 4 ? 1000 : 1);
1762 for (; __beg != __end && __i < __len; ++__beg, ++__i)
1764 const char __c = __ctype.narrow(*__beg, '*');
1765 if (__c >= '0' && __c <= '9')
1767 __value = __value * 10 + (__c - '0');
1768 const int __valuec = __value * __mult;
1769 if (__valuec > __max || __valuec + __mult < __min)
1779 __err |= ios_base::failbit;
1783 // All elements in __names are unique.
1784 template<typename _CharT, typename _InIter>
1786 time_get<_CharT, _InIter>::
1787 _M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
1788 const _CharT** __names, size_t __indexlen,
1789 const ctype<_CharT>& __ctype,
1790 ios_base::iostate& __err) const
1792 typedef char_traits<_CharT> __traits_type;
1793 int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)
1795 size_t __nmatches = 0;
1797 bool __testvalid = true;
1798 const char_type* __name;
1800 // Look for initial matches.
1801 // NB: Some of the locale data is in the form of all lowercase
1802 // names, and some is in the form of initially-capitalized
1803 // names. Look for both.
1806 const char_type __c = *__beg;
1807 for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
1808 if (__c == __names[__i1][0]
1809 || __c == __ctype.toupper(__names[__i1][0]))
1810 __matches[__nmatches++] = __i1;
1813 while (__nmatches > 1)
1815 // Find smallest matching string.
1816 size_t __minlen = 10;
1817 for (size_t __i2 = 0; __i2 < __nmatches; ++__i2)
1818 __minlen = std::min(__minlen,
1819 __traits_type::length(__names[__matches[__i2]]));
1821 if (__pos < __minlen && __beg != __end)
1824 for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)
1826 __name = __names[__matches[__i3]];
1827 if (__name[__pos] != *__beg)
1828 __matches[__i3] = __matches[--__nmatches];
1835 if (__nmatches == 1)
1837 // If there was only one match, the first compare is redundant.
1844 // Make sure found name is completely extracted.
1845 __name = __names[__matches[0]];
1846 const size_t __len = __traits_type::length(__name);
1847 while (__pos < __len && __beg != __end && __name[__pos] == *__beg)
1851 __member = __matches[0];
1853 __testvalid = false;
1856 __testvalid = false;
1858 __err |= ios_base::failbit;
1861 template<typename _CharT, typename _InIter>
1863 time_get<_CharT, _InIter>::
1864 do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
1865 ios_base::iostate& __err, tm* __tm) const
1868 const char* __cs = "%X";
1869 const locale __loc = __io.getloc();
1870 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1871 __ctype.widen(__cs, __cs + 3, __wcs);
1872 _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
1874 __err |= ios_base::eofbit;
1878 template<typename _CharT, typename _InIter>
1880 time_get<_CharT, _InIter>::
1881 do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
1882 ios_base::iostate& __err, tm* __tm) const
1885 const char* __cs = "%x";
1886 const locale __loc = __io.getloc();
1887 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1888 __ctype.widen(__cs, __cs + 3, __wcs);
1889 _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
1891 __err |= ios_base::eofbit;
1895 template<typename _CharT, typename _InIter>
1897 time_get<_CharT, _InIter>::
1898 do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
1899 ios_base::iostate& __err, tm* __tm) const
1901 typedef char_traits<_CharT> __traits_type;
1902 const locale __loc = __io.getloc();
1903 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1904 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1905 const char_type* __days[7];
1906 __tp._M_days_abbreviated(__days);
1908 _M_extract_name(__beg, __end, __tmpwday, __days, 7, __ctype, __err);
1910 // Check to see if non-abbreviated name exists, and extract.
1911 // NB: Assumes both _M_days and _M_days_abbreviated organized in
1912 // exact same order, first to last, such that the resulting
1913 // __days array with the same index points to a day, and that
1914 // day's abbreviated form.
1915 // NB: Also assumes that an abbreviated name is a subset of the name.
1918 size_t __pos = __traits_type::length(__days[__tmpwday]);
1919 __tp._M_days(__days);
1920 const char_type* __name = __days[__tmpwday];
1921 if (__name[__pos] == *__beg)
1923 // Extract the rest of it.
1924 const size_t __len = __traits_type::length(__name);
1925 while (__pos < __len && __beg != __end
1926 && __name[__pos] == *__beg)
1929 __err |= ios_base::failbit;
1932 __tm->tm_wday = __tmpwday;
1935 __err |= ios_base::eofbit;
1939 template<typename _CharT, typename _InIter>
1941 time_get<_CharT, _InIter>::
1942 do_get_monthname(iter_type __beg, iter_type __end,
1943 ios_base& __io, ios_base::iostate& __err, tm* __tm) const
1945 typedef char_traits<_CharT> __traits_type;
1946 const locale __loc = __io.getloc();
1947 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1948 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1949 const char_type* __months[12];
1950 __tp._M_months_abbreviated(__months);
1952 _M_extract_name(__beg, __end, __tmpmon, __months, 12, __ctype, __err);
1954 // Check to see if non-abbreviated name exists, and extract.
1955 // NB: Assumes both _M_months and _M_months_abbreviated organized in
1956 // exact same order, first to last, such that the resulting
1957 // __months array with the same index points to a month, and that
1958 // month's abbreviated form.
1959 // NB: Also assumes that an abbreviated name is a subset of the name.
1962 size_t __pos = __traits_type::length(__months[__tmpmon]);
1963 __tp._M_months(__months);
1964 const char_type* __name = __months[__tmpmon];
1965 if (__name[__pos] == *__beg)
1967 // Extract the rest of it.
1968 const size_t __len = __traits_type::length(__name);
1969 while (__pos < __len && __beg != __end
1970 && __name[__pos] == *__beg)
1973 __err |= ios_base::failbit;
1976 __tm->tm_mon = __tmpmon;
1980 __err |= ios_base::eofbit;
1984 template<typename _CharT, typename _InIter>
1986 time_get<_CharT, _InIter>::
1987 do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
1988 ios_base::iostate& __err, tm* __tm) const
1990 const locale __loc = __io.getloc();
1991 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1995 for (; __beg != __end && __i < 4; ++__beg, ++__i)
1997 const char __c = __ctype.narrow(*__beg, '*');
1998 if (__c >= '0' && __c <= '9')
1999 __value = __value * 10 + (__c - '0');
2003 if (__i == 2 || __i == 4)
2004 __tm->tm_year = __i == 2 ? __value : __value - 1900;
2006 __err |= ios_base::failbit;
2008 __err |= ios_base::eofbit;
2012 template<typename _CharT, typename _OutIter>
2014 time_put<_CharT, _OutIter>::
2015 put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
2016 const _CharT* __beg, const _CharT* __end) const
2018 const locale __loc = __io.getloc();
2019 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
2020 for (; __beg != __end; ++__beg)
2021 if (__ctype.narrow(*__beg, 0) != '%')
2026 else if (++__beg != __end)
2030 const char __c = __ctype.narrow(*__beg, 0);
2031 if (__c != 'E' && __c != 'O')
2033 else if (++__beg != __end)
2036 __format = __ctype.narrow(*__beg, 0);
2040 __s = this->do_put(__s, __io, __fill, __tm,
2048 template<typename _CharT, typename _OutIter>
2050 time_put<_CharT, _OutIter>::
2051 do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm,
2052 char __format, char __mod) const
2054 const locale __loc = __io.getloc();
2055 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
2056 __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
2058 // NB: This size is arbitrary. Should this be a data member,
2059 // initialized at construction?
2060 const size_t __maxlen = 64;
2061 char_type* __res = static_cast<char_type*>(__builtin_alloca(sizeof(char_type)
2064 // NB: In IEE 1003.1-200x, and perhaps other locale models, it
2065 // is possible that the format character will be longer than one
2066 // character. Possibilities include 'E' or 'O' followed by a
2067 // format character: if __mod is not the default argument, assume
2068 // it's a valid modifier.
2070 __fmt[0] = __ctype.widen('%');
2073 __fmt[1] = __format;
2074 __fmt[2] = char_type();
2079 __fmt[2] = __format;
2080 __fmt[3] = char_type();
2083 __tp._M_put(__res, __maxlen, __fmt, __tm);
2085 // Write resulting, fully-formatted string to output iterator.
2086 return std::__write(__s, __res, char_traits<char_type>::length(__res));
2090 // Generic version does nothing.
2091 template<typename _CharT>
2093 collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const
2096 // Generic version does nothing.
2097 template<typename _CharT>
2099 collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const
2102 template<typename _CharT>
2105 do_compare(const _CharT* __lo1, const _CharT* __hi1,
2106 const _CharT* __lo2, const _CharT* __hi2) const
2108 // strcoll assumes zero-terminated strings so we make a copy
2109 // and then put a zero at the end.
2110 const string_type __one(__lo1, __hi1);
2111 const string_type __two(__lo2, __hi2);
2113 const _CharT* __p = __one.c_str();
2114 const _CharT* __pend = __one.data() + __one.length();
2115 const _CharT* __q = __two.c_str();
2116 const _CharT* __qend = __two.data() + __two.length();
2118 // strcoll stops when it sees a nul character so we break
2119 // the strings into zero-terminated substrings and pass those
2123 const int __res = _M_compare(__p, __q);
2127 __p += char_traits<_CharT>::length(__p);
2128 __q += char_traits<_CharT>::length(__q);
2129 if (__p == __pend && __q == __qend)
2131 else if (__p == __pend)
2133 else if (__q == __qend)
2141 template<typename _CharT>
2142 typename collate<_CharT>::string_type
2144 do_transform(const _CharT* __lo, const _CharT* __hi) const
2146 // strxfrm assumes zero-terminated strings so we make a copy
2147 string_type __str(__lo, __hi);
2149 const _CharT* __p = __str.c_str();
2150 const _CharT* __pend = __str.data() + __str.length();
2152 size_t __len = (__hi - __lo) * 2;
2156 // strxfrm stops when it sees a nul character so we break
2157 // the string into zero-terminated substrings and pass those
2161 // First try a buffer perhaps big enough.
2163 static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
2164 size_t __res = _M_transform(__c, __p, __len);
2165 // If the buffer was not large enough, try again with the
2170 __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
2172 __res = _M_transform(__c, __p, __res + 1);
2175 __ret.append(__c, __res);
2176 __p += char_traits<_CharT>::length(__p);
2181 __ret.push_back(_CharT());
2185 template<typename _CharT>
2188 do_hash(const _CharT* __lo, const _CharT* __hi) const
2190 unsigned long __val = 0;
2191 for (; __lo < __hi; ++__lo)
2192 __val = *__lo + ((__val << 7) |
2193 (__val >> (numeric_limits<unsigned long>::digits - 7)));
2194 return static_cast<long>(__val);
2197 // Construct correctly padded string, as per 22.2.2.2.2
2199 // __newlen > __oldlen
2200 // __news is allocated for __newlen size
2201 // Used by both num_put and ostream inserters: if __num,
2202 // internal-adjusted objects are padded according to the rules below
2203 // concerning 0[xX] and +-, otherwise, exactly as right-adjusted
2206 // NB: Of the two parameters, _CharT can be deduced from the
2207 // function arguments. The other (_Traits) has to be explicitly specified.
2208 template<typename _CharT, typename _Traits>
2210 __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
2211 _CharT* __news, const _CharT* __olds,
2212 const streamsize __newlen,
2213 const streamsize __oldlen, const bool __num)
2215 const size_t __plen = static_cast<size_t>(__newlen - __oldlen);
2216 const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
2219 if (__adjust == ios_base::left)
2221 _Traits::copy(__news, const_cast<_CharT*>(__olds), __oldlen);
2222 _Traits::assign(__news + __oldlen, __plen, __fill);
2227 if (__adjust == ios_base::internal && __num)
2229 // Pad after the sign, if there is one.
2230 // Pad after 0[xX], if there is one.
2231 // Who came up with these rules, anyway? Jeeze.
2232 const locale& __loc = __io._M_getloc();
2233 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
2234 const _CharT __minus = __ctype.widen('-');
2235 const _CharT __plus = __ctype.widen('+');
2236 const bool __testsign = _Traits::eq(__olds[0], __minus)
2237 || _Traits::eq(__olds[0], __plus);
2239 const bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0])
2240 && (_Traits::eq(__ctype.widen('x'), __olds[1])
2241 || _Traits::eq(__ctype.widen('X'), __olds[1]));
2244 __news[0] = __olds[0];
2245 __news[1] = __olds[1];
2249 else if (__testsign)
2251 __news[0] = __olds[0];
2255 // else Padding first.
2257 _Traits::assign(__news, __plen, __fill);
2258 _Traits::copy(__news + __plen, const_cast<_CharT*>(__olds + __mod),
2262 template<typename _CharT>
2264 __verify_grouping(const basic_string<_CharT>& __grouping,
2265 const basic_string<_CharT>& __grouping_tmp)
2269 const size_t __len = __grouping.size();
2270 const size_t __n = __grouping_tmp.size();
2273 // Parsed number groupings have to match the
2274 // numpunct::grouping string exactly, starting at the
2275 // right-most point of the parsed sequence of elements ...
2276 while (__test && __i < __n - 1)
2277 for (__j = 0; __test && __j < __len && __i < __n - 1; ++__j, ++__i)
2278 __test = __grouping[__j] == __grouping_tmp[__n - __i - 1];
2279 // ... but the last parsed grouping can be <= numpunct
2281 __j == __len ? __j = 0 : __j;
2282 __test &= __grouping[__j] >= __grouping_tmp[__n - __i - 1];
2286 template<typename _CharT>
2288 __add_grouping(_CharT* __s, _CharT __sep,
2289 const char* __gbeg, const char* __gend,
2290 const _CharT* __first, const _CharT* __last)
2292 if (__last - __first > *__gbeg)
2294 const bool __bump = __gbeg + 1 != __gend;
2295 __s = std::__add_grouping(__s, __sep, __gbeg + __bump,
2296 __gend, __first, __last - *__gbeg);
2297 __first = __last - *__gbeg;
2301 *__s++ = *__first++;
2302 while (__first != __last);
2306 // Inhibit implicit instantiations for required instantiations,
2307 // which are defined via explicit instantiations elsewhere.
2308 // NB: This syntax is a GNU extension.
2309 #if _GLIBCXX_EXTERN_TEMPLATE
2310 extern template class moneypunct<char, false>;
2311 extern template class moneypunct<char, true>;
2312 extern template class moneypunct_byname<char, false>;
2313 extern template class moneypunct_byname<char, true>;
2314 extern template class money_get<char>;
2315 extern template class money_put<char>;
2316 extern template class numpunct<char>;
2317 extern template class numpunct_byname<char>;
2318 extern template class num_get<char>;
2319 extern template class num_put<char>;
2320 extern template class __timepunct<char>;
2321 extern template class time_put<char>;
2322 extern template class time_put_byname<char>;
2323 extern template class time_get<char>;
2324 extern template class time_get_byname<char>;
2325 extern template class messages<char>;
2326 extern template class messages_byname<char>;
2327 extern template class ctype_byname<char>;
2328 extern template class codecvt_byname<char, char, mbstate_t>;
2329 extern template class collate<char>;
2330 extern template class collate_byname<char>;
2333 const codecvt<char, char, mbstate_t>&
2334 use_facet<codecvt<char, char, mbstate_t> >(const locale&);
2337 const collate<char>&
2338 use_facet<collate<char> >(const locale&);
2341 const numpunct<char>&
2342 use_facet<numpunct<char> >(const locale&);
2345 const num_put<char>&
2346 use_facet<num_put<char> >(const locale&);
2349 const num_get<char>&
2350 use_facet<num_get<char> >(const locale&);
2353 const moneypunct<char, true>&
2354 use_facet<moneypunct<char, true> >(const locale&);
2357 const moneypunct<char, false>&
2358 use_facet<moneypunct<char, false> >(const locale&);
2361 const money_put<char>&
2362 use_facet<money_put<char> >(const locale&);
2365 const money_get<char>&
2366 use_facet<money_get<char> >(const locale&);
2369 const __timepunct<char>&
2370 use_facet<__timepunct<char> >(const locale&);
2373 const time_put<char>&
2374 use_facet<time_put<char> >(const locale&);
2377 const time_get<char>&
2378 use_facet<time_get<char> >(const locale&);
2381 const messages<char>&
2382 use_facet<messages<char> >(const locale&);
2386 has_facet<ctype<char> >(const locale&);
2390 has_facet<codecvt<char, char, mbstate_t> >(const locale&);
2394 has_facet<collate<char> >(const locale&);
2398 has_facet<numpunct<char> >(const locale&);
2402 has_facet<num_put<char> >(const locale&);
2406 has_facet<num_get<char> >(const locale&);
2410 has_facet<moneypunct<char> >(const locale&);
2414 has_facet<money_put<char> >(const locale&);
2418 has_facet<money_get<char> >(const locale&);
2422 has_facet<__timepunct<char> >(const locale&);
2426 has_facet<time_put<char> >(const locale&);
2430 has_facet<time_get<char> >(const locale&);
2434 has_facet<messages<char> >(const locale&);
2436 #ifdef _GLIBCXX_USE_WCHAR_T
2437 extern template class moneypunct<wchar_t, false>;
2438 extern template class moneypunct<wchar_t, true>;
2439 extern template class moneypunct_byname<wchar_t, false>;
2440 extern template class moneypunct_byname<wchar_t, true>;
2441 extern template class money_get<wchar_t>;
2442 extern template class money_put<wchar_t>;
2443 extern template class numpunct<wchar_t>;
2444 extern template class numpunct_byname<wchar_t>;
2445 extern template class num_get<wchar_t>;
2446 extern template class num_put<wchar_t>;
2447 extern template class __timepunct<wchar_t>;
2448 extern template class time_put<wchar_t>;
2449 extern template class time_put_byname<wchar_t>;
2450 extern template class time_get<wchar_t>;
2451 extern template class time_get_byname<wchar_t>;
2452 extern template class messages<wchar_t>;
2453 extern template class messages_byname<wchar_t>;
2454 extern template class ctype_byname<wchar_t>;
2455 extern template class codecvt_byname<wchar_t, char, mbstate_t>;
2456 extern template class collate<wchar_t>;
2457 extern template class collate_byname<wchar_t>;
2460 const codecvt<wchar_t, char, mbstate_t>&
2461 use_facet<codecvt<wchar_t, char, mbstate_t> >(locale const&);
2464 const collate<wchar_t>&
2465 use_facet<collate<wchar_t> >(const locale&);
2468 const numpunct<wchar_t>&
2469 use_facet<numpunct<wchar_t> >(const locale&);
2472 const num_put<wchar_t>&
2473 use_facet<num_put<wchar_t> >(const locale&);
2476 const num_get<wchar_t>&
2477 use_facet<num_get<wchar_t> >(const locale&);
2480 const moneypunct<wchar_t, true>&
2481 use_facet<moneypunct<wchar_t, true> >(const locale&);
2484 const moneypunct<wchar_t, false>&
2485 use_facet<moneypunct<wchar_t, false> >(const locale&);
2488 const money_put<wchar_t>&
2489 use_facet<money_put<wchar_t> >(const locale&);
2492 const money_get<wchar_t>&
2493 use_facet<money_get<wchar_t> >(const locale&);
2496 const __timepunct<wchar_t>&
2497 use_facet<__timepunct<wchar_t> >(const locale&);
2500 const time_put<wchar_t>&
2501 use_facet<time_put<wchar_t> >(const locale&);
2504 const time_get<wchar_t>&
2505 use_facet<time_get<wchar_t> >(const locale&);
2508 const messages<wchar_t>&
2509 use_facet<messages<wchar_t> >(const locale&);
2513 has_facet<ctype<wchar_t> >(const locale&);
2517 has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
2521 has_facet<collate<wchar_t> >(const locale&);
2525 has_facet<numpunct<wchar_t> >(const locale&);
2529 has_facet<num_put<wchar_t> >(const locale&);
2533 has_facet<num_get<wchar_t> >(const locale&);
2537 has_facet<moneypunct<wchar_t> >(const locale&);
2541 has_facet<money_put<wchar_t> >(const locale&);
2545 has_facet<money_get<wchar_t> >(const locale&);
2549 has_facet<__timepunct<wchar_t> >(const locale&);
2553 has_facet<time_put<wchar_t> >(const locale&);
2557 has_facet<time_get<wchar_t> >(const locale&);
2561 has_facet<messages<wchar_t> >(const locale&);