re PR libstdc++/37958 (num_get<>::do_get(bool) sets eofbit flag incorrectly when...
[gcc.git] / libstdc++-v3 / include / bits / locale_facets.tcc
1 // Locale support -*- C++ -*-
2
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 // 2006, 2007, 2008
5 // Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 2, or (at your option)
11 // any later version.
12
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING. If not, write to the Free
20 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // USA.
22
23 // As a special exception, you may use this file as part of a free software
24 // library without restriction. Specifically, if other files instantiate
25 // templates or use macros or inline functions from this file, or you compile
26 // this file and link it with other files to produce an executable, this
27 // file does not by itself cause the resulting executable to be covered by
28 // the GNU General Public License. This exception does not however
29 // invalidate any other reasons why the executable file might be covered by
30 // the GNU General Public License.
31
32 /** @file locale_facets.tcc
33 * This is an internal header file, included by other library headers.
34 * You should not attempt to use it directly.
35 */
36
37 #ifndef _LOCALE_FACETS_TCC
38 #define _LOCALE_FACETS_TCC 1
39
40 #pragma GCC system_header
41
42 _GLIBCXX_BEGIN_NAMESPACE(std)
43
44 // Routine to access a cache for the facet. If the cache didn't
45 // exist before, it gets constructed on the fly.
46 template<typename _Facet>
47 struct __use_cache
48 {
49 const _Facet*
50 operator() (const locale& __loc) const;
51 };
52
53 // Specializations.
54 template<typename _CharT>
55 struct __use_cache<__numpunct_cache<_CharT> >
56 {
57 const __numpunct_cache<_CharT>*
58 operator() (const locale& __loc) const
59 {
60 const size_t __i = numpunct<_CharT>::id._M_id();
61 const locale::facet** __caches = __loc._M_impl->_M_caches;
62 if (!__caches[__i])
63 {
64 __numpunct_cache<_CharT>* __tmp = NULL;
65 try
66 {
67 __tmp = new __numpunct_cache<_CharT>;
68 __tmp->_M_cache(__loc);
69 }
70 catch(...)
71 {
72 delete __tmp;
73 __throw_exception_again;
74 }
75 __loc._M_impl->_M_install_cache(__tmp, __i);
76 }
77 return static_cast<const __numpunct_cache<_CharT>*>(__caches[__i]);
78 }
79 };
80
81 template<typename _CharT>
82 void
83 __numpunct_cache<_CharT>::_M_cache(const locale& __loc)
84 {
85 _M_allocated = true;
86
87 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
88
89 _M_grouping_size = __np.grouping().size();
90 char* __grouping = new char[_M_grouping_size];
91 __np.grouping().copy(__grouping, _M_grouping_size);
92 _M_grouping = __grouping;
93 _M_use_grouping = (_M_grouping_size
94 && static_cast<signed char>(__np.grouping()[0]) > 0);
95
96 _M_truename_size = __np.truename().size();
97 _CharT* __truename = new _CharT[_M_truename_size];
98 __np.truename().copy(__truename, _M_truename_size);
99 _M_truename = __truename;
100
101 _M_falsename_size = __np.falsename().size();
102 _CharT* __falsename = new _CharT[_M_falsename_size];
103 __np.falsename().copy(__falsename, _M_falsename_size);
104 _M_falsename = __falsename;
105
106 _M_decimal_point = __np.decimal_point();
107 _M_thousands_sep = __np.thousands_sep();
108
109 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
110 __ct.widen(__num_base::_S_atoms_out,
111 __num_base::_S_atoms_out + __num_base::_S_oend, _M_atoms_out);
112 __ct.widen(__num_base::_S_atoms_in,
113 __num_base::_S_atoms_in + __num_base::_S_iend, _M_atoms_in);
114 }
115
116 // Used by both numeric and monetary facets.
117 // Check to make sure that the __grouping_tmp string constructed in
118 // money_get or num_get matches the canonical grouping for a given
119 // locale.
120 // __grouping_tmp is parsed L to R
121 // 1,222,444 == __grouping_tmp of "\1\3\3"
122 // __grouping is parsed R to L
123 // 1,222,444 == __grouping of "\3" == "\3\3\3"
124 bool
125 __verify_grouping(const char* __grouping, size_t __grouping_size,
126 const string& __grouping_tmp);
127
128 _GLIBCXX_BEGIN_LDBL_NAMESPACE
129
130 template<typename _CharT, typename _InIter>
131 _InIter
132 num_get<_CharT, _InIter>::
133 _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io,
134 ios_base::iostate& __err, string& __xtrc) const
135 {
136 typedef char_traits<_CharT> __traits_type;
137 typedef __numpunct_cache<_CharT> __cache_type;
138 __use_cache<__cache_type> __uc;
139 const locale& __loc = __io._M_getloc();
140 const __cache_type* __lc = __uc(__loc);
141 const _CharT* __lit = __lc->_M_atoms_in;
142 char_type __c = char_type();
143
144 // True if __beg becomes equal to __end.
145 bool __testeof = __beg == __end;
146
147 // First check for sign.
148 if (!__testeof)
149 {
150 __c = *__beg;
151 const bool __plus = __c == __lit[__num_base::_S_iplus];
152 if ((__plus || __c == __lit[__num_base::_S_iminus])
153 && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
154 && !(__c == __lc->_M_decimal_point))
155 {
156 __xtrc += __plus ? '+' : '-';
157 if (++__beg != __end)
158 __c = *__beg;
159 else
160 __testeof = true;
161 }
162 }
163
164 // Next, look for leading zeros.
165 bool __found_mantissa = false;
166 int __sep_pos = 0;
167 while (!__testeof)
168 {
169 if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
170 || __c == __lc->_M_decimal_point)
171 break;
172 else if (__c == __lit[__num_base::_S_izero])
173 {
174 if (!__found_mantissa)
175 {
176 __xtrc += '0';
177 __found_mantissa = true;
178 }
179 ++__sep_pos;
180
181 if (++__beg != __end)
182 __c = *__beg;
183 else
184 __testeof = true;
185 }
186 else
187 break;
188 }
189
190 // Only need acceptable digits for floating point numbers.
191 bool __found_dec = false;
192 bool __found_sci = false;
193 string __found_grouping;
194 if (__lc->_M_use_grouping)
195 __found_grouping.reserve(32);
196 const char_type* __lit_zero = __lit + __num_base::_S_izero;
197
198 if (!__lc->_M_allocated)
199 // "C" locale
200 while (!__testeof)
201 {
202 const int __digit = _M_find(__lit_zero, 10, __c);
203 if (__digit != -1)
204 {
205 __xtrc += '0' + __digit;
206 __found_mantissa = true;
207 }
208 else if (__c == __lc->_M_decimal_point
209 && !__found_dec && !__found_sci)
210 {
211 __xtrc += '.';
212 __found_dec = true;
213 }
214 else if ((__c == __lit[__num_base::_S_ie]
215 || __c == __lit[__num_base::_S_iE])
216 && !__found_sci && __found_mantissa)
217 {
218 // Scientific notation.
219 __xtrc += 'e';
220 __found_sci = true;
221
222 // Remove optional plus or minus sign, if they exist.
223 if (++__beg != __end)
224 {
225 __c = *__beg;
226 const bool __plus = __c == __lit[__num_base::_S_iplus];
227 if (__plus || __c == __lit[__num_base::_S_iminus])
228 __xtrc += __plus ? '+' : '-';
229 else
230 continue;
231 }
232 else
233 {
234 __testeof = true;
235 break;
236 }
237 }
238 else
239 break;
240
241 if (++__beg != __end)
242 __c = *__beg;
243 else
244 __testeof = true;
245 }
246 else
247 while (!__testeof)
248 {
249 // According to 22.2.2.1.2, p8-9, first look for thousands_sep
250 // and decimal_point.
251 if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
252 {
253 if (!__found_dec && !__found_sci)
254 {
255 // NB: Thousands separator at the beginning of a string
256 // is a no-no, as is two consecutive thousands separators.
257 if (__sep_pos)
258 {
259 __found_grouping += static_cast<char>(__sep_pos);
260 __sep_pos = 0;
261 }
262 else
263 {
264 // NB: __convert_to_v will not assign __v and will
265 // set the failbit.
266 __xtrc.clear();
267 break;
268 }
269 }
270 else
271 break;
272 }
273 else if (__c == __lc->_M_decimal_point)
274 {
275 if (!__found_dec && !__found_sci)
276 {
277 // If no grouping chars are seen, no grouping check
278 // is applied. Therefore __found_grouping is adjusted
279 // only if decimal_point comes after some thousands_sep.
280 if (__found_grouping.size())
281 __found_grouping += static_cast<char>(__sep_pos);
282 __xtrc += '.';
283 __found_dec = true;
284 }
285 else
286 break;
287 }
288 else
289 {
290 const char_type* __q =
291 __traits_type::find(__lit_zero, 10, __c);
292 if (__q)
293 {
294 __xtrc += '0' + (__q - __lit_zero);
295 __found_mantissa = true;
296 ++__sep_pos;
297 }
298 else if ((__c == __lit[__num_base::_S_ie]
299 || __c == __lit[__num_base::_S_iE])
300 && !__found_sci && __found_mantissa)
301 {
302 // Scientific notation.
303 if (__found_grouping.size() && !__found_dec)
304 __found_grouping += static_cast<char>(__sep_pos);
305 __xtrc += 'e';
306 __found_sci = true;
307
308 // Remove optional plus or minus sign, if they exist.
309 if (++__beg != __end)
310 {
311 __c = *__beg;
312 const bool __plus = __c == __lit[__num_base::_S_iplus];
313 if ((__plus || __c == __lit[__num_base::_S_iminus])
314 && !(__lc->_M_use_grouping
315 && __c == __lc->_M_thousands_sep)
316 && !(__c == __lc->_M_decimal_point))
317 __xtrc += __plus ? '+' : '-';
318 else
319 continue;
320 }
321 else
322 {
323 __testeof = true;
324 break;
325 }
326 }
327 else
328 break;
329 }
330
331 if (++__beg != __end)
332 __c = *__beg;
333 else
334 __testeof = true;
335 }
336
337 // Digit grouping is checked. If grouping and found_grouping don't
338 // match, then get very very upset, and set failbit.
339 if (__found_grouping.size())
340 {
341 // Add the ending grouping if a decimal or 'e'/'E' wasn't found.
342 if (!__found_dec && !__found_sci)
343 __found_grouping += static_cast<char>(__sep_pos);
344
345 if (!std::__verify_grouping(__lc->_M_grouping,
346 __lc->_M_grouping_size,
347 __found_grouping))
348 __err = ios_base::failbit;
349 }
350
351 return __beg;
352 }
353
354 template<typename _CharT, typename _InIter>
355 template<typename _ValueT>
356 _InIter
357 num_get<_CharT, _InIter>::
358 _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
359 ios_base::iostate& __err, _ValueT& __v) const
360 {
361 typedef char_traits<_CharT> __traits_type;
362 using __gnu_cxx::__add_unsigned;
363 typedef typename __add_unsigned<_ValueT>::__type __unsigned_type;
364 typedef __numpunct_cache<_CharT> __cache_type;
365 __use_cache<__cache_type> __uc;
366 const locale& __loc = __io._M_getloc();
367 const __cache_type* __lc = __uc(__loc);
368 const _CharT* __lit = __lc->_M_atoms_in;
369 char_type __c = char_type();
370
371 // NB: Iff __basefield == 0, __base can change based on contents.
372 const ios_base::fmtflags __basefield = __io.flags()
373 & ios_base::basefield;
374 const bool __oct = __basefield == ios_base::oct;
375 int __base = __oct ? 8 : (__basefield == ios_base::hex ? 16 : 10);
376
377 // True if __beg becomes equal to __end.
378 bool __testeof = __beg == __end;
379
380 // First check for sign.
381 bool __negative = false;
382 if (!__testeof)
383 {
384 __c = *__beg;
385 if (__gnu_cxx::__numeric_traits<_ValueT>::__is_signed)
386 __negative = __c == __lit[__num_base::_S_iminus];
387 if ((__negative || __c == __lit[__num_base::_S_iplus])
388 && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
389 && !(__c == __lc->_M_decimal_point))
390 {
391 if (++__beg != __end)
392 __c = *__beg;
393 else
394 __testeof = true;
395 }
396 }
397
398 // Next, look for leading zeros and check required digits
399 // for base formats.
400 bool __found_zero = false;
401 int __sep_pos = 0;
402 while (!__testeof)
403 {
404 if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
405 || __c == __lc->_M_decimal_point)
406 break;
407 else if (__c == __lit[__num_base::_S_izero]
408 && (!__found_zero || __base == 10))
409 {
410 __found_zero = true;
411 ++__sep_pos;
412 if (__basefield == 0)
413 __base = 8;
414 if (__base == 8)
415 __sep_pos = 0;
416 }
417 else if (__found_zero
418 && (__c == __lit[__num_base::_S_ix]
419 || __c == __lit[__num_base::_S_iX]))
420 {
421 if (__basefield == 0)
422 __base = 16;
423 if (__base == 16)
424 {
425 __found_zero = false;
426 __sep_pos = 0;
427 }
428 else
429 break;
430 }
431 else
432 break;
433
434 if (++__beg != __end)
435 {
436 __c = *__beg;
437 if (!__found_zero)
438 break;
439 }
440 else
441 __testeof = true;
442 }
443
444 // At this point, base is determined. If not hex, only allow
445 // base digits as valid input.
446 const size_t __len = (__base == 16 ? __num_base::_S_iend
447 - __num_base::_S_izero : __base);
448
449 // Extract.
450 string __found_grouping;
451 if (__lc->_M_use_grouping)
452 __found_grouping.reserve(32);
453 bool __testfail = false;
454 bool __testoverflow = false;
455 const __unsigned_type __max = __negative
456 ? -__gnu_cxx::__numeric_traits<_ValueT>::__min
457 : __gnu_cxx::__numeric_traits<_ValueT>::__max;
458 const __unsigned_type __smax = __max / __base;
459 __unsigned_type __result = 0;
460 int __digit = 0;
461 const char_type* __lit_zero = __lit + __num_base::_S_izero;
462
463 if (!__lc->_M_allocated)
464 // "C" locale
465 while (!__testeof)
466 {
467 __digit = _M_find(__lit_zero, __len, __c);
468 if (__digit == -1)
469 break;
470
471 if (__result > __smax)
472 __testoverflow = true;
473 else
474 {
475 __result *= __base;
476 __testoverflow |= __result > __max - __digit;
477 __result += __digit;
478 ++__sep_pos;
479 }
480
481 if (++__beg != __end)
482 __c = *__beg;
483 else
484 __testeof = true;
485 }
486 else
487 while (!__testeof)
488 {
489 // According to 22.2.2.1.2, p8-9, first look for thousands_sep
490 // and decimal_point.
491 if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
492 {
493 // NB: Thousands separator at the beginning of a string
494 // is a no-no, as is two consecutive thousands separators.
495 if (__sep_pos)
496 {
497 __found_grouping += static_cast<char>(__sep_pos);
498 __sep_pos = 0;
499 }
500 else
501 {
502 __testfail = true;
503 break;
504 }
505 }
506 else if (__c == __lc->_M_decimal_point)
507 break;
508 else
509 {
510 const char_type* __q =
511 __traits_type::find(__lit_zero, __len, __c);
512 if (!__q)
513 break;
514
515 __digit = __q - __lit_zero;
516 if (__digit > 15)
517 __digit -= 6;
518 if (__result > __smax)
519 __testoverflow = true;
520 else
521 {
522 __result *= __base;
523 __testoverflow |= __result > __max - __digit;
524 __result += __digit;
525 ++__sep_pos;
526 }
527 }
528
529 if (++__beg != __end)
530 __c = *__beg;
531 else
532 __testeof = true;
533 }
534
535 // Digit grouping is checked. If grouping and found_grouping don't
536 // match, then get very very upset, and set failbit.
537 if (__found_grouping.size())
538 {
539 // Add the ending grouping.
540 __found_grouping += static_cast<char>(__sep_pos);
541
542 if (!std::__verify_grouping(__lc->_M_grouping,
543 __lc->_M_grouping_size,
544 __found_grouping))
545 __err = ios_base::failbit;
546 }
547
548 // _GLIBCXX_RESOLVE_LIB_DEFECTS
549 // 23. Num_get overflow result.
550 if ((!__sep_pos && !__found_zero && !__found_grouping.size())
551 || __testfail)
552 {
553 __v = 0;
554 __err = ios_base::failbit;
555 }
556 else if (__testoverflow)
557 {
558 if (__negative)
559 __v = __gnu_cxx::__numeric_traits<_ValueT>::__min;
560 else
561 __v = __gnu_cxx::__numeric_traits<_ValueT>::__max;
562 __err = ios_base::failbit;
563 }
564 else
565 __v = __negative ? -__result : __result;
566
567 if (__testeof)
568 __err |= ios_base::eofbit;
569 return __beg;
570 }
571
572 // _GLIBCXX_RESOLVE_LIB_DEFECTS
573 // 17. Bad bool parsing
574 template<typename _CharT, typename _InIter>
575 _InIter
576 num_get<_CharT, _InIter>::
577 do_get(iter_type __beg, iter_type __end, ios_base& __io,
578 ios_base::iostate& __err, bool& __v) const
579 {
580 if (!(__io.flags() & ios_base::boolalpha))
581 {
582 // Parse bool values as long.
583 // NB: We can't just call do_get(long) here, as it might
584 // refer to a derived class.
585 long __l = -1;
586 __beg = _M_extract_int(__beg, __end, __io, __err, __l);
587 if (__l == 0 || __l == 1)
588 __v = bool(__l);
589 else
590 {
591 // _GLIBCXX_RESOLVE_LIB_DEFECTS
592 // 23. Num_get overflow result.
593 __v = true;
594 __err = ios_base::failbit;
595 if (__beg == __end)
596 __err |= ios_base::eofbit;
597 }
598 }
599 else
600 {
601 // Parse bool values as alphanumeric.
602 typedef __numpunct_cache<_CharT> __cache_type;
603 __use_cache<__cache_type> __uc;
604 const locale& __loc = __io._M_getloc();
605 const __cache_type* __lc = __uc(__loc);
606
607 bool __testf = false;
608 bool __donef = false;
609 bool __testt = false;
610 bool __donet = false;
611 size_t __n;
612 bool __testeof = __beg == __end;
613 for (__n = 0; !__testeof; ++__n)
614 {
615 const char_type __c = *__beg;
616
617 if (!__donef)
618 {
619 if (__n < __lc->_M_falsename_size)
620 {
621 __testf = __c == __lc->_M_falsename[__n];
622 if (!__testf)
623 __donef = true;
624 }
625 else
626 __donef = true;
627 }
628
629 if (!__donet)
630 {
631 if (__n < __lc->_M_truename_size)
632 {
633 __testt = __c == __lc->_M_truename[__n];
634 if (!__testt)
635 __donet = true;
636 }
637 else
638 __donet = true;
639 }
640
641 if (__donef && __donet)
642 break;
643
644 if (++__beg == __end)
645 __testeof = true;
646 }
647 if (__testf && __n == __lc->_M_falsename_size)
648 {
649 __v = false;
650 if (__testt && __n == __lc->_M_truename_size)
651 __err = ios_base::failbit;
652 else
653 __err = __donet ? ios_base::goodbit : ios_base::eofbit;
654 }
655 else if (__testt && __n == __lc->_M_truename_size)
656 {
657 __v = true;
658 __err = __donef ? ios_base::goodbit : ios_base::eofbit;
659 }
660 else
661 {
662 // _GLIBCXX_RESOLVE_LIB_DEFECTS
663 // 23. Num_get overflow result.
664 __v = false;
665 __err = ios_base::failbit;
666 if (__testeof && __n)
667 __err |= ios_base::eofbit;
668 }
669 }
670 return __beg;
671 }
672
673 template<typename _CharT, typename _InIter>
674 _InIter
675 num_get<_CharT, _InIter>::
676 do_get(iter_type __beg, iter_type __end, ios_base& __io,
677 ios_base::iostate& __err, long& __v) const
678 { return _M_extract_int(__beg, __end, __io, __err, __v); }
679
680 template<typename _CharT, typename _InIter>
681 _InIter
682 num_get<_CharT, _InIter>::
683 do_get(iter_type __beg, iter_type __end, ios_base& __io,
684 ios_base::iostate& __err, unsigned short& __v) const
685 { return _M_extract_int(__beg, __end, __io, __err, __v); }
686
687 template<typename _CharT, typename _InIter>
688 _InIter
689 num_get<_CharT, _InIter>::
690 do_get(iter_type __beg, iter_type __end, ios_base& __io,
691 ios_base::iostate& __err, unsigned int& __v) const
692 { return _M_extract_int(__beg, __end, __io, __err, __v); }
693
694 template<typename _CharT, typename _InIter>
695 _InIter
696 num_get<_CharT, _InIter>::
697 do_get(iter_type __beg, iter_type __end, ios_base& __io,
698 ios_base::iostate& __err, unsigned long& __v) const
699 { return _M_extract_int(__beg, __end, __io, __err, __v); }
700
701 #ifdef _GLIBCXX_USE_LONG_LONG
702 template<typename _CharT, typename _InIter>
703 _InIter
704 num_get<_CharT, _InIter>::
705 do_get(iter_type __beg, iter_type __end, ios_base& __io,
706 ios_base::iostate& __err, long long& __v) const
707 { return _M_extract_int(__beg, __end, __io, __err, __v); }
708
709 template<typename _CharT, typename _InIter>
710 _InIter
711 num_get<_CharT, _InIter>::
712 do_get(iter_type __beg, iter_type __end, ios_base& __io,
713 ios_base::iostate& __err, unsigned long long& __v) const
714 { return _M_extract_int(__beg, __end, __io, __err, __v); }
715 #endif
716
717 template<typename _CharT, typename _InIter>
718 _InIter
719 num_get<_CharT, _InIter>::
720 do_get(iter_type __beg, iter_type __end, ios_base& __io,
721 ios_base::iostate& __err, float& __v) const
722 {
723 string __xtrc;
724 __xtrc.reserve(32);
725 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
726 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
727 if (__beg == __end)
728 __err |= ios_base::eofbit;
729 return __beg;
730 }
731
732 template<typename _CharT, typename _InIter>
733 _InIter
734 num_get<_CharT, _InIter>::
735 do_get(iter_type __beg, iter_type __end, ios_base& __io,
736 ios_base::iostate& __err, double& __v) const
737 {
738 string __xtrc;
739 __xtrc.reserve(32);
740 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
741 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
742 if (__beg == __end)
743 __err |= ios_base::eofbit;
744 return __beg;
745 }
746
747 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
748 template<typename _CharT, typename _InIter>
749 _InIter
750 num_get<_CharT, _InIter>::
751 __do_get(iter_type __beg, iter_type __end, ios_base& __io,
752 ios_base::iostate& __err, double& __v) const
753 {
754 string __xtrc;
755 __xtrc.reserve(32);
756 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
757 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
758 if (__beg == __end)
759 __err |= ios_base::eofbit;
760 return __beg;
761 }
762 #endif
763
764 template<typename _CharT, typename _InIter>
765 _InIter
766 num_get<_CharT, _InIter>::
767 do_get(iter_type __beg, iter_type __end, ios_base& __io,
768 ios_base::iostate& __err, long double& __v) const
769 {
770 string __xtrc;
771 __xtrc.reserve(32);
772 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
773 std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
774 if (__beg == __end)
775 __err |= ios_base::eofbit;
776 return __beg;
777 }
778
779 template<typename _CharT, typename _InIter>
780 _InIter
781 num_get<_CharT, _InIter>::
782 do_get(iter_type __beg, iter_type __end, ios_base& __io,
783 ios_base::iostate& __err, void*& __v) const
784 {
785 // Prepare for hex formatted input.
786 typedef ios_base::fmtflags fmtflags;
787 const fmtflags __fmt = __io.flags();
788 __io.flags((__fmt & ~ios_base::basefield) | ios_base::hex);
789
790 typedef __gnu_cxx::__conditional_type<(sizeof(void*)
791 <= sizeof(unsigned long)),
792 unsigned long, unsigned long long>::__type _UIntPtrType;
793
794 _UIntPtrType __ul;
795 __beg = _M_extract_int(__beg, __end, __io, __err, __ul);
796
797 // Reset from hex formatted input.
798 __io.flags(__fmt);
799
800 __v = reinterpret_cast<void*>(__ul);
801 return __beg;
802 }
803
804 // For use by integer and floating-point types after they have been
805 // converted into a char_type string.
806 template<typename _CharT, typename _OutIter>
807 void
808 num_put<_CharT, _OutIter>::
809 _M_pad(_CharT __fill, streamsize __w, ios_base& __io,
810 _CharT* __new, const _CharT* __cs, int& __len) const
811 {
812 // [22.2.2.2.2] Stage 3.
813 // If necessary, pad.
814 __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new,
815 __cs, __w, __len);
816 __len = static_cast<int>(__w);
817 }
818
819 _GLIBCXX_END_LDBL_NAMESPACE
820
821 template<typename _CharT, typename _ValueT>
822 int
823 __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit,
824 ios_base::fmtflags __flags, bool __dec)
825 {
826 _CharT* __buf = __bufend;
827 if (__builtin_expect(__dec, true))
828 {
829 // Decimal.
830 do
831 {
832 *--__buf = __lit[(__v % 10) + __num_base::_S_odigits];
833 __v /= 10;
834 }
835 while (__v != 0);
836 }
837 else if ((__flags & ios_base::basefield) == ios_base::oct)
838 {
839 // Octal.
840 do
841 {
842 *--__buf = __lit[(__v & 0x7) + __num_base::_S_odigits];
843 __v >>= 3;
844 }
845 while (__v != 0);
846 }
847 else
848 {
849 // Hex.
850 const bool __uppercase = __flags & ios_base::uppercase;
851 const int __case_offset = __uppercase ? __num_base::_S_oudigits
852 : __num_base::_S_odigits;
853 do
854 {
855 *--__buf = __lit[(__v & 0xf) + __case_offset];
856 __v >>= 4;
857 }
858 while (__v != 0);
859 }
860 return __bufend - __buf;
861 }
862
863 _GLIBCXX_BEGIN_LDBL_NAMESPACE
864
865 template<typename _CharT, typename _OutIter>
866 void
867 num_put<_CharT, _OutIter>::
868 _M_group_int(const char* __grouping, size_t __grouping_size, _CharT __sep,
869 ios_base&, _CharT* __new, _CharT* __cs, int& __len) const
870 {
871 _CharT* __p = std::__add_grouping(__new, __sep, __grouping,
872 __grouping_size, __cs, __cs + __len);
873 __len = __p - __new;
874 }
875
876 template<typename _CharT, typename _OutIter>
877 template<typename _ValueT>
878 _OutIter
879 num_put<_CharT, _OutIter>::
880 _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
881 _ValueT __v) const
882 {
883 using __gnu_cxx::__add_unsigned;
884 typedef typename __add_unsigned<_ValueT>::__type __unsigned_type;
885 typedef __numpunct_cache<_CharT> __cache_type;
886 __use_cache<__cache_type> __uc;
887 const locale& __loc = __io._M_getloc();
888 const __cache_type* __lc = __uc(__loc);
889 const _CharT* __lit = __lc->_M_atoms_out;
890 const ios_base::fmtflags __flags = __io.flags();
891
892 // Long enough to hold hex, dec, and octal representations.
893 const int __ilen = 5 * sizeof(_ValueT);
894 _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
895 * __ilen));
896
897 // [22.2.2.2.2] Stage 1, numeric conversion to character.
898 // Result is returned right-justified in the buffer.
899 const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
900 const bool __dec = (__basefield != ios_base::oct
901 && __basefield != ios_base::hex);
902 const __unsigned_type __u = ((__v > 0 || !__dec)
903 ? __unsigned_type(__v)
904 : -__unsigned_type(__v));
905 int __len = __int_to_char(__cs + __ilen, __u, __lit, __flags, __dec);
906 __cs += __ilen - __len;
907
908 // Add grouping, if necessary.
909 if (__lc->_M_use_grouping)
910 {
911 // Grouping can add (almost) as many separators as the number
912 // of digits + space is reserved for numeric base or sign.
913 _CharT* __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
914 * (__len + 1)
915 * 2));
916 _M_group_int(__lc->_M_grouping, __lc->_M_grouping_size,
917 __lc->_M_thousands_sep, __io, __cs2 + 2, __cs, __len);
918 __cs = __cs2 + 2;
919 }
920
921 // Complete Stage 1, prepend numeric base or sign.
922 if (__builtin_expect(__dec, true))
923 {
924 // Decimal.
925 if (__v >= 0)
926 {
927 if (bool(__flags & ios_base::showpos)
928 && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed)
929 *--__cs = __lit[__num_base::_S_oplus], ++__len;
930 }
931 else
932 *--__cs = __lit[__num_base::_S_ominus], ++__len;
933 }
934 else if (bool(__flags & ios_base::showbase) && __v)
935 {
936 if (__basefield == ios_base::oct)
937 *--__cs = __lit[__num_base::_S_odigits], ++__len;
938 else
939 {
940 // 'x' or 'X'
941 const bool __uppercase = __flags & ios_base::uppercase;
942 *--__cs = __lit[__num_base::_S_ox + __uppercase];
943 // '0'
944 *--__cs = __lit[__num_base::_S_odigits];
945 __len += 2;
946 }
947 }
948
949 // Pad.
950 const streamsize __w = __io.width();
951 if (__w > static_cast<streamsize>(__len))
952 {
953 _CharT* __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
954 * __w));
955 _M_pad(__fill, __w, __io, __cs3, __cs, __len);
956 __cs = __cs3;
957 }
958 __io.width(0);
959
960 // [22.2.2.2.2] Stage 4.
961 // Write resulting, fully-formatted string to output iterator.
962 return std::__write(__s, __cs, __len);
963 }
964
965 template<typename _CharT, typename _OutIter>
966 void
967 num_put<_CharT, _OutIter>::
968 _M_group_float(const char* __grouping, size_t __grouping_size,
969 _CharT __sep, const _CharT* __p, _CharT* __new,
970 _CharT* __cs, int& __len) const
971 {
972 // _GLIBCXX_RESOLVE_LIB_DEFECTS
973 // 282. What types does numpunct grouping refer to?
974 // Add grouping, if necessary.
975 const int __declen = __p ? __p - __cs : __len;
976 _CharT* __p2 = std::__add_grouping(__new, __sep, __grouping,
977 __grouping_size,
978 __cs, __cs + __declen);
979
980 // Tack on decimal part.
981 int __newlen = __p2 - __new;
982 if (__p)
983 {
984 char_traits<_CharT>::copy(__p2, __p, __len - __declen);
985 __newlen += __len - __declen;
986 }
987 __len = __newlen;
988 }
989
990 // The following code uses vsnprintf (or vsprintf(), when
991 // _GLIBCXX_USE_C99 is not defined) to convert floating point values
992 // for insertion into a stream. An optimization would be to replace
993 // them with code that works directly on a wide buffer and then use
994 // __pad to do the padding. It would be good to replace them anyway
995 // to gain back the efficiency that C++ provides by knowing up front
996 // the type of the values to insert. Also, sprintf is dangerous
997 // since may lead to accidental buffer overruns. This
998 // implementation follows the C++ standard fairly directly as
999 // outlined in 22.2.2.2 [lib.locale.num.put]
1000 template<typename _CharT, typename _OutIter>
1001 template<typename _ValueT>
1002 _OutIter
1003 num_put<_CharT, _OutIter>::
1004 _M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
1005 _ValueT __v) const
1006 {
1007 typedef __numpunct_cache<_CharT> __cache_type;
1008 __use_cache<__cache_type> __uc;
1009 const locale& __loc = __io._M_getloc();
1010 const __cache_type* __lc = __uc(__loc);
1011
1012 // Use default precision if out of range.
1013 const streamsize __prec = __io.precision() < 0 ? 6 : __io.precision();
1014
1015 const int __max_digits =
1016 __gnu_cxx::__numeric_traits<_ValueT>::__digits10;
1017
1018 // [22.2.2.2.2] Stage 1, numeric conversion to character.
1019 int __len;
1020 // Long enough for the max format spec.
1021 char __fbuf[16];
1022 __num_base::_S_format_float(__io, __fbuf, __mod);
1023
1024 #ifdef _GLIBCXX_USE_C99
1025 // First try a buffer perhaps big enough (most probably sufficient
1026 // for non-ios_base::fixed outputs)
1027 int __cs_size = __max_digits * 3;
1028 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1029 __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
1030 __fbuf, __prec, __v);
1031
1032 // If the buffer was not large enough, try again with the correct size.
1033 if (__len >= __cs_size)
1034 {
1035 __cs_size = __len + 1;
1036 __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1037 __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
1038 __fbuf, __prec, __v);
1039 }
1040 #else
1041 // Consider the possibility of long ios_base::fixed outputs
1042 const bool __fixed = __io.flags() & ios_base::fixed;
1043 const int __max_exp =
1044 __gnu_cxx::__numeric_traits<_ValueT>::__max_exponent10;
1045
1046 // The size of the output string is computed as follows.
1047 // ios_base::fixed outputs may need up to __max_exp + 1 chars
1048 // for the integer part + __prec chars for the fractional part
1049 // + 3 chars for sign, decimal point, '\0'. On the other hand,
1050 // for non-fixed outputs __max_digits * 2 + __prec chars are
1051 // largely sufficient.
1052 const int __cs_size = __fixed ? __max_exp + __prec + 4
1053 : __max_digits * 2 + __prec;
1054 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
1055 __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, __fbuf,
1056 __prec, __v);
1057 #endif
1058
1059 // [22.2.2.2.2] Stage 2, convert to char_type, using correct
1060 // numpunct.decimal_point() values for '.' and adding grouping.
1061 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1062
1063 _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1064 * __len));
1065 __ctype.widen(__cs, __cs + __len, __ws);
1066
1067 // Replace decimal point.
1068 _CharT* __wp = 0;
1069 const char* __p = char_traits<char>::find(__cs, __len, '.');
1070 if (__p)
1071 {
1072 __wp = __ws + (__p - __cs);
1073 *__wp = __lc->_M_decimal_point;
1074 }
1075
1076 // Add grouping, if necessary.
1077 // N.B. Make sure to not group things like 2e20, i.e., no decimal
1078 // point, scientific notation.
1079 if (__lc->_M_use_grouping
1080 && (__wp || __len < 3 || (__cs[1] <= '9' && __cs[2] <= '9'
1081 && __cs[1] >= '0' && __cs[2] >= '0')))
1082 {
1083 // Grouping can add (almost) as many separators as the
1084 // number of digits, but no more.
1085 _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1086 * __len * 2));
1087
1088 streamsize __off = 0;
1089 if (__cs[0] == '-' || __cs[0] == '+')
1090 {
1091 __off = 1;
1092 __ws2[0] = __ws[0];
1093 __len -= 1;
1094 }
1095
1096 _M_group_float(__lc->_M_grouping, __lc->_M_grouping_size,
1097 __lc->_M_thousands_sep, __wp, __ws2 + __off,
1098 __ws + __off, __len);
1099 __len += __off;
1100
1101 __ws = __ws2;
1102 }
1103
1104 // Pad.
1105 const streamsize __w = __io.width();
1106 if (__w > static_cast<streamsize>(__len))
1107 {
1108 _CharT* __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1109 * __w));
1110 _M_pad(__fill, __w, __io, __ws3, __ws, __len);
1111 __ws = __ws3;
1112 }
1113 __io.width(0);
1114
1115 // [22.2.2.2.2] Stage 4.
1116 // Write resulting, fully-formatted string to output iterator.
1117 return std::__write(__s, __ws, __len);
1118 }
1119
1120 template<typename _CharT, typename _OutIter>
1121 _OutIter
1122 num_put<_CharT, _OutIter>::
1123 do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
1124 {
1125 const ios_base::fmtflags __flags = __io.flags();
1126 if ((__flags & ios_base::boolalpha) == 0)
1127 {
1128 const long __l = __v;
1129 __s = _M_insert_int(__s, __io, __fill, __l);
1130 }
1131 else
1132 {
1133 typedef __numpunct_cache<_CharT> __cache_type;
1134 __use_cache<__cache_type> __uc;
1135 const locale& __loc = __io._M_getloc();
1136 const __cache_type* __lc = __uc(__loc);
1137
1138 const _CharT* __name = __v ? __lc->_M_truename
1139 : __lc->_M_falsename;
1140 int __len = __v ? __lc->_M_truename_size
1141 : __lc->_M_falsename_size;
1142
1143 const streamsize __w = __io.width();
1144 if (__w > static_cast<streamsize>(__len))
1145 {
1146 _CharT* __cs
1147 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
1148 * __w));
1149 _M_pad(__fill, __w, __io, __cs, __name, __len);
1150 __name = __cs;
1151 }
1152 __io.width(0);
1153 __s = std::__write(__s, __name, __len);
1154 }
1155 return __s;
1156 }
1157
1158 template<typename _CharT, typename _OutIter>
1159 _OutIter
1160 num_put<_CharT, _OutIter>::
1161 do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
1162 { return _M_insert_int(__s, __io, __fill, __v); }
1163
1164 template<typename _CharT, typename _OutIter>
1165 _OutIter
1166 num_put<_CharT, _OutIter>::
1167 do_put(iter_type __s, ios_base& __io, char_type __fill,
1168 unsigned long __v) const
1169 { return _M_insert_int(__s, __io, __fill, __v); }
1170
1171 #ifdef _GLIBCXX_USE_LONG_LONG
1172 template<typename _CharT, typename _OutIter>
1173 _OutIter
1174 num_put<_CharT, _OutIter>::
1175 do_put(iter_type __s, ios_base& __io, char_type __fill, long long __v) const
1176 { return _M_insert_int(__s, __io, __fill, __v); }
1177
1178 template<typename _CharT, typename _OutIter>
1179 _OutIter
1180 num_put<_CharT, _OutIter>::
1181 do_put(iter_type __s, ios_base& __io, char_type __fill,
1182 unsigned long long __v) const
1183 { return _M_insert_int(__s, __io, __fill, __v); }
1184 #endif
1185
1186 template<typename _CharT, typename _OutIter>
1187 _OutIter
1188 num_put<_CharT, _OutIter>::
1189 do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
1190 { return _M_insert_float(__s, __io, __fill, char(), __v); }
1191
1192 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
1193 template<typename _CharT, typename _OutIter>
1194 _OutIter
1195 num_put<_CharT, _OutIter>::
1196 __do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
1197 { return _M_insert_float(__s, __io, __fill, char(), __v); }
1198 #endif
1199
1200 template<typename _CharT, typename _OutIter>
1201 _OutIter
1202 num_put<_CharT, _OutIter>::
1203 do_put(iter_type __s, ios_base& __io, char_type __fill,
1204 long double __v) const
1205 { return _M_insert_float(__s, __io, __fill, 'L', __v); }
1206
1207 template<typename _CharT, typename _OutIter>
1208 _OutIter
1209 num_put<_CharT, _OutIter>::
1210 do_put(iter_type __s, ios_base& __io, char_type __fill,
1211 const void* __v) const
1212 {
1213 const ios_base::fmtflags __flags = __io.flags();
1214 const ios_base::fmtflags __fmt = ~(ios_base::basefield
1215 | ios_base::uppercase
1216 | ios_base::internal);
1217 __io.flags((__flags & __fmt) | (ios_base::hex | ios_base::showbase));
1218
1219 typedef __gnu_cxx::__conditional_type<(sizeof(const void*)
1220 <= sizeof(unsigned long)),
1221 unsigned long, unsigned long long>::__type _UIntPtrType;
1222
1223 __s = _M_insert_int(__s, __io, __fill,
1224 reinterpret_cast<_UIntPtrType>(__v));
1225 __io.flags(__flags);
1226 return __s;
1227 }
1228
1229 _GLIBCXX_END_LDBL_NAMESPACE
1230
1231 // Construct correctly padded string, as per 22.2.2.2.2
1232 // Assumes
1233 // __newlen > __oldlen
1234 // __news is allocated for __newlen size
1235
1236 // NB: Of the two parameters, _CharT can be deduced from the
1237 // function arguments. The other (_Traits) has to be explicitly specified.
1238 template<typename _CharT, typename _Traits>
1239 void
1240 __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
1241 _CharT* __news, const _CharT* __olds,
1242 streamsize __newlen, streamsize __oldlen)
1243 {
1244 const size_t __plen = static_cast<size_t>(__newlen - __oldlen);
1245 const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
1246
1247 // Padding last.
1248 if (__adjust == ios_base::left)
1249 {
1250 _Traits::copy(__news, __olds, __oldlen);
1251 _Traits::assign(__news + __oldlen, __plen, __fill);
1252 return;
1253 }
1254
1255 size_t __mod = 0;
1256 if (__adjust == ios_base::internal)
1257 {
1258 // Pad after the sign, if there is one.
1259 // Pad after 0[xX], if there is one.
1260 // Who came up with these rules, anyway? Jeeze.
1261 const locale& __loc = __io._M_getloc();
1262 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1263
1264 if (__ctype.widen('-') == __olds[0]
1265 || __ctype.widen('+') == __olds[0])
1266 {
1267 __news[0] = __olds[0];
1268 __mod = 1;
1269 ++__news;
1270 }
1271 else if (__ctype.widen('0') == __olds[0]
1272 && __oldlen > 1
1273 && (__ctype.widen('x') == __olds[1]
1274 || __ctype.widen('X') == __olds[1]))
1275 {
1276 __news[0] = __olds[0];
1277 __news[1] = __olds[1];
1278 __mod = 2;
1279 __news += 2;
1280 }
1281 // else Padding first.
1282 }
1283 _Traits::assign(__news, __plen, __fill);
1284 _Traits::copy(__news + __plen, __olds + __mod, __oldlen - __mod);
1285 }
1286
1287 template<typename _CharT>
1288 _CharT*
1289 __add_grouping(_CharT* __s, _CharT __sep,
1290 const char* __gbeg, size_t __gsize,
1291 const _CharT* __first, const _CharT* __last)
1292 {
1293 size_t __idx = 0;
1294 size_t __ctr = 0;
1295
1296 while (__last - __first > __gbeg[__idx]
1297 && static_cast<signed char>(__gbeg[__idx]) > 0)
1298 {
1299 __last -= __gbeg[__idx];
1300 __idx < __gsize - 1 ? ++__idx : ++__ctr;
1301 }
1302
1303 while (__first != __last)
1304 *__s++ = *__first++;
1305
1306 while (__ctr--)
1307 {
1308 *__s++ = __sep;
1309 for (char __i = __gbeg[__idx]; __i > 0; --__i)
1310 *__s++ = *__first++;
1311 }
1312
1313 while (__idx--)
1314 {
1315 *__s++ = __sep;
1316 for (char __i = __gbeg[__idx]; __i > 0; --__i)
1317 *__s++ = *__first++;
1318 }
1319
1320 return __s;
1321 }
1322
1323 // Inhibit implicit instantiations for required instantiations,
1324 // which are defined via explicit instantiations elsewhere.
1325 // NB: This syntax is a GNU extension.
1326 #if _GLIBCXX_EXTERN_TEMPLATE
1327 extern template class numpunct<char>;
1328 extern template class numpunct_byname<char>;
1329 extern template class _GLIBCXX_LDBL_NAMESPACE num_get<char>;
1330 extern template class _GLIBCXX_LDBL_NAMESPACE num_put<char>;
1331 extern template class ctype_byname<char>;
1332
1333 extern template
1334 const ctype<char>&
1335 use_facet<ctype<char> >(const locale&);
1336
1337 extern template
1338 const numpunct<char>&
1339 use_facet<numpunct<char> >(const locale&);
1340
1341 extern template
1342 const num_put<char>&
1343 use_facet<num_put<char> >(const locale&);
1344
1345 extern template
1346 const num_get<char>&
1347 use_facet<num_get<char> >(const locale&);
1348
1349 extern template
1350 bool
1351 has_facet<ctype<char> >(const locale&);
1352
1353 extern template
1354 bool
1355 has_facet<numpunct<char> >(const locale&);
1356
1357 extern template
1358 bool
1359 has_facet<num_put<char> >(const locale&);
1360
1361 extern template
1362 bool
1363 has_facet<num_get<char> >(const locale&);
1364
1365 #ifdef _GLIBCXX_USE_WCHAR_T
1366 extern template class numpunct<wchar_t>;
1367 extern template class numpunct_byname<wchar_t>;
1368 extern template class _GLIBCXX_LDBL_NAMESPACE num_get<wchar_t>;
1369 extern template class _GLIBCXX_LDBL_NAMESPACE num_put<wchar_t>;
1370 extern template class ctype_byname<wchar_t>;
1371
1372 extern template
1373 const ctype<wchar_t>&
1374 use_facet<ctype<wchar_t> >(const locale&);
1375
1376 extern template
1377 const numpunct<wchar_t>&
1378 use_facet<numpunct<wchar_t> >(const locale&);
1379
1380 extern template
1381 const num_put<wchar_t>&
1382 use_facet<num_put<wchar_t> >(const locale&);
1383
1384 extern template
1385 const num_get<wchar_t>&
1386 use_facet<num_get<wchar_t> >(const locale&);
1387
1388 extern template
1389 bool
1390 has_facet<ctype<wchar_t> >(const locale&);
1391
1392 extern template
1393 bool
1394 has_facet<numpunct<wchar_t> >(const locale&);
1395
1396 extern template
1397 bool
1398 has_facet<num_put<wchar_t> >(const locale&);
1399
1400 extern template
1401 bool
1402 has_facet<num_get<wchar_t> >(const locale&);
1403 #endif
1404 #endif
1405
1406 _GLIBCXX_END_NAMESPACE
1407
1408 #endif