1 // Locale support -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
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 // Used by both numeric and monetary facets.
154 // Check to make sure that the __grouping_tmp string constructed in
155 // money_get or num_get matches the canonical grouping for a given
157 // __grouping_tmp is parsed L to R
158 // 1,222,444 == __grouping_tmp of "\1\3\3"
159 // __grouping is parsed R to L
160 // 1,222,444 == __grouping of "\3" == "\3\3\3"
162 __verify_grouping(const char* __grouping, size_t __grouping_size,
163 const string& __grouping_tmp);
165 template<typename _CharT, typename _InIter>
167 num_get<_CharT, _InIter>::
168 _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io,
169 ios_base::iostate& __err, string& __xtrc) const
171 typedef char_traits<_CharT> __traits_type;
172 typedef typename numpunct<_CharT>::__cache_type __cache_type;
173 __use_cache<__cache_type> __uc;
174 const locale& __loc = __io._M_getloc();
175 const __cache_type* __lc = __uc(__loc);
176 const _CharT* __lit = __lc->_M_atoms_in;
178 // True if a mantissa is found.
179 bool __found_mantissa = false;
181 // First check for sign.
184 const char_type __c = *__beg;
185 const bool __plus = __traits_type::eq(__c, __lit[_S_iplus]);
186 if ((__plus || __traits_type::eq(__c, __lit[_S_iminus]))
187 && (!__lc->_M_use_grouping
188 || !__traits_type::eq(__c, __lc->_M_thousands_sep))
189 && !__traits_type::eq(__c, __lc->_M_decimal_point))
191 __xtrc += __plus ? '+' : '-';
196 // Next, look for leading zeros.
197 while (__beg != __end)
199 const char_type __c = *__beg;
200 if (__lc->_M_use_grouping
201 && __traits_type::eq(__c, __lc->_M_thousands_sep)
202 || __traits_type::eq(__c, __lc->_M_decimal_point))
204 else if (__traits_type::eq(__c, __lit[_S_izero]))
206 if (!__found_mantissa)
209 __found_mantissa = true;
217 // Only need acceptable digits for floating point numbers.
218 bool __found_dec = false;
219 bool __found_sci = false;
220 string __found_grouping;
221 if (__lc->_M_use_grouping)
222 __found_grouping.reserve(32);
224 const char_type* __lit_zero = __lit + _S_izero;
225 const char_type* __q;
226 while (__beg != __end)
228 // According to 22.2.2.1.2, p8-9, first look for thousands_sep
229 // and decimal_point.
230 const char_type __c = *__beg;
231 if (__lc->_M_use_grouping
232 && __traits_type::eq(__c, __lc->_M_thousands_sep))
234 if (!__found_dec && !__found_sci)
236 // NB: Thousands separator at the beginning of a string
237 // is a no-no, as is two consecutive thousands separators.
240 __found_grouping += static_cast<char>(__sep_pos);
246 __err |= ios_base::failbit;
253 else if (__traits_type::eq(__c, __lc->_M_decimal_point))
255 if (!__found_dec && !__found_sci)
257 // If no grouping chars are seen, no grouping check
258 // is applied. Therefore __found_grouping is adjusted
259 // only if decimal_point comes after some thousands_sep.
260 if (__found_grouping.size())
261 __found_grouping += static_cast<char>(__sep_pos);
269 else if (__q = __traits_type::find(__lit_zero, 10, __c))
271 __xtrc += _S_atoms_in[__q - __lit];
272 __found_mantissa = true;
276 else if ((__traits_type::eq(__c, __lit[_S_ie])
277 || __traits_type::eq(__c, __lit[_S_iE]))
278 && __found_mantissa && !__found_sci)
280 // Scientific notation.
281 if (__found_grouping.size() && !__found_dec)
282 __found_grouping += static_cast<char>(__sep_pos);
286 // Remove optional plus or minus sign, if they exist.
287 if (++__beg != __end)
289 const bool __plus = __traits_type::eq(*__beg,
291 if ((__plus || __traits_type::eq(*__beg, __lit[_S_iminus]))
292 && (!__lc->_M_use_grouping
293 || !__traits_type::eq(*__beg, __lc->_M_thousands_sep))
294 && !__traits_type::eq(*__beg, __lc->_M_decimal_point))
296 __xtrc += __plus ? '+' : '-';
302 // Not a valid input item.
306 // Digit grouping is checked. If grouping and found_grouping don't
307 // match, then get very very upset, and set failbit.
308 if (__found_grouping.size())
310 // Add the ending grouping if a decimal or 'e'/'E' wasn't found.
311 if (!__found_dec && !__found_sci)
312 __found_grouping += static_cast<char>(__sep_pos);
314 if (!std::__verify_grouping(__lc->_M_grouping, __lc->_M_grouping_size,
316 __err |= ios_base::failbit;
321 __err |= ios_base::eofbit;
325 template<typename _CharT, typename _InIter>
326 template<typename _ValueT>
328 num_get<_CharT, _InIter>::
329 _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
330 ios_base::iostate& __err, _ValueT& __v) const
332 typedef char_traits<_CharT> __traits_type;
333 typedef typename numpunct<_CharT>::__cache_type __cache_type;
334 __use_cache<__cache_type> __uc;
335 const locale& __loc = __io._M_getloc();
336 const __cache_type* __lc = __uc(__loc);
337 const _CharT* __lit = __lc->_M_atoms_in;
339 // NB: Iff __basefield == 0, __base can change based on contents.
340 const ios_base::fmtflags __basefield = __io.flags()
341 & ios_base::basefield;
342 const bool __oct = __basefield == ios_base::oct;
343 int __base = __oct ? 8 : (__basefield == ios_base::hex ? 16 : 10);
345 // True if numeric digits are found.
346 bool __found_num = false;
348 // First check for sign.
349 bool __negative = false;
352 const char_type __c = *__beg;
353 if (numeric_limits<_ValueT>::is_signed)
354 __negative = __traits_type::eq(__c, __lit[_S_iminus]);
355 if ((__negative || __traits_type::eq(__c, __lit[_S_iplus]))
356 && (!__lc->_M_use_grouping
357 || !__traits_type::eq(__c, __lc->_M_thousands_sep))
358 && !__traits_type::eq(__c, __lc->_M_decimal_point))
362 // Next, look for leading zeros and check required digits
364 while (__beg != __end)
366 const char_type __c = *__beg;
367 if (__lc->_M_use_grouping
368 && __traits_type::eq(__c, __lc->_M_thousands_sep)
369 || __traits_type::eq(__c, __lc->_M_decimal_point))
371 else if (__traits_type::eq(__c, __lit[_S_izero])
372 && (!__found_num || __base == 10))
377 else if (__found_num)
379 if (__traits_type::eq(__c, __lit[_S_ix])
380 || __traits_type::eq(__c, __lit[_S_iX]))
382 if (__basefield == 0)
390 else if (__basefield == 0)
398 // At this point, base is determined. If not hex, only allow
399 // base digits as valid input.
400 const size_t __len = __base == 16 ? _S_iend - _S_izero : __base;
403 string __found_grouping;
404 if (__lc->_M_use_grouping)
405 __found_grouping.reserve(32);
407 bool __overflow = false;
408 _ValueT __result = 0;
409 const char_type* __lit_zero = __lit + _S_izero;
410 const char_type* __q;
413 const _ValueT __min = numeric_limits<_ValueT>::min() / __base;
414 for (; __beg != __end; ++__beg)
416 // According to 22.2.2.1.2, p8-9, first look for thousands_sep
417 // and decimal_point.
418 const char_type __c = *__beg;
419 if (__lc->_M_use_grouping
420 && __traits_type::eq(__c, __lc->_M_thousands_sep))
422 // NB: Thousands separator at the beginning of a string
423 // is a no-no, as is two consecutive thousands separators.
426 __found_grouping += static_cast<char>(__sep_pos);
431 __err |= ios_base::failbit;
435 else if (__traits_type::eq(__c, __lc->_M_decimal_point))
437 else if (__q = __traits_type::find(__lit_zero, __len, __c))
439 int __digit = __q - __lit_zero;
442 if (__result < __min)
446 const _ValueT __new_result = __result * __base
448 __overflow |= __new_result > __result;
449 __result = __new_result;
455 // Not a valid input item.
461 const _ValueT __max = numeric_limits<_ValueT>::max() / __base;
462 for (; __beg != __end; ++__beg)
464 const char_type __c = *__beg;
465 if (__lc->_M_use_grouping
466 && __traits_type::eq(__c, __lc->_M_thousands_sep))
470 __found_grouping += static_cast<char>(__sep_pos);
475 __err |= ios_base::failbit;
479 else if (__traits_type::eq(__c, __lc->_M_decimal_point))
481 else if (__q = __traits_type::find(__lit_zero, __len, __c))
483 int __digit = __q - __lit_zero;
486 if (__result > __max)
490 const _ValueT __new_result = __result * __base
492 __overflow |= __new_result < __result;
493 __result = __new_result;
503 // Digit grouping is checked. If grouping and found_grouping don't
504 // match, then get very very upset, and set failbit.
505 if (__found_grouping.size())
507 // Add the ending grouping.
508 __found_grouping += static_cast<char>(__sep_pos);
510 if (!std::__verify_grouping(__lc->_M_grouping,
511 __lc->_M_grouping_size,
513 __err |= ios_base::failbit;
516 if (!(__err & ios_base::failbit) && !__overflow
520 __err |= ios_base::failbit;
523 __err |= ios_base::eofbit;
527 // _GLIBCXX_RESOLVE_LIB_DEFECTS
528 // 17. Bad bool parsing
529 template<typename _CharT, typename _InIter>
531 num_get<_CharT, _InIter>::
532 do_get(iter_type __beg, iter_type __end, ios_base& __io,
533 ios_base::iostate& __err, bool& __v) const
535 if (!(__io.flags() & ios_base::boolalpha))
537 // Parse bool values as long.
538 // NB: We can't just call do_get(long) here, as it might
539 // refer to a derived class.
541 __beg = _M_extract_int(__beg, __end, __io, __err, __l);
542 if (__l == 0 || __l == 1)
545 __err |= ios_base::failbit;
549 // Parse bool values as alphanumeric.
550 typedef char_traits<_CharT> __traits_type;
551 typedef typename numpunct<_CharT>::__cache_type __cache_type;
552 __use_cache<__cache_type> __uc;
553 const locale& __loc = __io._M_getloc();
554 const __cache_type* __lc = __uc(__loc);
559 for (__n = 0; __beg != __end; ++__n, ++__beg)
562 if (__n < __lc->_M_falsename_size)
563 __testf = __traits_type::eq(*__beg, __lc->_M_falsename[__n]);
568 if (__n < __lc->_M_truename_size)
569 __testt = __traits_type::eq(*__beg, __lc->_M_truename[__n]);
573 if (!__testf && !__testt)
576 if (__testf && __n == __lc->_M_falsename_size)
578 else if (__testt && __n == __lc->_M_truename_size)
581 __err |= ios_base::failbit;
584 __err |= ios_base::eofbit;
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& __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 short& __v) const
601 { return _M_extract_int(__beg, __end, __io, __err, __v); }
603 template<typename _CharT, typename _InIter>
605 num_get<_CharT, _InIter>::
606 do_get(iter_type __beg, iter_type __end, ios_base& __io,
607 ios_base::iostate& __err, unsigned int& __v) const
608 { return _M_extract_int(__beg, __end, __io, __err, __v); }
610 template<typename _CharT, typename _InIter>
612 num_get<_CharT, _InIter>::
613 do_get(iter_type __beg, iter_type __end, ios_base& __io,
614 ios_base::iostate& __err, unsigned long& __v) const
615 { return _M_extract_int(__beg, __end, __io, __err, __v); }
617 #ifdef _GLIBCXX_USE_LONG_LONG
618 template<typename _CharT, typename _InIter>
620 num_get<_CharT, _InIter>::
621 do_get(iter_type __beg, iter_type __end, ios_base& __io,
622 ios_base::iostate& __err, long long& __v) const
623 { return _M_extract_int(__beg, __end, __io, __err, __v); }
625 template<typename _CharT, typename _InIter>
627 num_get<_CharT, _InIter>::
628 do_get(iter_type __beg, iter_type __end, ios_base& __io,
629 ios_base::iostate& __err, unsigned long long& __v) const
630 { return _M_extract_int(__beg, __end, __io, __err, __v); }
633 template<typename _CharT, typename _InIter>
635 num_get<_CharT, _InIter>::
636 do_get(iter_type __beg, iter_type __end, ios_base& __io,
637 ios_base::iostate& __err, float& __v) const
641 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
642 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
646 template<typename _CharT, typename _InIter>
648 num_get<_CharT, _InIter>::
649 do_get(iter_type __beg, iter_type __end, ios_base& __io,
650 ios_base::iostate& __err, double& __v) const
654 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
655 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
659 template<typename _CharT, typename _InIter>
661 num_get<_CharT, _InIter>::
662 do_get(iter_type __beg, iter_type __end, ios_base& __io,
663 ios_base::iostate& __err, long double& __v) const
667 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
668 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
672 template<typename _CharT, typename _InIter>
674 num_get<_CharT, _InIter>::
675 do_get(iter_type __beg, iter_type __end, ios_base& __io,
676 ios_base::iostate& __err, void*& __v) const
678 // Prepare for hex formatted input.
679 typedef ios_base::fmtflags fmtflags;
680 const fmtflags __fmt = __io.flags();
681 __io.flags(__fmt & ~ios_base::basefield | ios_base::hex);
684 __beg = _M_extract_int(__beg, __end, __io, __err, __ul);
686 // Reset from hex formatted input.
689 if (!(__err & ios_base::failbit))
690 __v = reinterpret_cast<void*>(__ul);
692 __err |= ios_base::failbit;
696 // For use by integer and floating-point types after they have been
697 // converted into a char_type string.
698 template<typename _CharT, typename _OutIter>
700 num_put<_CharT, _OutIter>::
701 _M_pad(_CharT __fill, streamsize __w, ios_base& __io,
702 _CharT* __new, const _CharT* __cs, int& __len) const
704 // [22.2.2.2.2] Stage 3.
705 // If necessary, pad.
706 __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, __cs,
708 __len = static_cast<int>(__w);
711 // Forwarding functions to peel signed from unsigned integer types.
712 template<typename _CharT>
714 __int_to_char(_CharT* __bufend, long __v, const _CharT* __lit,
715 ios_base::fmtflags __flags)
717 unsigned long __ul = static_cast<unsigned long>(__v);
724 return __int_to_char(__bufend, __ul, __lit, __flags, __neg);
727 template<typename _CharT>
729 __int_to_char(_CharT* __bufend, unsigned long __v, const _CharT* __lit,
730 ios_base::fmtflags __flags)
731 { return __int_to_char(__bufend, __v, __lit, __flags, false); }
733 #ifdef _GLIBCXX_USE_LONG_LONG
734 template<typename _CharT>
736 __int_to_char(_CharT* __bufend, long long __v, const _CharT* __lit,
737 ios_base::fmtflags __flags)
739 unsigned long long __ull = static_cast<unsigned long long>(__v);
746 return __int_to_char(__bufend, __ull, __lit, __flags, __neg);
749 template<typename _CharT>
751 __int_to_char(_CharT* __bufend, unsigned long long __v, const _CharT* __lit,
752 ios_base::fmtflags __flags)
753 { return __int_to_char(__bufend, __v, __lit, __flags, false); }
756 template<typename _CharT, typename _ValueT>
758 __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit,
759 ios_base::fmtflags __flags, bool __neg)
761 // Don't write base if already 0.
762 const bool __showbase = (__flags & ios_base::showbase) && __v;
763 const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
764 _CharT* __buf = __bufend - 1;
766 if (__builtin_expect(__basefield != ios_base::oct &&
767 __basefield != ios_base::hex, true))
772 *__buf-- = __lit[(__v % 10) + __num_base::_S_odigits];
777 *__buf-- = __lit[__num_base::_S_ominus];
778 else if (__flags & ios_base::showpos)
779 *__buf-- = __lit[__num_base::_S_oplus];
781 else if (__basefield == ios_base::oct)
786 *__buf-- = __lit[(__v & 0x7) + __num_base::_S_odigits];
791 *__buf-- = __lit[__num_base::_S_odigits];
796 const bool __uppercase = __flags & ios_base::uppercase;
797 const int __case_offset = __uppercase ? __num_base::_S_oudigits
798 : __num_base::_S_odigits;
801 *__buf-- = __lit[(__v & 0xf) + __case_offset];
808 *__buf-- = __lit[__num_base::_S_ox + __uppercase];
810 *__buf-- = __lit[__num_base::_S_odigits];
813 return __bufend - __buf - 1;
816 template<typename _CharT, typename _OutIter>
818 num_put<_CharT, _OutIter>::
819 _M_group_int(const char* __grouping, size_t __grouping_size, _CharT __sep,
820 ios_base& __io, _CharT* __new, _CharT* __cs, int& __len) const
822 // By itself __add_grouping cannot deal correctly with __cs when
823 // ios::showbase is set and ios_base::oct || ios_base::hex.
824 // Therefore we take care "by hand" of the initial 0, 0x or 0X.
825 // However, remember that the latter do not occur if the number
826 // printed is '0' (__len == 1).
827 streamsize __off = 0;
828 const ios_base::fmtflags __basefield = __io.flags()
829 & ios_base::basefield;
830 if ((__io.flags() & ios_base::showbase) && __len > 1)
831 if (__basefield == ios_base::oct)
836 else if (__basefield == ios_base::hex)
843 __p = std::__add_grouping(__new + __off, __sep, __grouping,
844 __grouping_size, __cs + __off,
849 template<typename _CharT, typename _OutIter>
850 template<typename _ValueT>
852 num_put<_CharT, _OutIter>::
853 _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
856 typedef typename numpunct<_CharT>::__cache_type __cache_type;
857 __use_cache<__cache_type> __uc;
858 const locale& __loc = __io._M_getloc();
859 const __cache_type* __lc = __uc(__loc);
860 const _CharT* __lit = __lc->_M_atoms_out;
862 // Long enough to hold hex, dec, and octal representations.
863 const int __ilen = 4 * sizeof(_ValueT);
864 _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
867 // [22.2.2.2.2] Stage 1, numeric conversion to character.
868 // Result is returned right-justified in the buffer.
870 __len = __int_to_char(__cs + __ilen, __v, __lit, __io.flags());
871 __cs += __ilen - __len;
873 // Add grouping, if necessary.
874 if (__lc->_M_use_grouping)
876 // Grouping can add (almost) as many separators as the
877 // number of digits, but no more.
878 _CharT* __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
880 _M_group_int(__lc->_M_grouping, __lc->_M_grouping_size,
881 __lc->_M_thousands_sep, __io, __cs2, __cs, __len);
886 const streamsize __w = __io.width();
887 if (__w > static_cast<streamsize>(__len))
889 _CharT* __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
891 _M_pad(__fill, __w, __io, __cs3, __cs, __len);
896 // [22.2.2.2.2] Stage 4.
897 // Write resulting, fully-formatted string to output iterator.
898 return std::__write(__s, __cs, __len);
901 template<typename _CharT, typename _OutIter>
903 num_put<_CharT, _OutIter>::
904 _M_group_float(const char* __grouping, size_t __grouping_size,
905 _CharT __sep, const _CharT* __p, _CharT* __new,
906 _CharT* __cs, int& __len) const
908 // _GLIBCXX_RESOLVE_LIB_DEFECTS
909 // 282. What types does numpunct grouping refer to?
910 // Add grouping, if necessary.
912 const int __declen = __p ? __p - __cs : __len;
913 __p2 = std::__add_grouping(__new, __sep, __grouping, __grouping_size,
914 __cs, __cs + __declen);
916 // Tack on decimal part.
917 int __newlen = __p2 - __new;
920 char_traits<_CharT>::copy(__p2, __p, __len - __declen);
921 __newlen += __len - __declen;
926 // The following code uses snprintf (or sprintf(), when
927 // _GLIBCXX_USE_C99 is not defined) to convert floating point values
928 // for insertion into a stream. An optimization would be to replace
929 // them with code that works directly on a wide buffer and then use
930 // __pad to do the padding. It would be good to replace them anyway
931 // to gain back the efficiency that C++ provides by knowing up front
932 // the type of the values to insert. Also, sprintf is dangerous
933 // since may lead to accidental buffer overruns. This
934 // implementation follows the C++ standard fairly directly as
935 // outlined in 22.2.2.2 [lib.locale.num.put]
936 template<typename _CharT, typename _OutIter>
937 template<typename _ValueT>
939 num_put<_CharT, _OutIter>::
940 _M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
943 typedef typename numpunct<_CharT>::__cache_type __cache_type;
944 __use_cache<__cache_type> __uc;
945 const locale& __loc = __io._M_getloc();
946 const __cache_type* __lc = __uc(__loc);
948 // Note: digits10 is rounded down: add 1 to ensure the maximum
949 // available precision. Then, in general, one more 1 needs to
950 // be added since, when the %{g,G} conversion specifiers are
951 // chosen inside _S_format_float, the precision field is "the
952 // maximum number of significant digits", *not* the "number of
953 // digits to appear after the decimal point", as happens for
954 // %{e,E,f,F} (C99, 7.19.6.1,4).
955 const int __max_digits = numeric_limits<_ValueT>::digits10 + 2;
957 // Use default precision if out of range.
958 streamsize __prec = __io.precision();
959 if (__prec > static_cast<streamsize>(__max_digits))
960 __prec = static_cast<streamsize>(__max_digits);
961 else if (__prec < static_cast<streamsize>(0))
962 __prec = static_cast<streamsize>(6);
964 // [22.2.2.2.2] Stage 1, numeric conversion to character.
966 // Long enough for the max format spec.
969 #ifdef _GLIBCXX_USE_C99
970 // First try a buffer perhaps big enough (for sure sufficient
971 // for non-ios_base::fixed outputs)
972 int __cs_size = __max_digits * 3;
973 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
975 _S_format_float(__io, __fbuf, __mod);
976 __len = std::__convert_from_v(__cs, __cs_size, __fbuf, __v,
977 _S_get_c_locale(), __prec);
979 // If the buffer was not large enough, try again with the correct size.
980 if (__len >= __cs_size)
982 __cs_size = __len + 1;
983 __cs = static_cast<char*>(__builtin_alloca(__cs_size));
984 __len = std::__convert_from_v(__cs, __cs_size, __fbuf, __v,
985 _S_get_c_locale(), __prec);
988 // Consider the possibility of long ios_base::fixed outputs
989 const bool __fixed = __io.flags() & ios_base::fixed;
990 const int __max_exp = numeric_limits<_ValueT>::max_exponent10;
992 // The size of the output string is computed as follows.
993 // ios_base::fixed outputs may need up to __max_exp+1 chars
994 // for the integer part + up to __max_digits chars for the
995 // fractional part + 3 chars for sign, decimal point, '\0'. On
996 // the other hand, for non-fixed outputs __max_digits*3 chars
997 // are largely sufficient.
998 const int __cs_size = __fixed ? __max_exp + __max_digits + 4
1000 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1002 _S_format_float(__io, __fbuf, __mod);
1003 __len = std::__convert_from_v(__cs, 0, __fbuf, __v,
1004 _S_get_c_locale(), __prec);
1007 // [22.2.2.2.2] Stage 2, convert to char_type, using correct
1008 // numpunct.decimal_point() values for '.' and adding grouping.
1009 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1011 _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1013 __ctype.widen(__cs, __cs + __len, __ws);
1015 // Replace decimal point.
1016 const _CharT __cdec = __ctype.widen('.');
1017 const _CharT __dec = __lc->_M_decimal_point;
1019 if (__p = char_traits<_CharT>::find(__ws, __len, __cdec))
1020 __ws[__p - __ws] = __dec;
1022 // Add grouping, if necessary.
1023 if (__lc->_M_use_grouping)
1025 // Grouping can add (almost) as many separators as the
1026 // number of digits, but no more.
1027 _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1029 _M_group_float(__lc->_M_grouping, __lc->_M_grouping_size,
1030 __lc->_M_thousands_sep, __p, __ws2, __ws, __len);
1035 const streamsize __w = __io.width();
1036 if (__w > static_cast<streamsize>(__len))
1038 _CharT* __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1040 _M_pad(__fill, __w, __io, __ws3, __ws, __len);
1045 // [22.2.2.2.2] Stage 4.
1046 // Write resulting, fully-formatted string to output iterator.
1047 return std::__write(__s, __ws, __len);
1050 template<typename _CharT, typename _OutIter>
1052 num_put<_CharT, _OutIter>::
1053 do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
1055 const ios_base::fmtflags __flags = __io.flags();
1056 if ((__flags & ios_base::boolalpha) == 0)
1058 unsigned long __uv = __v;
1059 __s = _M_insert_int(__s, __io, __fill, __uv);
1063 typedef typename numpunct<_CharT>::__cache_type __cache_type;
1064 __use_cache<__cache_type> __uc;
1065 const locale& __loc = __io._M_getloc();
1066 const __cache_type* __lc = __uc(__loc);
1068 const _CharT* __name = __v ? __lc->_M_truename
1069 : __lc->_M_falsename;
1070 int __len = __v ? __lc->_M_truename_size
1071 : __lc->_M_falsename_size;
1073 const streamsize __w = __io.width();
1074 if (__w > static_cast<streamsize>(__len))
1077 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1079 _M_pad(__fill, __w, __io, __cs, __name, __len);
1083 __s = std::__write(__s, __name, __len);
1088 template<typename _CharT, typename _OutIter>
1090 num_put<_CharT, _OutIter>::
1091 do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
1092 { return _M_insert_int(__s, __io, __fill, __v); }
1094 template<typename _CharT, typename _OutIter>
1096 num_put<_CharT, _OutIter>::
1097 do_put(iter_type __s, ios_base& __io, char_type __fill,
1098 unsigned long __v) const
1099 { return _M_insert_int(__s, __io, __fill, __v); }
1101 #ifdef _GLIBCXX_USE_LONG_LONG
1102 template<typename _CharT, typename _OutIter>
1104 num_put<_CharT, _OutIter>::
1105 do_put(iter_type __s, ios_base& __b, char_type __fill, long long __v) const
1106 { return _M_insert_int(__s, __b, __fill, __v); }
1108 template<typename _CharT, typename _OutIter>
1110 num_put<_CharT, _OutIter>::
1111 do_put(iter_type __s, ios_base& __io, char_type __fill,
1112 unsigned long long __v) const
1113 { return _M_insert_int(__s, __io, __fill, __v); }
1116 template<typename _CharT, typename _OutIter>
1118 num_put<_CharT, _OutIter>::
1119 do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
1120 { return _M_insert_float(__s, __io, __fill, char(), __v); }
1122 template<typename _CharT, typename _OutIter>
1124 num_put<_CharT, _OutIter>::
1125 do_put(iter_type __s, ios_base& __io, char_type __fill,
1126 long double __v) const
1127 { return _M_insert_float(__s, __io, __fill, 'L', __v); }
1129 template<typename _CharT, typename _OutIter>
1131 num_put<_CharT, _OutIter>::
1132 do_put(iter_type __s, ios_base& __io, char_type __fill,
1133 const void* __v) const
1135 const ios_base::fmtflags __flags = __io.flags();
1136 const ios_base::fmtflags __fmt = ~(ios_base::showpos
1137 | ios_base::basefield
1138 | ios_base::uppercase
1139 | ios_base::internal);
1140 __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
1142 __s = _M_insert_int(__s, __io, __fill,
1143 reinterpret_cast<unsigned long>(__v));
1144 __io.flags(__flags);
1148 template<typename _CharT, bool _Intl>
1149 struct __use_cache<__moneypunct_cache<_CharT, _Intl> >
1151 const __moneypunct_cache<_CharT, _Intl>*
1152 operator() (const locale& __loc) const
1154 const size_t __i = moneypunct<_CharT, _Intl>::id._M_id();
1155 const locale::facet** __caches = __loc._M_impl->_M_caches;
1158 __moneypunct_cache<_CharT, _Intl>* __tmp = NULL;
1161 __tmp = new __moneypunct_cache<_CharT, _Intl>;
1162 __tmp->_M_cache(__loc);
1167 __throw_exception_again;
1169 __loc._M_impl->_M_install_cache(__tmp, __i);
1172 const __moneypunct_cache<_CharT, _Intl>*>(__caches[__i]);
1176 template<typename _CharT, typename _InIter>
1177 template<bool _Intl>
1179 money_get<_CharT, _InIter>::
1180 _M_extract(iter_type __beg, iter_type __end, ios_base& __io,
1181 ios_base::iostate& __err, string& __units) const
1183 typedef char_traits<_CharT> __traits_type;
1184 typedef typename string_type::size_type size_type;
1185 typedef money_base::part part;
1186 typedef moneypunct<_CharT, _Intl> __moneypunct_type;
1187 typedef typename __moneypunct_type::__cache_type __cache_type;
1189 const locale& __loc = __io._M_getloc();
1190 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1192 __use_cache<__cache_type> __uc;
1193 const __cache_type* __lc = __uc(__loc);
1194 const char_type* __lit = __lc->_M_atoms;
1196 const money_base::pattern __p = __lc->_M_neg_format;
1199 bool __negative = false;
1200 // True for more than one character long sign.
1201 bool __long_sign = false;
1202 // String of grouping info from thousands_sep plucked from __units.
1203 string __grouping_tmp;
1204 if (__lc->_M_use_grouping)
1205 __grouping_tmp.reserve(32);
1206 // Last position before the decimal point.
1208 // Separator positions, then, possibly, fractional digits.
1210 // If input iterator is in a valid state.
1211 bool __testvalid = true;
1212 // Flag marking when a decimal point is found.
1213 bool __testdecfound = false;
1215 // The tentative returned string is stored here.
1219 const char_type* __lit_zero = __lit + _S_zero;
1220 const char_type* __q;
1221 for (int __i = 0; __beg != __end && __i < 4 && __testvalid; ++__i)
1223 const part __which = static_cast<part>(__p.field[__i]);
1226 case money_base::symbol:
1227 if (__io.flags() & ios_base::showbase
1228 || __i < 2 || __long_sign
1229 || ((static_cast<part>(__p.field[3]) != money_base::none)
1232 // According to 22.2.6.1.2, p2, symbol is required
1233 // if (__io.flags() & ios_base::showbase),
1234 // otherwise is optional and consumed only if
1235 // other characters are needed to complete the
1237 const size_type __len = __lc->_M_curr_symbol_size;
1239 for (; __beg != __end && __j < __len
1240 && *__beg == __lc->_M_curr_symbol[__j];
1242 // When (__io.flags() & ios_base::showbase)
1243 // symbol is required.
1244 if (__j != __len && (__io.flags() & ios_base::showbase))
1245 __testvalid = false;
1248 case money_base::sign:
1249 // Sign might not exist, or be more than one character long.
1250 if (__lc->_M_positive_sign_size
1251 && *__beg == __lc->_M_positive_sign[0])
1253 if (__lc->_M_positive_sign_size > 1)
1257 else if (__lc->_M_negative_sign_size
1258 && *__beg == __lc->_M_negative_sign[0])
1261 if (__lc->_M_negative_sign_size > 1)
1265 else if (__lc->_M_positive_sign_size
1266 && !__lc->_M_negative_sign_size)
1267 // "... if no sign is detected, the result is given the sign
1268 // that corresponds to the source of the empty string"
1270 else if (__lc->_M_positive_sign_size
1271 && __lc->_M_negative_sign_size)
1273 // Sign is mandatory.
1274 __testvalid = false;
1277 case money_base::value:
1278 // Extract digits, remove and stash away the
1279 // grouping of found thousands separators.
1280 for (; __beg != __end; ++__beg)
1281 if (__q = __traits_type::find(__lit_zero, 10, *__beg))
1283 __res += _S_atoms[__q - __lit];
1286 else if (*__beg == __lc->_M_decimal_point && !__testdecfound)
1290 __testdecfound = true;
1292 else if (__lc->_M_use_grouping
1293 && *__beg == __lc->_M_thousands_sep
1298 // Mark position for later analysis.
1299 __grouping_tmp += static_cast<char>(__n);
1304 __testvalid = false;
1311 case money_base::space:
1312 case money_base::none:
1313 // Only if not at the end of the pattern.
1315 for (; __beg != __end
1316 && __ctype.is(ctype_base::space, *__beg); ++__beg);
1321 // Need to get the rest of the sign characters, if they exist.
1324 const char_type* __sign = __negative ? __lc->_M_negative_sign
1325 : __lc->_M_positive_sign;
1326 const size_type __len = __negative ? __lc->_M_negative_sign_size
1327 : __lc->_M_positive_sign_size;
1329 for (; __beg != __end && __i < __len
1330 && *__beg == __sign[__i]; ++__beg, ++__i);
1333 __testvalid = false;
1336 if (__testvalid && __res.size())
1338 // Strip leading zeros.
1339 if (__res.size() > 1)
1341 size_type __first = __res.find_first_not_of(__lit[_S_zero]);
1342 const bool __only_zeros = __first == string_type::npos;
1344 __res.erase(0, __only_zeros ? __res.size() - 1 : __first);
1348 if (__negative && __res[0] != __lit[_S_zero])
1349 __res.insert(__res.begin(), __lit[_S_minus]);
1351 // Test for grouping fidelity.
1352 if (__grouping_tmp.size())
1354 // Add the ending grouping.
1355 __grouping_tmp += static_cast<char>(__testdecfound ? __last_pos
1357 if (!std::__verify_grouping(__lc->_M_grouping,
1358 __lc->_M_grouping_size,
1360 __testvalid = false;
1363 // Iff not enough digits were supplied after the decimal-point.
1364 if (__testdecfound && __lc->_M_frac_digits > 0
1365 && __n != __lc->_M_frac_digits)
1366 __testvalid = false;
1369 __testvalid = false;
1371 // Iff no more characters are available.
1373 __err |= ios_base::eofbit;
1375 // Iff valid sequence is not recognized.
1377 __err |= ios_base::failbit;
1379 __units.swap(__res);
1384 template<typename _CharT, typename _InIter>
1386 money_get<_CharT, _InIter>::
1387 do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
1388 ios_base::iostate& __err, long double& __units) const
1392 __beg = _M_extract<true>(__beg, __end, __io, __err, __str);
1394 __beg = _M_extract<false>(__beg, __end, __io, __err, __str);
1397 std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
1402 template<typename _CharT, typename _InIter>
1404 money_get<_CharT, _InIter>::
1405 do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
1406 ios_base::iostate& __err, string_type& __units) const
1408 typedef typename string_type::size_type size_type;
1410 const locale& __loc = __io._M_getloc();
1411 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1414 const iter_type __ret = __intl ? _M_extract<true>(__beg, __end, __io,
1416 : _M_extract<false>(__beg, __end, __io,
1418 const size_type __len = __str.size();
1421 _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1423 __ctype.widen(__str.data(), __str.data() + __len, __ws);
1424 __units.assign(__ws, __len);
1430 template<typename _CharT, typename _OutIter>
1431 template<bool _Intl>
1433 money_put<_CharT, _OutIter>::
1434 _M_insert(iter_type __s, ios_base& __io, char_type __fill,
1435 const string_type& __digits) const
1437 typedef typename string_type::size_type size_type;
1438 typedef money_base::part part;
1439 typedef moneypunct<_CharT, _Intl> __moneypunct_type;
1440 typedef typename __moneypunct_type::__cache_type __cache_type;
1442 const locale& __loc = __io._M_getloc();
1443 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1445 __use_cache<__cache_type> __uc;
1446 const __cache_type* __lc = __uc(__loc);
1447 const char_type* __lit = __lc->_M_atoms;
1449 // Determine if negative or positive formats are to be used, and
1450 // discard leading negative_sign if it is present.
1451 const char_type* __beg = __digits.data();
1452 const char_type* __end = __beg + __digits.size();
1454 money_base::pattern __p;
1455 const char_type* __sign;
1456 size_type __sign_size;
1457 if (*__beg != __lit[_S_minus])
1459 __p = __lc->_M_pos_format;
1460 __sign = __lc->_M_positive_sign;
1461 __sign_size = __lc->_M_positive_sign_size;
1465 __p = __lc->_M_neg_format;
1466 __sign = __lc->_M_negative_sign;
1467 __sign_size = __lc->_M_negative_sign_size;
1471 // Look for valid numbers in the ctype facet within input digits.
1472 __end = __ctype.scan_not(ctype_base::digit, __beg, __end);
1475 // Assume valid input, and attempt to format.
1476 // Break down input numbers into base components, as follows:
1477 // final_value = grouped units + (decimal point) + (digits)
1478 string_type __value;
1479 size_type __len = __end - __beg;
1480 __value.reserve(2 * __len);
1482 // Add thousands separators to non-decimal digits, per
1484 const int __paddec = __lc->_M_frac_digits - __len;
1487 if (__lc->_M_grouping_size)
1490 static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1493 std::__add_grouping(__ws, __lc->_M_thousands_sep,
1495 __lc->_M_grouping_size,
1496 __beg, __end - __lc->_M_frac_digits);
1497 __value.assign(__ws, __ws_end - __ws);
1500 __value.assign(__beg, -__paddec);
1503 // Deal with decimal point, decimal digits.
1504 if (__lc->_M_frac_digits > 0)
1506 __value += __lc->_M_decimal_point;
1508 __value.append(__end - __lc->_M_frac_digits,
1509 __lc->_M_frac_digits);
1512 // Have to pad zeros in the decimal position.
1513 __value.append(__paddec, __lit[_S_zero]);
1514 __value.append(__beg, __len);
1518 // Calculate length of resulting string.
1519 const ios_base::fmtflags __f = __io.flags() & ios_base::adjustfield;
1520 __len = __value.size() + __sign_size;
1521 __len += ((__io.flags() & ios_base::showbase)
1522 ? __lc->_M_curr_symbol_size : 0);
1525 __res.reserve(2 * __len);
1527 const size_type __width = static_cast<size_type>(__io.width());
1528 const bool __testipad = (__f == ios_base::internal
1529 && __len < __width);
1530 // Fit formatted digits into the required pattern.
1531 for (int __i = 0; __i < 4; ++__i)
1533 const part __which = static_cast<part>(__p.field[__i]);
1536 case money_base::symbol:
1537 if (__io.flags() & ios_base::showbase)
1538 __res.append(__lc->_M_curr_symbol,
1539 __lc->_M_curr_symbol_size);
1541 case money_base::sign:
1542 // Sign might not exist, or be more than one
1543 // charater long. In that case, add in the rest
1548 case money_base::value:
1551 case money_base::space:
1552 // At least one space is required, but if internal
1553 // formatting is required, an arbitrary number of
1554 // fill spaces will be necessary.
1556 __res.append(__width - __len, __fill);
1560 case money_base::none:
1562 __res.append(__width - __len, __fill);
1567 // Special case of multi-part sign parts.
1568 if (__sign_size > 1)
1569 __res.append(__sign + 1, __sign_size - 1);
1571 // Pad, if still necessary.
1572 __len = __res.size();
1573 if (__width > __len)
1575 if (__f == ios_base::left)
1577 __res.append(__width - __len, __fill);
1580 __res.insert(0, __width - __len, __fill);
1584 // Write resulting, fully-formatted string to output iterator.
1585 __s = std::__write(__s, __res.data(), __len);
1591 template<typename _CharT, typename _OutIter>
1593 money_put<_CharT, _OutIter>::
1594 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1595 long double __units) const
1597 const locale __loc = __io.getloc();
1598 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1599 #ifdef _GLIBCXX_USE_C99
1600 // First try a buffer perhaps big enough.
1602 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1603 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1604 // 328. Bad sprintf format modifier in money_put<>::do_put()
1605 int __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
1607 // If the buffer was not large enough, try again with the correct size.
1608 if (__len >= __cs_size)
1610 __cs_size = __len + 1;
1611 __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1612 __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
1616 // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
1617 const int __cs_size = numeric_limits<long double>::max_exponent10 + 3;
1618 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1619 int __len = std::__convert_from_v(__cs, 0, "%.0Lf", __units,
1622 _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1624 __ctype.widen(__cs, __cs + __len, __ws);
1625 const string_type __digits(__ws, __len);
1626 return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
1627 : _M_insert<false>(__s, __io, __fill, __digits);
1630 template<typename _CharT, typename _OutIter>
1632 money_put<_CharT, _OutIter>::
1633 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1634 const string_type& __digits) const
1635 { return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
1636 : _M_insert<false>(__s, __io, __fill, __digits); }
1638 // NB: Not especially useful. Without an ios_base object or some
1639 // kind of locale reference, we are left clawing at the air where
1640 // the side of the mountain used to be...
1641 template<typename _CharT, typename _InIter>
1642 time_base::dateorder
1643 time_get<_CharT, _InIter>::do_date_order() const
1644 { return time_base::no_order; }
1646 // Recursively expand a strftime format string and parse it. Starts w/ %x
1647 // and %X from do_get_time() and do_get_date(), which translate to a more
1648 // specific string, which may contain yet more strings. I.e. %x => %r =>
1649 // %H:%M:%S => extracted characters.
1650 template<typename _CharT, typename _InIter>
1652 time_get<_CharT, _InIter>::
1653 _M_extract_via_format(iter_type& __beg, iter_type& __end, ios_base& __io,
1654 ios_base::iostate& __err, tm* __tm,
1655 const _CharT* __format) const
1657 const locale __loc = __io.getloc();
1658 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1659 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1660 const size_t __len = char_traits<_CharT>::length(__format);
1662 for (size_t __i = 0; __beg != __end && __i < __len && !__err; ++__i)
1664 if (__ctype.narrow(__format[__i], 0) == '%')
1666 // Verify valid formatting code, attempt to extract.
1667 char __c = __ctype.narrow(__format[++__i], 0);
1669 if (__c == 'E' || __c == 'O')
1670 __c = __ctype.narrow(__format[++__i], 0);
1676 // Abbreviated weekday name [tm_wday]
1677 const char_type* __days1[7];
1678 __tp._M_days_abbreviated(__days1);
1679 _M_extract_name(__beg, __end, __tm->tm_wday, __days1, 7,
1683 // Weekday name [tm_wday].
1684 const char_type* __days2[7];
1685 __tp._M_days(__days2);
1686 _M_extract_name(__beg, __end, __tm->tm_wday, __days2, 7,
1691 // Abbreviated month name [tm_mon]
1692 const char_type* __months1[12];
1693 __tp._M_months_abbreviated(__months1);
1694 _M_extract_name(__beg, __end, __tm->tm_mon, __months1, 12,
1698 // Month name [tm_mon].
1699 const char_type* __months2[12];
1700 __tp._M_months(__months2);
1701 _M_extract_name(__beg, __end, __tm->tm_mon, __months2, 12,
1705 // Default time and date representation.
1706 const char_type* __dt[2];
1707 __tp._M_date_time_formats(__dt);
1708 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1712 // Day [01, 31]. [tm_mday]
1713 _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
1717 // Day [1, 31], with single digits preceded by
1719 if (__ctype.is(ctype_base::space, *__beg))
1720 _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9, 1,
1723 _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31, 2,
1727 // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
1729 __ctype.widen(__cs, __cs + 9, __wcs);
1730 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1734 // Hour [00, 23]. [tm_hour]
1735 _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
1739 // Hour [01, 12]. [tm_hour]
1740 _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
1744 // Month [01, 12]. [tm_mon]
1745 _M_extract_num(__beg, __end, __mem, 1, 12, 2, __ctype,
1748 __tm->tm_mon = __mem - 1;
1751 // Minute [00, 59]. [tm_min]
1752 _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
1756 if (__ctype.narrow(*__beg, 0) == '\n')
1759 __err |= ios_base::failbit;
1762 // Equivalent to (%H:%M).
1764 __ctype.widen(__cs, __cs + 6, __wcs);
1765 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1770 _M_extract_num(__beg, __end, __tm->tm_sec, 0, 59, 2,
1774 if (__ctype.narrow(*__beg, 0) == '\t')
1777 __err |= ios_base::failbit;
1780 // Equivalent to (%H:%M:%S).
1782 __ctype.widen(__cs, __cs + 9, __wcs);
1783 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1788 const char_type* __dates[2];
1789 __tp._M_date_formats(__dates);
1790 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1795 const char_type* __times[2];
1796 __tp._M_time_formats(__times);
1797 _M_extract_via_format(__beg, __end, __io, __err, __tm,
1802 // Two digit year. [tm_year]
1803 _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2,
1807 // Year [1900). [tm_year]
1808 _M_extract_num(__beg, __end, __mem, 0, 9999, 4,
1811 __tm->tm_year = __mem - 1900;
1815 if (__ctype.is(ctype_base::upper, *__beg))
1818 _M_extract_name(__beg, __end, __tmp,
1819 __timepunct_cache<_CharT>::_S_timezones,
1820 14, __ctype, __err);
1822 // GMT requires special effort.
1823 if (__beg != __end && !__err && __tmp == 0
1824 && (*__beg == __ctype.widen('-')
1825 || *__beg == __ctype.widen('+')))
1827 _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
1829 _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
1834 __err |= ios_base::failbit;
1838 __err |= ios_base::failbit;
1843 // Verify format and input match, extract and discard.
1844 if (__format[__i] == *__beg)
1847 __err |= ios_base::failbit;
1852 template<typename _CharT, typename _InIter>
1854 time_get<_CharT, _InIter>::
1855 _M_extract_num(iter_type& __beg, iter_type& __end, int& __member,
1856 int __min, int __max, size_t __len,
1857 const ctype<_CharT>& __ctype,
1858 ios_base::iostate& __err) const
1860 // As-is works for __len = 1, 2, 4, the values actually used.
1861 int __mult = __len == 2 ? 10 : (__len == 4 ? 1000 : 1);
1866 for (; __beg != __end && __i < __len; ++__beg, ++__i)
1868 const char __c = __ctype.narrow(*__beg, '*');
1869 if (__c >= '0' && __c <= '9')
1871 __value = __value * 10 + (__c - '0');
1872 const int __valuec = __value * __mult;
1873 if (__valuec > __max || __valuec + __mult < __min)
1883 __err |= ios_base::failbit;
1887 // All elements in __names are unique.
1888 template<typename _CharT, typename _InIter>
1890 time_get<_CharT, _InIter>::
1891 _M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
1892 const _CharT** __names, size_t __indexlen,
1893 const ctype<_CharT>& __ctype,
1894 ios_base::iostate& __err) const
1896 typedef char_traits<_CharT> __traits_type;
1897 int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)
1899 size_t __nmatches = 0;
1901 bool __testvalid = true;
1902 const char_type* __name;
1904 // Look for initial matches.
1905 // NB: Some of the locale data is in the form of all lowercase
1906 // names, and some is in the form of initially-capitalized
1907 // names. Look for both.
1910 const char_type __c = *__beg;
1911 for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
1912 if (__c == __names[__i1][0]
1913 || __c == __ctype.toupper(__names[__i1][0]))
1914 __matches[__nmatches++] = __i1;
1917 while (__nmatches > 1)
1919 // Find smallest matching string.
1920 size_t __minlen = 10;
1921 for (size_t __i2 = 0; __i2 < __nmatches; ++__i2)
1922 __minlen = std::min(__minlen,
1923 __traits_type::length(__names[__matches[__i2]]));
1925 if (__pos < __minlen && __beg != __end)
1928 for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)
1930 __name = __names[__matches[__i3]];
1931 if (__name[__pos] != *__beg)
1932 __matches[__i3] = __matches[--__nmatches];
1939 if (__nmatches == 1)
1941 // If there was only one match, the first compare is redundant.
1948 // Make sure found name is completely extracted.
1949 __name = __names[__matches[0]];
1950 const size_t __len = __traits_type::length(__name);
1951 while (__pos < __len && __beg != __end && __name[__pos] == *__beg)
1955 __member = __matches[0];
1957 __testvalid = false;
1960 __testvalid = false;
1962 __err |= ios_base::failbit;
1965 template<typename _CharT, typename _InIter>
1967 time_get<_CharT, _InIter>::
1968 do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
1969 ios_base::iostate& __err, tm* __tm) const
1972 const char* __cs = "%X";
1973 const locale __loc = __io.getloc();
1974 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1975 __ctype.widen(__cs, __cs + 3, __wcs);
1976 _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
1978 __err |= ios_base::eofbit;
1982 template<typename _CharT, typename _InIter>
1984 time_get<_CharT, _InIter>::
1985 do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
1986 ios_base::iostate& __err, tm* __tm) const
1989 const char* __cs = "%x";
1990 const locale __loc = __io.getloc();
1991 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1992 __ctype.widen(__cs, __cs + 3, __wcs);
1993 _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
1995 __err |= ios_base::eofbit;
1999 template<typename _CharT, typename _InIter>
2001 time_get<_CharT, _InIter>::
2002 do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
2003 ios_base::iostate& __err, tm* __tm) const
2005 typedef char_traits<_CharT> __traits_type;
2006 const locale __loc = __io.getloc();
2007 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
2008 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
2009 const char_type* __days[7];
2010 __tp._M_days_abbreviated(__days);
2012 _M_extract_name(__beg, __end, __tmpwday, __days, 7, __ctype, __err);
2014 // Check to see if non-abbreviated name exists, and extract.
2015 // NB: Assumes both _M_days and _M_days_abbreviated organized in
2016 // exact same order, first to last, such that the resulting
2017 // __days array with the same index points to a day, and that
2018 // day's abbreviated form.
2019 // NB: Also assumes that an abbreviated name is a subset of the name.
2022 size_t __pos = __traits_type::length(__days[__tmpwday]);
2023 __tp._M_days(__days);
2024 const char_type* __name = __days[__tmpwday];
2025 if (__name[__pos] == *__beg)
2027 // Extract the rest of it.
2028 const size_t __len = __traits_type::length(__name);
2029 while (__pos < __len && __beg != __end
2030 && __name[__pos] == *__beg)
2033 __err |= ios_base::failbit;
2036 __tm->tm_wday = __tmpwday;
2039 __err |= ios_base::eofbit;
2043 template<typename _CharT, typename _InIter>
2045 time_get<_CharT, _InIter>::
2046 do_get_monthname(iter_type __beg, iter_type __end,
2047 ios_base& __io, ios_base::iostate& __err, tm* __tm) const
2049 typedef char_traits<_CharT> __traits_type;
2050 const locale __loc = __io.getloc();
2051 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
2052 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
2053 const char_type* __months[12];
2054 __tp._M_months_abbreviated(__months);
2056 _M_extract_name(__beg, __end, __tmpmon, __months, 12, __ctype, __err);
2058 // Check to see if non-abbreviated name exists, and extract.
2059 // NB: Assumes both _M_months and _M_months_abbreviated organized in
2060 // exact same order, first to last, such that the resulting
2061 // __months array with the same index points to a month, and that
2062 // month's abbreviated form.
2063 // NB: Also assumes that an abbreviated name is a subset of the name.
2066 size_t __pos = __traits_type::length(__months[__tmpmon]);
2067 __tp._M_months(__months);
2068 const char_type* __name = __months[__tmpmon];
2069 if (__name[__pos] == *__beg)
2071 // Extract the rest of it.
2072 const size_t __len = __traits_type::length(__name);
2073 while (__pos < __len && __beg != __end
2074 && __name[__pos] == *__beg)
2077 __err |= ios_base::failbit;
2080 __tm->tm_mon = __tmpmon;
2084 __err |= ios_base::eofbit;
2088 template<typename _CharT, typename _InIter>
2090 time_get<_CharT, _InIter>::
2091 do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
2092 ios_base::iostate& __err, tm* __tm) const
2094 const locale __loc = __io.getloc();
2095 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
2099 for (; __beg != __end && __i < 4; ++__beg, ++__i)
2101 const char __c = __ctype.narrow(*__beg, '*');
2102 if (__c >= '0' && __c <= '9')
2103 __value = __value * 10 + (__c - '0');
2107 if (__i == 2 || __i == 4)
2108 __tm->tm_year = __i == 2 ? __value : __value - 1900;
2110 __err |= ios_base::failbit;
2112 __err |= ios_base::eofbit;
2116 template<typename _CharT, typename _OutIter>
2118 time_put<_CharT, _OutIter>::
2119 put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
2120 const _CharT* __beg, const _CharT* __end) const
2122 const locale __loc = __io.getloc();
2123 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
2124 for (; __beg != __end; ++__beg)
2125 if (__ctype.narrow(*__beg, 0) != '%')
2130 else if (++__beg != __end)
2134 const char __c = __ctype.narrow(*__beg, 0);
2135 if (__c != 'E' && __c != 'O')
2137 else if (++__beg != __end)
2140 __format = __ctype.narrow(*__beg, 0);
2144 __s = this->do_put(__s, __io, __fill, __tm,
2152 template<typename _CharT, typename _OutIter>
2154 time_put<_CharT, _OutIter>::
2155 do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm,
2156 char __format, char __mod) const
2158 const locale __loc = __io.getloc();
2159 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
2160 __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
2162 // NB: This size is arbitrary. Should this be a data member,
2163 // initialized at construction?
2164 const size_t __maxlen = 64;
2166 static_cast<char_type*>(__builtin_alloca(sizeof(char_type)
2169 // NB: In IEE 1003.1-200x, and perhaps other locale models, it
2170 // is possible that the format character will be longer than one
2171 // character. Possibilities include 'E' or 'O' followed by a
2172 // format character: if __mod is not the default argument, assume
2173 // it's a valid modifier.
2175 __fmt[0] = __ctype.widen('%');
2178 __fmt[1] = __format;
2179 __fmt[2] = char_type();
2184 __fmt[2] = __format;
2185 __fmt[3] = char_type();
2188 __tp._M_put(__res, __maxlen, __fmt, __tm);
2190 // Write resulting, fully-formatted string to output iterator.
2191 return std::__write(__s, __res, char_traits<char_type>::length(__res));
2195 // Generic version does nothing.
2196 template<typename _CharT>
2198 collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const
2201 // Generic version does nothing.
2202 template<typename _CharT>
2204 collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const
2207 template<typename _CharT>
2210 do_compare(const _CharT* __lo1, const _CharT* __hi1,
2211 const _CharT* __lo2, const _CharT* __hi2) const
2213 // strcoll assumes zero-terminated strings so we make a copy
2214 // and then put a zero at the end.
2215 const string_type __one(__lo1, __hi1);
2216 const string_type __two(__lo2, __hi2);
2218 const _CharT* __p = __one.c_str();
2219 const _CharT* __pend = __one.data() + __one.length();
2220 const _CharT* __q = __two.c_str();
2221 const _CharT* __qend = __two.data() + __two.length();
2223 // strcoll stops when it sees a nul character so we break
2224 // the strings into zero-terminated substrings and pass those
2228 const int __res = _M_compare(__p, __q);
2232 __p += char_traits<_CharT>::length(__p);
2233 __q += char_traits<_CharT>::length(__q);
2234 if (__p == __pend && __q == __qend)
2236 else if (__p == __pend)
2238 else if (__q == __qend)
2246 template<typename _CharT>
2247 typename collate<_CharT>::string_type
2249 do_transform(const _CharT* __lo, const _CharT* __hi) const
2251 // strxfrm assumes zero-terminated strings so we make a copy
2252 string_type __str(__lo, __hi);
2254 const _CharT* __p = __str.c_str();
2255 const _CharT* __pend = __str.data() + __str.length();
2257 size_t __len = (__hi - __lo) * 2;
2261 // strxfrm stops when it sees a nul character so we break
2262 // the string into zero-terminated substrings and pass those
2266 // First try a buffer perhaps big enough.
2268 static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
2269 size_t __res = _M_transform(__c, __p, __len);
2270 // If the buffer was not large enough, try again with the
2275 __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
2277 __res = _M_transform(__c, __p, __res + 1);
2280 __ret.append(__c, __res);
2281 __p += char_traits<_CharT>::length(__p);
2286 __ret.push_back(_CharT());
2290 template<typename _CharT>
2293 do_hash(const _CharT* __lo, const _CharT* __hi) const
2295 unsigned long __val = 0;
2296 for (; __lo < __hi; ++__lo)
2297 __val = *__lo + ((__val << 7) |
2298 (__val >> (numeric_limits<unsigned long>::digits - 7)));
2299 return static_cast<long>(__val);
2302 // Construct correctly padded string, as per 22.2.2.2.2
2304 // __newlen > __oldlen
2305 // __news is allocated for __newlen size
2306 // Used by both num_put and ostream inserters: if __num,
2307 // internal-adjusted objects are padded according to the rules below
2308 // concerning 0[xX] and +-, otherwise, exactly as right-adjusted
2311 // NB: Of the two parameters, _CharT can be deduced from the
2312 // function arguments. The other (_Traits) has to be explicitly specified.
2313 template<typename _CharT, typename _Traits>
2315 __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
2316 _CharT* __news, const _CharT* __olds,
2317 const streamsize __newlen,
2318 const streamsize __oldlen, const bool __num)
2320 const size_t __plen = static_cast<size_t>(__newlen - __oldlen);
2321 const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
2324 if (__adjust == ios_base::left)
2326 _Traits::copy(__news, const_cast<_CharT*>(__olds), __oldlen);
2327 _Traits::assign(__news + __oldlen, __plen, __fill);
2332 if (__adjust == ios_base::internal && __num)
2334 // Pad after the sign, if there is one.
2335 // Pad after 0[xX], if there is one.
2336 // Who came up with these rules, anyway? Jeeze.
2337 const locale& __loc = __io._M_getloc();
2338 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
2340 const bool __testsign = _Traits::eq(__ctype.widen('-'), __olds[0])
2341 || _Traits::eq(__ctype.widen('+'), __olds[0]);
2342 const bool __testhex = (_Traits::eq(__ctype.widen('0'), __olds[0])
2344 && (_Traits::eq(__ctype.widen('x'), __olds[1])
2345 || _Traits::eq(__ctype.widen('X'),
2349 __news[0] = __olds[0];
2350 __news[1] = __olds[1];
2354 else if (__testsign)
2356 __news[0] = __olds[0];
2360 // else Padding first.
2362 _Traits::assign(__news, __plen, __fill);
2363 _Traits::copy(__news + __plen, const_cast<_CharT*>(__olds + __mod),
2368 __verify_grouping(const char* __grouping, size_t __grouping_size,
2369 const string& __grouping_tmp)
2371 const size_t __n = __grouping_tmp.size() - 1;
2372 const size_t __min = std::min(__n, __grouping_size - 1);
2376 // Parsed number groupings have to match the
2377 // numpunct::grouping string exactly, starting at the
2378 // right-most point of the parsed sequence of elements ...
2379 for (size_t __j = 0; __j < __min && __test; --__i, ++__j)
2380 __test = __grouping_tmp[__i] == __grouping[__j];
2381 for (; __i && __test; --__i)
2382 __test = __grouping_tmp[__i] == __grouping[__min];
2383 // ... but the last parsed grouping can be <= numpunct
2385 __test &= __grouping_tmp[0] <= __grouping[__min];
2389 template<typename _CharT>
2391 __add_grouping(_CharT* __s, _CharT __sep,
2392 const char* __gbeg, size_t __gsize,
2393 const _CharT* __first, const _CharT* __last)
2395 if (__last - __first > *__gbeg)
2397 const bool __bump = __gsize != 1;
2398 __s = std::__add_grouping(__s, __sep, __gbeg + __bump,
2399 __gsize - __bump, __first,
2401 __first = __last - *__gbeg;
2405 *__s++ = *__first++;
2406 while (__first != __last);
2410 // Inhibit implicit instantiations for required instantiations,
2411 // which are defined via explicit instantiations elsewhere.
2412 // NB: This syntax is a GNU extension.
2413 #if _GLIBCXX_EXTERN_TEMPLATE
2414 extern template class moneypunct<char, false>;
2415 extern template class moneypunct<char, true>;
2416 extern template class moneypunct_byname<char, false>;
2417 extern template class moneypunct_byname<char, true>;
2418 extern template class money_get<char>;
2419 extern template class money_put<char>;
2420 extern template class numpunct<char>;
2421 extern template class numpunct_byname<char>;
2422 extern template class num_get<char>;
2423 extern template class num_put<char>;
2424 extern template class __timepunct<char>;
2425 extern template class time_put<char>;
2426 extern template class time_put_byname<char>;
2427 extern template class time_get<char>;
2428 extern template class time_get_byname<char>;
2429 extern template class messages<char>;
2430 extern template class messages_byname<char>;
2431 extern template class ctype_byname<char>;
2432 extern template class codecvt_byname<char, char, mbstate_t>;
2433 extern template class collate<char>;
2434 extern template class collate_byname<char>;
2437 const codecvt<char, char, mbstate_t>&
2438 use_facet<codecvt<char, char, mbstate_t> >(const locale&);
2441 const collate<char>&
2442 use_facet<collate<char> >(const locale&);
2445 const numpunct<char>&
2446 use_facet<numpunct<char> >(const locale&);
2449 const num_put<char>&
2450 use_facet<num_put<char> >(const locale&);
2453 const num_get<char>&
2454 use_facet<num_get<char> >(const locale&);
2457 const moneypunct<char, true>&
2458 use_facet<moneypunct<char, true> >(const locale&);
2461 const moneypunct<char, false>&
2462 use_facet<moneypunct<char, false> >(const locale&);
2465 const money_put<char>&
2466 use_facet<money_put<char> >(const locale&);
2469 const money_get<char>&
2470 use_facet<money_get<char> >(const locale&);
2473 const __timepunct<char>&
2474 use_facet<__timepunct<char> >(const locale&);
2477 const time_put<char>&
2478 use_facet<time_put<char> >(const locale&);
2481 const time_get<char>&
2482 use_facet<time_get<char> >(const locale&);
2485 const messages<char>&
2486 use_facet<messages<char> >(const locale&);
2490 has_facet<ctype<char> >(const locale&);
2494 has_facet<codecvt<char, char, mbstate_t> >(const locale&);
2498 has_facet<collate<char> >(const locale&);
2502 has_facet<numpunct<char> >(const locale&);
2506 has_facet<num_put<char> >(const locale&);
2510 has_facet<num_get<char> >(const locale&);
2514 has_facet<moneypunct<char> >(const locale&);
2518 has_facet<money_put<char> >(const locale&);
2522 has_facet<money_get<char> >(const locale&);
2526 has_facet<__timepunct<char> >(const locale&);
2530 has_facet<time_put<char> >(const locale&);
2534 has_facet<time_get<char> >(const locale&);
2538 has_facet<messages<char> >(const locale&);
2540 #ifdef _GLIBCXX_USE_WCHAR_T
2541 extern template class moneypunct<wchar_t, false>;
2542 extern template class moneypunct<wchar_t, true>;
2543 extern template class moneypunct_byname<wchar_t, false>;
2544 extern template class moneypunct_byname<wchar_t, true>;
2545 extern template class money_get<wchar_t>;
2546 extern template class money_put<wchar_t>;
2547 extern template class numpunct<wchar_t>;
2548 extern template class numpunct_byname<wchar_t>;
2549 extern template class num_get<wchar_t>;
2550 extern template class num_put<wchar_t>;
2551 extern template class __timepunct<wchar_t>;
2552 extern template class time_put<wchar_t>;
2553 extern template class time_put_byname<wchar_t>;
2554 extern template class time_get<wchar_t>;
2555 extern template class time_get_byname<wchar_t>;
2556 extern template class messages<wchar_t>;
2557 extern template class messages_byname<wchar_t>;
2558 extern template class ctype_byname<wchar_t>;
2559 extern template class codecvt_byname<wchar_t, char, mbstate_t>;
2560 extern template class collate<wchar_t>;
2561 extern template class collate_byname<wchar_t>;
2564 const codecvt<wchar_t, char, mbstate_t>&
2565 use_facet<codecvt<wchar_t, char, mbstate_t> >(locale const&);
2568 const collate<wchar_t>&
2569 use_facet<collate<wchar_t> >(const locale&);
2572 const numpunct<wchar_t>&
2573 use_facet<numpunct<wchar_t> >(const locale&);
2576 const num_put<wchar_t>&
2577 use_facet<num_put<wchar_t> >(const locale&);
2580 const num_get<wchar_t>&
2581 use_facet<num_get<wchar_t> >(const locale&);
2584 const moneypunct<wchar_t, true>&
2585 use_facet<moneypunct<wchar_t, true> >(const locale&);
2588 const moneypunct<wchar_t, false>&
2589 use_facet<moneypunct<wchar_t, false> >(const locale&);
2592 const money_put<wchar_t>&
2593 use_facet<money_put<wchar_t> >(const locale&);
2596 const money_get<wchar_t>&
2597 use_facet<money_get<wchar_t> >(const locale&);
2600 const __timepunct<wchar_t>&
2601 use_facet<__timepunct<wchar_t> >(const locale&);
2604 const time_put<wchar_t>&
2605 use_facet<time_put<wchar_t> >(const locale&);
2608 const time_get<wchar_t>&
2609 use_facet<time_get<wchar_t> >(const locale&);
2612 const messages<wchar_t>&
2613 use_facet<messages<wchar_t> >(const locale&);
2617 has_facet<ctype<wchar_t> >(const locale&);
2621 has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
2625 has_facet<collate<wchar_t> >(const locale&);
2629 has_facet<numpunct<wchar_t> >(const locale&);
2633 has_facet<num_put<wchar_t> >(const locale&);
2637 has_facet<num_get<wchar_t> >(const locale&);
2641 has_facet<moneypunct<wchar_t> >(const locale&);
2645 has_facet<money_put<wchar_t> >(const locale&);
2649 has_facet<money_get<wchar_t> >(const locale&);
2653 has_facet<__timepunct<wchar_t> >(const locale&);
2657 has_facet<time_put<wchar_t> >(const locale&);
2661 has_facet<time_get<wchar_t> >(const locale&);
2665 has_facet<messages<wchar_t> >(const locale&);