1 // Locale support -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 // 2006, 2007, 2008, 2009, 2010
5 // Free Software Foundation, Inc.
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 3, or (at your option)
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.
18 // Under Section 7 of GPL version 3, you are granted additional
19 // permissions described in the GCC Runtime Library Exception, version
20 // 3.1, as published by the Free Software Foundation.
22 // You should have received a copy of the GNU General Public License and
23 // a copy of the GCC Runtime Library Exception along with this program;
24 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 // <http://www.gnu.org/licenses/>.
27 /** @file bits/locale_facets.h
28 * This is an internal header file, included by other library headers.
29 * Do not attempt to use it directly. @headername{locale}
33 // ISO C++ 14882: 22.1 Locales
36 #ifndef _LOCALE_FACETS_H
37 #define _LOCALE_FACETS_H 1
39 #pragma GCC system_header
41 #include <cwctype> // For wctype_t
43 #include <bits/ctype_base.h>
45 #include <bits/ios_base.h> // For ios_base, ios_base::iostate
47 #include <bits/cpp_type_traits.h>
48 #include <ext/type_traits.h>
49 #include <ext/numeric_traits.h>
50 #include <bits/streambuf_iterator.h>
52 _GLIBCXX_BEGIN_NAMESPACE(std
)
54 // NB: Don't instantiate required wchar_t facets if no wchar_t support.
55 #ifdef _GLIBCXX_USE_WCHAR_T
56 # define _GLIBCXX_NUM_FACETS 28
58 # define _GLIBCXX_NUM_FACETS 14
61 // Convert string to numeric value of type _Tp and store results.
62 // NB: This is specialized for all required types, there is no
63 // generic definition.
64 template<typename _Tp
>
66 __convert_to_v(const char*, _Tp
&, ios_base::iostate
&,
67 const __c_locale
&) throw();
69 // Explicit specializations for required types.
72 __convert_to_v(const char*, float&, ios_base::iostate
&,
73 const __c_locale
&) throw();
77 __convert_to_v(const char*, double&, ios_base::iostate
&,
78 const __c_locale
&) throw();
82 __convert_to_v(const char*, long double&, ios_base::iostate
&,
83 const __c_locale
&) throw();
85 // NB: __pad is a struct, rather than a function, so it can be
86 // partially-specialized.
87 template<typename _CharT
, typename _Traits
>
91 _S_pad(ios_base
& __io
, _CharT __fill
, _CharT
* __news
,
92 const _CharT
* __olds
, streamsize __newlen
, streamsize __oldlen
);
95 // Used by both numeric and monetary facets.
96 // Inserts "group separator" characters into an array of characters.
97 // It's recursive, one iteration per group. It moves the characters
98 // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
99 // only with __gsize != 0.
100 template<typename _CharT
>
102 __add_grouping(_CharT
* __s
, _CharT __sep
,
103 const char* __gbeg
, size_t __gsize
,
104 const _CharT
* __first
, const _CharT
* __last
);
106 // This template permits specializing facet output code for
107 // ostreambuf_iterator. For ostreambuf_iterator, sputn is
108 // significantly more efficient than incrementing iterators.
109 template<typename _CharT
>
111 ostreambuf_iterator
<_CharT
>
112 __write(ostreambuf_iterator
<_CharT
> __s
, const _CharT
* __ws
, int __len
)
114 __s
._M_put(__ws
, __len
);
118 // This is the unspecialized form of the template.
119 template<typename _CharT
, typename _OutIter
>
122 __write(_OutIter __s
, const _CharT
* __ws
, int __len
)
124 for (int __j
= 0; __j
< __len
; __j
++, ++__s
)
130 // 22.2.1.1 Template class ctype
131 // Include host and configuration specific ctype enums for ctype_base.
134 * @brief Common base for ctype facet
136 * This template class provides implementations of the public functions
137 * that forward to the protected virtual functions.
139 * This template also provides abstract stubs for the protected virtual
142 template<typename _CharT
>
143 class __ctype_abstract_base
: public locale::facet
, public ctype_base
147 /// Typedef for the template parameter
148 typedef _CharT char_type
;
151 * @brief Test char_type classification.
153 * This function finds a mask M for @a c and compares it to mask @a m.
154 * It does so by returning the value of ctype<char_type>::do_is().
156 * @param c The char_type to compare the mask of.
157 * @param m The mask to compare against.
158 * @return (M & m) != 0.
161 is(mask __m
, char_type __c
) const
162 { return this->do_is(__m
, __c
); }
165 * @brief Return a mask array.
167 * This function finds the mask for each char_type in the range [lo,hi)
168 * and successively writes it to vec. vec must have as many elements
169 * as the char array. It does so by returning the value of
170 * ctype<char_type>::do_is().
172 * @param lo Pointer to start of range.
173 * @param hi Pointer to end of range.
174 * @param vec Pointer to an array of mask storage.
178 is(const char_type
*__lo
, const char_type
*__hi
, mask
*__vec
) const
179 { return this->do_is(__lo
, __hi
, __vec
); }
182 * @brief Find char_type matching a mask
184 * This function searches for and returns the first char_type c in
185 * [lo,hi) for which is(m,c) is true. It does so by returning
186 * ctype<char_type>::do_scan_is().
188 * @param m The mask to compare against.
189 * @param lo Pointer to start of range.
190 * @param hi Pointer to end of range.
191 * @return Pointer to matching char_type if found, else @a hi.
194 scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
195 { return this->do_scan_is(__m
, __lo
, __hi
); }
198 * @brief Find char_type not matching a mask
200 * This function searches for and returns the first char_type c in
201 * [lo,hi) for which is(m,c) is false. It does so by returning
202 * ctype<char_type>::do_scan_not().
204 * @param m The mask to compare against.
205 * @param lo Pointer to first char in range.
206 * @param hi Pointer to end of range.
207 * @return Pointer to non-matching char if found, else @a hi.
210 scan_not(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
211 { return this->do_scan_not(__m
, __lo
, __hi
); }
214 * @brief Convert to uppercase.
216 * This function converts the argument to uppercase if possible.
217 * If not possible (for example, '2'), returns the argument. It does
218 * so by returning ctype<char_type>::do_toupper().
220 * @param c The char_type to convert.
221 * @return The uppercase char_type if convertible, else @a c.
224 toupper(char_type __c
) const
225 { return this->do_toupper(__c
); }
228 * @brief Convert array to uppercase.
230 * This function converts each char_type in the range [lo,hi) to
231 * uppercase if possible. Other elements remain untouched. It does so
232 * by returning ctype<char_type>:: do_toupper(lo, hi).
234 * @param lo Pointer to start of range.
235 * @param hi Pointer to end of range.
239 toupper(char_type
*__lo
, const char_type
* __hi
) const
240 { return this->do_toupper(__lo
, __hi
); }
243 * @brief Convert to lowercase.
245 * This function converts the argument to lowercase if possible. If
246 * not possible (for example, '2'), returns the argument. It does so
247 * by returning ctype<char_type>::do_tolower(c).
249 * @param c The char_type to convert.
250 * @return The lowercase char_type if convertible, else @a c.
253 tolower(char_type __c
) const
254 { return this->do_tolower(__c
); }
257 * @brief Convert array to lowercase.
259 * This function converts each char_type in the range [lo,hi) to
260 * lowercase if possible. Other elements remain untouched. It does so
261 * by returning ctype<char_type>:: do_tolower(lo, hi).
263 * @param lo Pointer to start of range.
264 * @param hi Pointer to end of range.
268 tolower(char_type
* __lo
, const char_type
* __hi
) const
269 { return this->do_tolower(__lo
, __hi
); }
272 * @brief Widen char to char_type
274 * This function converts the char argument to char_type using the
275 * simplest reasonable transformation. It does so by returning
276 * ctype<char_type>::do_widen(c).
278 * Note: this is not what you want for codepage conversions. See
281 * @param c The char to convert.
282 * @return The converted char_type.
285 widen(char __c
) const
286 { return this->do_widen(__c
); }
289 * @brief Widen array to char_type
291 * This function converts each char in the input to char_type using the
292 * simplest reasonable transformation. It does so by returning
293 * ctype<char_type>::do_widen(c).
295 * Note: this is not what you want for codepage conversions. See
298 * @param lo Pointer to start of range.
299 * @param hi Pointer to end of range.
300 * @param to Pointer to the destination array.
304 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
305 { return this->do_widen(__lo
, __hi
, __to
); }
308 * @brief Narrow char_type to char
310 * This function converts the char_type to char using the simplest
311 * reasonable transformation. If the conversion fails, dfault is
312 * returned instead. It does so by returning
313 * ctype<char_type>::do_narrow(c).
315 * Note: this is not what you want for codepage conversions. See
318 * @param c The char_type to convert.
319 * @param dfault Char to return if conversion fails.
320 * @return The converted char.
323 narrow(char_type __c
, char __dfault
) const
324 { return this->do_narrow(__c
, __dfault
); }
327 * @brief Narrow array to char array
329 * This function converts each char_type in the input to char using the
330 * simplest reasonable transformation and writes the results to the
331 * destination array. For any char_type in the input that cannot be
332 * converted, @a dfault is used instead. It does so by returning
333 * ctype<char_type>::do_narrow(lo, hi, dfault, to).
335 * Note: this is not what you want for codepage conversions. See
338 * @param lo Pointer to start of range.
339 * @param hi Pointer to end of range.
340 * @param dfault Char to use if conversion fails.
341 * @param to Pointer to the destination array.
345 narrow(const char_type
* __lo
, const char_type
* __hi
,
346 char __dfault
, char *__to
) const
347 { return this->do_narrow(__lo
, __hi
, __dfault
, __to
); }
351 __ctype_abstract_base(size_t __refs
= 0): facet(__refs
) { }
354 ~__ctype_abstract_base() { }
357 * @brief Test char_type classification.
359 * This function finds a mask M for @a c and compares it to mask @a m.
361 * do_is() is a hook for a derived facet to change the behavior of
362 * classifying. do_is() must always return the same result for the
365 * @param c The char_type to find the mask of.
366 * @param m The mask to compare against.
367 * @return (M & m) != 0.
370 do_is(mask __m
, char_type __c
) const = 0;
373 * @brief Return a mask array.
375 * This function finds the mask for each char_type in the range [lo,hi)
376 * and successively writes it to vec. vec must have as many elements
379 * do_is() is a hook for a derived facet to change the behavior of
380 * classifying. do_is() must always return the same result for the
383 * @param lo Pointer to start of range.
384 * @param hi Pointer to end of range.
385 * @param vec Pointer to an array of mask storage.
388 virtual const char_type
*
389 do_is(const char_type
* __lo
, const char_type
* __hi
,
390 mask
* __vec
) const = 0;
393 * @brief Find char_type matching mask
395 * This function searches for and returns the first char_type c in
396 * [lo,hi) for which is(m,c) is true.
398 * do_scan_is() is a hook for a derived facet to change the behavior of
399 * match searching. do_is() must always return the same result for the
402 * @param m The mask to compare against.
403 * @param lo Pointer to start of range.
404 * @param hi Pointer to end of range.
405 * @return Pointer to a matching char_type if found, else @a hi.
407 virtual const char_type
*
408 do_scan_is(mask __m
, const char_type
* __lo
,
409 const char_type
* __hi
) const = 0;
412 * @brief Find char_type not matching mask
414 * This function searches for and returns a pointer to the first
415 * char_type c of [lo,hi) for which is(m,c) is false.
417 * do_scan_is() is a hook for a derived facet to change the behavior of
418 * match searching. do_is() must always return the same result for the
421 * @param m The mask to compare against.
422 * @param lo Pointer to start of range.
423 * @param hi Pointer to end of range.
424 * @return Pointer to a non-matching char_type if found, else @a hi.
426 virtual const char_type
*
427 do_scan_not(mask __m
, const char_type
* __lo
,
428 const char_type
* __hi
) const = 0;
431 * @brief Convert to uppercase.
433 * This virtual function converts the char_type argument to uppercase
434 * if possible. If not possible (for example, '2'), returns the
437 * do_toupper() is a hook for a derived facet to change the behavior of
438 * uppercasing. do_toupper() must always return the same result for
441 * @param c The char_type to convert.
442 * @return The uppercase char_type if convertible, else @a c.
445 do_toupper(char_type
) const = 0;
448 * @brief Convert array to uppercase.
450 * This virtual function converts each char_type in the range [lo,hi)
451 * to uppercase if possible. Other elements remain untouched.
453 * do_toupper() is a hook for a derived facet to change the behavior of
454 * uppercasing. do_toupper() must always return the same result for
457 * @param lo Pointer to start of range.
458 * @param hi Pointer to end of range.
461 virtual const char_type
*
462 do_toupper(char_type
* __lo
, const char_type
* __hi
) const = 0;
465 * @brief Convert to lowercase.
467 * This virtual function converts the argument to lowercase if
468 * possible. If not possible (for example, '2'), returns the argument.
470 * do_tolower() is a hook for a derived facet to change the behavior of
471 * lowercasing. do_tolower() must always return the same result for
474 * @param c The char_type to convert.
475 * @return The lowercase char_type if convertible, else @a c.
478 do_tolower(char_type
) const = 0;
481 * @brief Convert array to lowercase.
483 * This virtual function converts each char_type in the range [lo,hi)
484 * to lowercase if possible. Other elements remain untouched.
486 * do_tolower() is a hook for a derived facet to change the behavior of
487 * lowercasing. do_tolower() must always return the same result for
490 * @param lo Pointer to start of range.
491 * @param hi Pointer to end of range.
494 virtual const char_type
*
495 do_tolower(char_type
* __lo
, const char_type
* __hi
) const = 0;
500 * This virtual function converts the char to char_type using the
501 * simplest reasonable transformation.
503 * do_widen() is a hook for a derived facet to change the behavior of
504 * widening. do_widen() must always return the same result for the
507 * Note: this is not what you want for codepage conversions. See
510 * @param c The char to convert.
511 * @return The converted char_type
514 do_widen(char) const = 0;
517 * @brief Widen char array
519 * This function converts each char in the input to char_type using the
520 * simplest reasonable transformation.
522 * do_widen() is a hook for a derived facet to change the behavior of
523 * widening. do_widen() must always return the same result for the
526 * Note: this is not what you want for codepage conversions. See
529 * @param lo Pointer to start range.
530 * @param hi Pointer to end of range.
531 * @param to Pointer to the destination array.
535 do_widen(const char* __lo
, const char* __hi
,
536 char_type
* __dest
) const = 0;
539 * @brief Narrow char_type to char
541 * This virtual function converts the argument to char using the
542 * simplest reasonable transformation. If the conversion fails, dfault
543 * is returned instead.
545 * do_narrow() is a hook for a derived facet to change the behavior of
546 * narrowing. do_narrow() must always return the same result for the
549 * Note: this is not what you want for codepage conversions. See
552 * @param c The char_type to convert.
553 * @param dfault Char to return if conversion fails.
554 * @return The converted char.
557 do_narrow(char_type
, char __dfault
) const = 0;
560 * @brief Narrow char_type array to char
562 * This virtual function converts each char_type in the range [lo,hi) to
563 * char using the simplest reasonable transformation and writes the
564 * results to the destination array. For any element in the input that
565 * cannot be converted, @a dfault is used instead.
567 * do_narrow() is a hook for a derived facet to change the behavior of
568 * narrowing. do_narrow() must always return the same result for the
571 * Note: this is not what you want for codepage conversions. See
574 * @param lo Pointer to start of range.
575 * @param hi Pointer to end of range.
576 * @param dfault Char to use if conversion fails.
577 * @param to Pointer to the destination array.
580 virtual const char_type
*
581 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
582 char __dfault
, char* __dest
) const = 0;
586 * @brief Primary class template ctype facet.
589 * This template class defines classification and conversion functions for
590 * character sets. It wraps cctype functionality. Ctype gets used by
591 * streams for many I/O operations.
593 * This template provides the protected virtual functions the developer
594 * will have to replace in a derived class or specialization to make a
595 * working facet. The public functions that access them are defined in
596 * __ctype_abstract_base, to allow for implementation flexibility. See
597 * ctype<wchar_t> for an example. The functions are documented in
598 * __ctype_abstract_base.
600 * Note: implementations are provided for all the protected virtual
601 * functions, but will likely not be useful.
603 template<typename _CharT
>
604 class ctype
: public __ctype_abstract_base
<_CharT
>
608 typedef _CharT char_type
;
609 typedef typename __ctype_abstract_base
<_CharT
>::mask mask
;
611 /// The facet id for ctype<char_type>
612 static locale::id id
;
615 ctype(size_t __refs
= 0) : __ctype_abstract_base
<_CharT
>(__refs
) { }
622 do_is(mask __m
, char_type __c
) const;
624 virtual const char_type
*
625 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
627 virtual const char_type
*
628 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
630 virtual const char_type
*
631 do_scan_not(mask __m
, const char_type
* __lo
,
632 const char_type
* __hi
) const;
635 do_toupper(char_type __c
) const;
637 virtual const char_type
*
638 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
641 do_tolower(char_type __c
) const;
643 virtual const char_type
*
644 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
647 do_widen(char __c
) const;
650 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
653 do_narrow(char_type
, char __dfault
) const;
655 virtual const char_type
*
656 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
657 char __dfault
, char* __dest
) const;
660 template<typename _CharT
>
661 locale::id ctype
<_CharT
>::id
;
664 * @brief The ctype<char> specialization.
667 * This class defines classification and conversion functions for
668 * the char type. It gets used by char streams for many I/O
669 * operations. The char specialization provides a number of
670 * optimizations as well.
673 class ctype
<char> : public locale::facet
, public ctype_base
677 /// Typedef for the template parameter char.
678 typedef char char_type
;
682 __c_locale _M_c_locale_ctype
;
684 __to_type _M_toupper
;
685 __to_type _M_tolower
;
686 const mask
* _M_table
;
687 mutable char _M_widen_ok
;
688 mutable char _M_widen
[1 + static_cast<unsigned char>(-1)];
689 mutable char _M_narrow
[1 + static_cast<unsigned char>(-1)];
690 mutable char _M_narrow_ok
; // 0 uninitialized, 1 init,
691 // 2 memcpy can't be used
694 /// The facet id for ctype<char>
695 static locale::id id
;
696 /// The size of the mask table. It is SCHAR_MAX + 1.
697 static const size_t table_size
= 1 + static_cast<unsigned char>(-1);
700 * @brief Constructor performs initialization.
702 * This is the constructor provided by the standard.
704 * @param table If non-zero, table is used as the per-char mask.
705 * Else classic_table() is used.
706 * @param del If true, passes ownership of table to this facet.
707 * @param refs Passed to the base facet class.
710 ctype(const mask
* __table
= 0, bool __del
= false, size_t __refs
= 0);
713 * @brief Constructor performs static initialization.
715 * This constructor is used to construct the initial C locale facet.
717 * @param cloc Handle to C locale data.
718 * @param table If non-zero, table is used as the per-char mask.
719 * @param del If true, passes ownership of table to this facet.
720 * @param refs Passed to the base facet class.
723 ctype(__c_locale __cloc
, const mask
* __table
= 0, bool __del
= false,
727 * @brief Test char classification.
729 * This function compares the mask table[c] to @a m.
731 * @param c The char to compare the mask of.
732 * @param m The mask to compare against.
733 * @return True if m & table[c] is true, false otherwise.
736 is(mask __m
, char __c
) const;
739 * @brief Return a mask array.
741 * This function finds the mask for each char in the range [lo, hi) and
742 * successively writes it to vec. vec must have as many elements as
745 * @param lo Pointer to start of range.
746 * @param hi Pointer to end of range.
747 * @param vec Pointer to an array of mask storage.
751 is(const char* __lo
, const char* __hi
, mask
* __vec
) const;
754 * @brief Find char matching a mask
756 * This function searches for and returns the first char in [lo,hi) for
757 * which is(m,char) is true.
759 * @param m The mask to compare against.
760 * @param lo Pointer to start of range.
761 * @param hi Pointer to end of range.
762 * @return Pointer to a matching char if found, else @a hi.
765 scan_is(mask __m
, const char* __lo
, const char* __hi
) const;
768 * @brief Find char not matching a mask
770 * This function searches for and returns a pointer to the first char
771 * in [lo,hi) for which is(m,char) is false.
773 * @param m The mask to compare against.
774 * @param lo Pointer to start of range.
775 * @param hi Pointer to end of range.
776 * @return Pointer to a non-matching char if found, else @a hi.
779 scan_not(mask __m
, const char* __lo
, const char* __hi
) const;
782 * @brief Convert to uppercase.
784 * This function converts the char argument to uppercase if possible.
785 * If not possible (for example, '2'), returns the argument.
787 * toupper() acts as if it returns ctype<char>::do_toupper(c).
788 * do_toupper() must always return the same result for the same input.
790 * @param c The char to convert.
791 * @return The uppercase char if convertible, else @a c.
794 toupper(char_type __c
) const
795 { return this->do_toupper(__c
); }
798 * @brief Convert array to uppercase.
800 * This function converts each char in the range [lo,hi) to uppercase
801 * if possible. Other chars remain untouched.
803 * toupper() acts as if it returns ctype<char>:: do_toupper(lo, hi).
804 * do_toupper() must always return the same result for the same input.
806 * @param lo Pointer to first char in range.
807 * @param hi Pointer to end of range.
811 toupper(char_type
*__lo
, const char_type
* __hi
) const
812 { return this->do_toupper(__lo
, __hi
); }
815 * @brief Convert to lowercase.
817 * This function converts the char argument to lowercase if possible.
818 * If not possible (for example, '2'), returns the argument.
820 * tolower() acts as if it returns ctype<char>::do_tolower(c).
821 * do_tolower() must always return the same result for the same input.
823 * @param c The char to convert.
824 * @return The lowercase char if convertible, else @a c.
827 tolower(char_type __c
) const
828 { return this->do_tolower(__c
); }
831 * @brief Convert array to lowercase.
833 * This function converts each char in the range [lo,hi) to lowercase
834 * if possible. Other chars remain untouched.
836 * tolower() acts as if it returns ctype<char>:: do_tolower(lo, hi).
837 * do_tolower() must always return the same result for the same input.
839 * @param lo Pointer to first char in range.
840 * @param hi Pointer to end of range.
844 tolower(char_type
* __lo
, const char_type
* __hi
) const
845 { return this->do_tolower(__lo
, __hi
); }
850 * This function converts the char to char_type using the simplest
851 * reasonable transformation. For an underived ctype<char> facet, the
852 * argument will be returned unchanged.
854 * This function works as if it returns ctype<char>::do_widen(c).
855 * do_widen() must always return the same result for the same input.
857 * Note: this is not what you want for codepage conversions. See
860 * @param c The char to convert.
861 * @return The converted character.
864 widen(char __c
) const
867 return _M_widen
[static_cast<unsigned char>(__c
)];
868 this->_M_widen_init();
869 return this->do_widen(__c
);
873 * @brief Widen char array
875 * This function converts each char in the input to char using the
876 * simplest reasonable transformation. For an underived ctype<char>
877 * facet, the argument will be copied unchanged.
879 * This function works as if it returns ctype<char>::do_widen(c).
880 * do_widen() must always return the same result for the same input.
882 * Note: this is not what you want for codepage conversions. See
885 * @param lo Pointer to first char in range.
886 * @param hi Pointer to end of range.
887 * @param to Pointer to the destination array.
891 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
893 if (_M_widen_ok
== 1)
895 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
900 return this->do_widen(__lo
, __hi
, __to
);
906 * This function converts the char to char using the simplest
907 * reasonable transformation. If the conversion fails, dfault is
908 * returned instead. For an underived ctype<char> facet, @a c
909 * will be returned unchanged.
911 * This function works as if it returns ctype<char>::do_narrow(c).
912 * do_narrow() must always return the same result for the same input.
914 * Note: this is not what you want for codepage conversions. See
917 * @param c The char to convert.
918 * @param dfault Char to return if conversion fails.
919 * @return The converted character.
922 narrow(char_type __c
, char __dfault
) const
924 if (_M_narrow
[static_cast<unsigned char>(__c
)])
925 return _M_narrow
[static_cast<unsigned char>(__c
)];
926 const char __t
= do_narrow(__c
, __dfault
);
928 _M_narrow
[static_cast<unsigned char>(__c
)] = __t
;
933 * @brief Narrow char array
935 * This function converts each char in the input to char using the
936 * simplest reasonable transformation and writes the results to the
937 * destination array. For any char in the input that cannot be
938 * converted, @a dfault is used instead. For an underived ctype<char>
939 * facet, the argument will be copied unchanged.
941 * This function works as if it returns ctype<char>::do_narrow(lo, hi,
942 * dfault, to). do_narrow() must always return the same result for the
945 * Note: this is not what you want for codepage conversions. See
948 * @param lo Pointer to start of range.
949 * @param hi Pointer to end of range.
950 * @param dfault Char to use if conversion fails.
951 * @param to Pointer to the destination array.
955 narrow(const char_type
* __lo
, const char_type
* __hi
,
956 char __dfault
, char *__to
) const
958 if (__builtin_expect(_M_narrow_ok
== 1, true))
960 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
965 return this->do_narrow(__lo
, __hi
, __dfault
, __to
);
968 // _GLIBCXX_RESOLVE_LIB_DEFECTS
969 // DR 695. ctype<char>::classic_table() not accessible.
970 /// Returns a pointer to the mask table provided to the constructor, or
971 /// the default from classic_table() if none was provided.
973 table() const throw()
976 /// Returns a pointer to the C locale mask table.
978 classic_table() throw();
984 * This function deletes table() if @a del was true in the
991 * @brief Convert to uppercase.
993 * This virtual function converts the char argument to uppercase if
994 * possible. If not possible (for example, '2'), returns the argument.
996 * do_toupper() is a hook for a derived facet to change the behavior of
997 * uppercasing. do_toupper() must always return the same result for
1000 * @param c The char to convert.
1001 * @return The uppercase char if convertible, else @a c.
1004 do_toupper(char_type
) const;
1007 * @brief Convert array to uppercase.
1009 * This virtual function converts each char in the range [lo,hi) to
1010 * uppercase if possible. Other chars remain untouched.
1012 * do_toupper() is a hook for a derived facet to change the behavior of
1013 * uppercasing. do_toupper() must always return the same result for
1016 * @param lo Pointer to start of range.
1017 * @param hi Pointer to end of range.
1020 virtual const char_type
*
1021 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
1024 * @brief Convert to lowercase.
1026 * This virtual function converts the char argument to lowercase if
1027 * possible. If not possible (for example, '2'), returns the argument.
1029 * do_tolower() is a hook for a derived facet to change the behavior of
1030 * lowercasing. do_tolower() must always return the same result for
1033 * @param c The char to convert.
1034 * @return The lowercase char if convertible, else @a c.
1037 do_tolower(char_type
) const;
1040 * @brief Convert array to lowercase.
1042 * This virtual function converts each char in the range [lo,hi) to
1043 * lowercase if possible. Other chars remain untouched.
1045 * do_tolower() is a hook for a derived facet to change the behavior of
1046 * lowercasing. do_tolower() must always return the same result for
1049 * @param lo Pointer to first char in range.
1050 * @param hi Pointer to end of range.
1053 virtual const char_type
*
1054 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
1059 * This virtual function converts the char to char using the simplest
1060 * reasonable transformation. For an underived ctype<char> facet, the
1061 * argument will be returned unchanged.
1063 * do_widen() is a hook for a derived facet to change the behavior of
1064 * widening. do_widen() must always return the same result for the
1067 * Note: this is not what you want for codepage conversions. See
1070 * @param c The char to convert.
1071 * @return The converted character.
1074 do_widen(char __c
) const
1078 * @brief Widen char array
1080 * This function converts each char in the range [lo,hi) to char using
1081 * the simplest reasonable transformation. For an underived
1082 * ctype<char> facet, the argument will be copied unchanged.
1084 * do_widen() is a hook for a derived facet to change the behavior of
1085 * widening. do_widen() must always return the same result for the
1088 * Note: this is not what you want for codepage conversions. See
1091 * @param lo Pointer to start of range.
1092 * @param hi Pointer to end of range.
1093 * @param to Pointer to the destination array.
1097 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const
1099 __builtin_memcpy(__dest
, __lo
, __hi
- __lo
);
1104 * @brief Narrow char
1106 * This virtual function converts the char to char using the simplest
1107 * reasonable transformation. If the conversion fails, dfault is
1108 * returned instead. For an underived ctype<char> facet, @a c will be
1109 * returned unchanged.
1111 * do_narrow() is a hook for a derived facet to change the behavior of
1112 * narrowing. do_narrow() must always return the same result for the
1115 * Note: this is not what you want for codepage conversions. See
1118 * @param c The char to convert.
1119 * @param dfault Char to return if conversion fails.
1120 * @return The converted char.
1123 do_narrow(char_type __c
, char) const
1127 * @brief Narrow char array to char array
1129 * This virtual function converts each char in the range [lo,hi) to
1130 * char using the simplest reasonable transformation and writes the
1131 * results to the destination array. For any char in the input that
1132 * cannot be converted, @a dfault is used instead. For an underived
1133 * ctype<char> facet, the argument will be copied unchanged.
1135 * do_narrow() is a hook for a derived facet to change the behavior of
1136 * narrowing. do_narrow() must always return the same result for the
1139 * Note: this is not what you want for codepage conversions. See
1142 * @param lo Pointer to start of range.
1143 * @param hi Pointer to end of range.
1144 * @param dfault Char to use if conversion fails.
1145 * @param to Pointer to the destination array.
1148 virtual const char_type
*
1149 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
1150 char, char* __dest
) const
1152 __builtin_memcpy(__dest
, __lo
, __hi
- __lo
);
1157 void _M_narrow_init() const;
1158 void _M_widen_init() const;
1161 #ifdef _GLIBCXX_USE_WCHAR_T
1163 * @brief The ctype<wchar_t> specialization.
1166 * This class defines classification and conversion functions for the
1167 * wchar_t type. It gets used by wchar_t streams for many I/O operations.
1168 * The wchar_t specialization provides a number of optimizations as well.
1170 * ctype<wchar_t> inherits its public methods from
1171 * __ctype_abstract_base<wchar_t>.
1174 class ctype
<wchar_t> : public __ctype_abstract_base
<wchar_t>
1178 /// Typedef for the template parameter wchar_t.
1179 typedef wchar_t char_type
;
1180 typedef wctype_t __wmask_type
;
1183 __c_locale _M_c_locale_ctype
;
1185 // Pre-computed narrowed and widened chars.
1187 char _M_narrow
[128];
1188 wint_t _M_widen
[1 + static_cast<unsigned char>(-1)];
1190 // Pre-computed elements for do_is.
1192 __wmask_type _M_wmask
[16];
1196 /// The facet id for ctype<wchar_t>
1197 static locale::id id
;
1200 * @brief Constructor performs initialization.
1202 * This is the constructor provided by the standard.
1204 * @param refs Passed to the base facet class.
1207 ctype(size_t __refs
= 0);
1210 * @brief Constructor performs static initialization.
1212 * This constructor is used to construct the initial C locale facet.
1214 * @param cloc Handle to C locale data.
1215 * @param refs Passed to the base facet class.
1218 ctype(__c_locale __cloc
, size_t __refs
= 0);
1222 _M_convert_to_wmask(const mask __m
) const throw();
1229 * @brief Test wchar_t classification.
1231 * This function finds a mask M for @a c and compares it to mask @a m.
1233 * do_is() is a hook for a derived facet to change the behavior of
1234 * classifying. do_is() must always return the same result for the
1237 * @param c The wchar_t to find the mask of.
1238 * @param m The mask to compare against.
1239 * @return (M & m) != 0.
1242 do_is(mask __m
, char_type __c
) const;
1245 * @brief Return a mask array.
1247 * This function finds the mask for each wchar_t in the range [lo,hi)
1248 * and successively writes it to vec. vec must have as many elements
1251 * do_is() is a hook for a derived facet to change the behavior of
1252 * classifying. do_is() must always return the same result for the
1255 * @param lo Pointer to start of range.
1256 * @param hi Pointer to end of range.
1257 * @param vec Pointer to an array of mask storage.
1260 virtual const char_type
*
1261 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
1264 * @brief Find wchar_t matching mask
1266 * This function searches for and returns the first wchar_t c in
1267 * [lo,hi) for which is(m,c) is true.
1269 * do_scan_is() is a hook for a derived facet to change the behavior of
1270 * match searching. do_is() must always return the same result for the
1273 * @param m The mask to compare against.
1274 * @param lo Pointer to start of range.
1275 * @param hi Pointer to end of range.
1276 * @return Pointer to a matching wchar_t if found, else @a hi.
1278 virtual const char_type
*
1279 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
1282 * @brief Find wchar_t not matching mask
1284 * This function searches for and returns a pointer to the first
1285 * wchar_t c of [lo,hi) for which is(m,c) is false.
1287 * do_scan_is() is a hook for a derived facet to change the behavior of
1288 * match searching. do_is() must always return the same result for the
1291 * @param m The mask to compare against.
1292 * @param lo Pointer to start of range.
1293 * @param hi Pointer to end of range.
1294 * @return Pointer to a non-matching wchar_t if found, else @a hi.
1296 virtual const char_type
*
1297 do_scan_not(mask __m
, const char_type
* __lo
,
1298 const char_type
* __hi
) const;
1301 * @brief Convert to uppercase.
1303 * This virtual function converts the wchar_t argument to uppercase if
1304 * possible. If not possible (for example, '2'), returns the argument.
1306 * do_toupper() is a hook for a derived facet to change the behavior of
1307 * uppercasing. do_toupper() must always return the same result for
1310 * @param c The wchar_t to convert.
1311 * @return The uppercase wchar_t if convertible, else @a c.
1314 do_toupper(char_type
) const;
1317 * @brief Convert array to uppercase.
1319 * This virtual function converts each wchar_t in the range [lo,hi) to
1320 * uppercase if possible. Other elements remain untouched.
1322 * do_toupper() is a hook for a derived facet to change the behavior of
1323 * uppercasing. do_toupper() must always return the same result for
1326 * @param lo Pointer to start of range.
1327 * @param hi Pointer to end of range.
1330 virtual const char_type
*
1331 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
1334 * @brief Convert to lowercase.
1336 * This virtual function converts the argument to lowercase if
1337 * possible. If not possible (for example, '2'), returns the argument.
1339 * do_tolower() is a hook for a derived facet to change the behavior of
1340 * lowercasing. do_tolower() must always return the same result for
1343 * @param c The wchar_t to convert.
1344 * @return The lowercase wchar_t if convertible, else @a c.
1347 do_tolower(char_type
) const;
1350 * @brief Convert array to lowercase.
1352 * This virtual function converts each wchar_t in the range [lo,hi) to
1353 * lowercase if possible. Other elements remain untouched.
1355 * do_tolower() is a hook for a derived facet to change the behavior of
1356 * lowercasing. do_tolower() must always return the same result for
1359 * @param lo Pointer to start of range.
1360 * @param hi Pointer to end of range.
1363 virtual const char_type
*
1364 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
1367 * @brief Widen char to wchar_t
1369 * This virtual function converts the char to wchar_t using the
1370 * simplest reasonable transformation. For an underived ctype<wchar_t>
1371 * facet, the argument will be cast to wchar_t.
1373 * do_widen() is a hook for a derived facet to change the behavior of
1374 * widening. do_widen() must always return the same result for the
1377 * Note: this is not what you want for codepage conversions. See
1380 * @param c The char to convert.
1381 * @return The converted wchar_t.
1384 do_widen(char) const;
1387 * @brief Widen char array to wchar_t array
1389 * This function converts each char in the input to wchar_t using the
1390 * simplest reasonable transformation. For an underived ctype<wchar_t>
1391 * facet, the argument will be copied, casting each element to wchar_t.
1393 * do_widen() is a hook for a derived facet to change the behavior of
1394 * widening. do_widen() must always return the same result for the
1397 * Note: this is not what you want for codepage conversions. See
1400 * @param lo Pointer to start range.
1401 * @param hi Pointer to end of range.
1402 * @param to Pointer to the destination array.
1406 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
1409 * @brief Narrow wchar_t to char
1411 * This virtual function converts the argument to char using
1412 * the simplest reasonable transformation. If the conversion
1413 * fails, dfault is returned instead. For an underived
1414 * ctype<wchar_t> facet, @a c will be cast to char and
1417 * do_narrow() is a hook for a derived facet to change the
1418 * behavior of narrowing. do_narrow() must always return the
1419 * same result for the same input.
1421 * Note: this is not what you want for codepage conversions. See
1424 * @param c The wchar_t to convert.
1425 * @param dfault Char to return if conversion fails.
1426 * @return The converted char.
1429 do_narrow(char_type
, char __dfault
) const;
1432 * @brief Narrow wchar_t array to char array
1434 * This virtual function converts each wchar_t in the range [lo,hi) to
1435 * char using the simplest reasonable transformation and writes the
1436 * results to the destination array. For any wchar_t in the input that
1437 * cannot be converted, @a dfault is used instead. For an underived
1438 * ctype<wchar_t> facet, the argument will be copied, casting each
1441 * do_narrow() is a hook for a derived facet to change the behavior of
1442 * narrowing. do_narrow() must always return the same result for the
1445 * Note: this is not what you want for codepage conversions. See
1448 * @param lo Pointer to start of range.
1449 * @param hi Pointer to end of range.
1450 * @param dfault Char to use if conversion fails.
1451 * @param to Pointer to the destination array.
1454 virtual const char_type
*
1455 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
1456 char __dfault
, char* __dest
) const;
1458 // For use at construction time only.
1460 _M_initialize_ctype() throw();
1462 #endif //_GLIBCXX_USE_WCHAR_T
1464 /// class ctype_byname [22.2.1.2].
1465 template<typename _CharT
>
1466 class ctype_byname
: public ctype
<_CharT
>
1469 typedef typename ctype
<_CharT
>::mask mask
;
1472 ctype_byname(const char* __s
, size_t __refs
= 0);
1476 ~ctype_byname() { };
1479 /// 22.2.1.4 Class ctype_byname specializations.
1481 class ctype_byname
<char> : public ctype
<char>
1485 ctype_byname(const char* __s
, size_t __refs
= 0);
1492 #ifdef _GLIBCXX_USE_WCHAR_T
1494 class ctype_byname
<wchar_t> : public ctype
<wchar_t>
1498 ctype_byname(const char* __s
, size_t __refs
= 0);
1506 _GLIBCXX_END_NAMESPACE
1508 // Include host and configuration specific ctype inlines.
1509 #include <bits/ctype_inline.h>
1511 _GLIBCXX_BEGIN_NAMESPACE(std
)
1513 // 22.2.2 The numeric category.
1517 // NB: Code depends on the order of _S_atoms_out elements.
1518 // Below are the indices into _S_atoms_out.
1526 _S_odigits_end
= _S_odigits
+ 16,
1527 _S_oudigits
= _S_odigits_end
,
1528 _S_oudigits_end
= _S_oudigits
+ 16,
1529 _S_oe
= _S_odigits
+ 14, // For scientific notation, 'e'
1530 _S_oE
= _S_oudigits
+ 14, // For scientific notation, 'E'
1531 _S_oend
= _S_oudigits_end
1534 // A list of valid numeric literals for output. This array
1535 // contains chars that will be passed through the current locale's
1536 // ctype<_CharT>.widen() and then used to render numbers.
1537 // For the standard "C" locale, this is
1538 // "-+xX0123456789abcdef0123456789ABCDEF".
1539 static const char* _S_atoms_out
;
1541 // String literal of acceptable (narrow) input, for num_get.
1542 // "-+xX0123456789abcdefABCDEF"
1543 static const char* _S_atoms_in
;
1552 _S_ie
= _S_izero
+ 14,
1553 _S_iE
= _S_izero
+ 20,
1558 // Construct and return valid scanf format for floating point types.
1560 _S_format_float(const ios_base
& __io
, char* __fptr
, char __mod
) throw();
1563 template<typename _CharT
>
1564 struct __numpunct_cache
: public locale::facet
1566 const char* _M_grouping
;
1567 size_t _M_grouping_size
;
1568 bool _M_use_grouping
;
1569 const _CharT
* _M_truename
;
1570 size_t _M_truename_size
;
1571 const _CharT
* _M_falsename
;
1572 size_t _M_falsename_size
;
1573 _CharT _M_decimal_point
;
1574 _CharT _M_thousands_sep
;
1576 // A list of valid numeric literals for output: in the standard
1577 // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
1578 // This array contains the chars after having been passed
1579 // through the current locale's ctype<_CharT>.widen().
1580 _CharT _M_atoms_out
[__num_base::_S_oend
];
1582 // A list of valid numeric literals for input: in the standard
1583 // "C" locale, this is "-+xX0123456789abcdefABCDEF"
1584 // This array contains the chars after having been passed
1585 // through the current locale's ctype<_CharT>.widen().
1586 _CharT _M_atoms_in
[__num_base::_S_iend
];
1590 __numpunct_cache(size_t __refs
= 0)
1591 : facet(__refs
), _M_grouping(0), _M_grouping_size(0),
1592 _M_use_grouping(false),
1593 _M_truename(0), _M_truename_size(0), _M_falsename(0),
1594 _M_falsename_size(0), _M_decimal_point(_CharT()),
1595 _M_thousands_sep(_CharT()), _M_allocated(false)
1598 ~__numpunct_cache();
1601 _M_cache(const locale
& __loc
);
1605 operator=(const __numpunct_cache
&);
1608 __numpunct_cache(const __numpunct_cache
&);
1611 template<typename _CharT
>
1612 __numpunct_cache
<_CharT
>::~__numpunct_cache()
1616 delete [] _M_grouping
;
1617 delete [] _M_truename
;
1618 delete [] _M_falsename
;
1623 * @brief Primary class template numpunct.
1626 * This facet stores several pieces of information related to printing and
1627 * scanning numbers, such as the decimal point character. It takes a
1628 * template parameter specifying the char type. The numpunct facet is
1629 * used by streams for many I/O operations involving numbers.
1631 * The numpunct template uses protected virtual functions to provide the
1632 * actual results. The public accessors forward the call to the virtual
1633 * functions. These virtual functions are hooks for developers to
1634 * implement the behavior they require from a numpunct facet.
1636 template<typename _CharT
>
1637 class numpunct
: public locale::facet
1643 typedef _CharT char_type
;
1644 typedef basic_string
<_CharT
> string_type
;
1646 typedef __numpunct_cache
<_CharT
> __cache_type
;
1649 __cache_type
* _M_data
;
1652 /// Numpunct facet id.
1653 static locale::id id
;
1656 * @brief Numpunct constructor.
1658 * @param refs Refcount to pass to the base class.
1661 numpunct(size_t __refs
= 0)
1662 : facet(__refs
), _M_data(0)
1663 { _M_initialize_numpunct(); }
1666 * @brief Internal constructor. Not for general use.
1668 * This is a constructor for use by the library itself to set up the
1669 * predefined locale facets.
1671 * @param cache __numpunct_cache object.
1672 * @param refs Refcount to pass to the base class.
1675 numpunct(__cache_type
* __cache
, size_t __refs
= 0)
1676 : facet(__refs
), _M_data(__cache
)
1677 { _M_initialize_numpunct(); }
1680 * @brief Internal constructor. Not for general use.
1682 * This is a constructor for use by the library itself to set up new
1685 * @param cloc The C locale.
1686 * @param refs Refcount to pass to the base class.
1689 numpunct(__c_locale __cloc
, size_t __refs
= 0)
1690 : facet(__refs
), _M_data(0)
1691 { _M_initialize_numpunct(__cloc
); }
1694 * @brief Return decimal point character.
1696 * This function returns a char_type to use as a decimal point. It
1697 * does so by returning returning
1698 * numpunct<char_type>::do_decimal_point().
1700 * @return @a char_type representing a decimal point.
1703 decimal_point() const
1704 { return this->do_decimal_point(); }
1707 * @brief Return thousands separator character.
1709 * This function returns a char_type to use as a thousands
1710 * separator. It does so by returning returning
1711 * numpunct<char_type>::do_thousands_sep().
1713 * @return char_type representing a thousands separator.
1716 thousands_sep() const
1717 { return this->do_thousands_sep(); }
1720 * @brief Return grouping specification.
1722 * This function returns a string representing groupings for the
1723 * integer part of a number. Groupings indicate where thousands
1724 * separators should be inserted in the integer part of a number.
1726 * Each char in the return string is interpret as an integer
1727 * rather than a character. These numbers represent the number
1728 * of digits in a group. The first char in the string
1729 * represents the number of digits in the least significant
1730 * group. If a char is negative, it indicates an unlimited
1731 * number of digits for the group. If more chars from the
1732 * string are required to group a number, the last char is used
1735 * For example, if the grouping() returns "\003\002" and is
1736 * applied to the number 123456789, this corresponds to
1737 * 12,34,56,789. Note that if the string was "32", this would
1738 * put more than 50 digits into the least significant group if
1739 * the character set is ASCII.
1741 * The string is returned by calling
1742 * numpunct<char_type>::do_grouping().
1744 * @return string representing grouping specification.
1748 { return this->do_grouping(); }
1751 * @brief Return string representation of bool true.
1753 * This function returns a string_type containing the text
1754 * representation for true bool variables. It does so by calling
1755 * numpunct<char_type>::do_truename().
1757 * @return string_type representing printed form of true.
1761 { return this->do_truename(); }
1764 * @brief Return string representation of bool false.
1766 * This function returns a string_type containing the text
1767 * representation for false bool variables. It does so by calling
1768 * numpunct<char_type>::do_falsename().
1770 * @return string_type representing printed form of false.
1774 { return this->do_falsename(); }
1782 * @brief Return decimal point character.
1784 * Returns a char_type to use as a decimal point. This function is a
1785 * hook for derived classes to change the value returned.
1787 * @return @a char_type representing a decimal point.
1790 do_decimal_point() const
1791 { return _M_data
->_M_decimal_point
; }
1794 * @brief Return thousands separator character.
1796 * Returns a char_type to use as a thousands separator. This function
1797 * is a hook for derived classes to change the value returned.
1799 * @return @a char_type representing a thousands separator.
1802 do_thousands_sep() const
1803 { return _M_data
->_M_thousands_sep
; }
1806 * @brief Return grouping specification.
1808 * Returns a string representing groupings for the integer part of a
1809 * number. This function is a hook for derived classes to change the
1810 * value returned. @see grouping() for details.
1812 * @return String representing grouping specification.
1816 { return _M_data
->_M_grouping
; }
1819 * @brief Return string representation of bool true.
1821 * Returns a string_type containing the text representation for true
1822 * bool variables. This function is a hook for derived classes to
1823 * change the value returned.
1825 * @return string_type representing printed form of true.
1829 { return _M_data
->_M_truename
; }
1832 * @brief Return string representation of bool false.
1834 * Returns a string_type containing the text representation for false
1835 * bool variables. This function is a hook for derived classes to
1836 * change the value returned.
1838 * @return string_type representing printed form of false.
1841 do_falsename() const
1842 { return _M_data
->_M_falsename
; }
1844 // For use at construction time only.
1846 _M_initialize_numpunct(__c_locale __cloc
= 0);
1849 template<typename _CharT
>
1850 locale::id numpunct
<_CharT
>::id
;
1853 numpunct
<char>::~numpunct();
1857 numpunct
<char>::_M_initialize_numpunct(__c_locale __cloc
);
1859 #ifdef _GLIBCXX_USE_WCHAR_T
1861 numpunct
<wchar_t>::~numpunct();
1865 numpunct
<wchar_t>::_M_initialize_numpunct(__c_locale __cloc
);
1868 /// class numpunct_byname [22.2.3.2].
1869 template<typename _CharT
>
1870 class numpunct_byname
: public numpunct
<_CharT
>
1873 typedef _CharT char_type
;
1874 typedef basic_string
<_CharT
> string_type
;
1877 numpunct_byname(const char* __s
, size_t __refs
= 0)
1878 : numpunct
<_CharT
>(__refs
)
1880 if (__builtin_strcmp(__s
, "C") != 0
1881 && __builtin_strcmp(__s
, "POSIX") != 0)
1884 this->_S_create_c_locale(__tmp
, __s
);
1885 this->_M_initialize_numpunct(__tmp
);
1886 this->_S_destroy_c_locale(__tmp
);
1892 ~numpunct_byname() { }
1895 _GLIBCXX_BEGIN_LDBL_NAMESPACE
1898 * @brief Primary class template num_get.
1901 * This facet encapsulates the code to parse and return a number
1902 * from a string. It is used by the istream numeric extraction
1905 * The num_get template uses protected virtual functions to provide the
1906 * actual results. The public accessors forward the call to the virtual
1907 * functions. These virtual functions are hooks for developers to
1908 * implement the behavior they require from the num_get facet.
1910 template<typename _CharT
, typename _InIter
>
1911 class num_get
: public locale::facet
1917 typedef _CharT char_type
;
1918 typedef _InIter iter_type
;
1921 /// Numpunct facet id.
1922 static locale::id id
;
1925 * @brief Constructor performs initialization.
1927 * This is the constructor provided by the standard.
1929 * @param refs Passed to the base facet class.
1932 num_get(size_t __refs
= 0) : facet(__refs
) { }
1935 * @brief Numeric parsing.
1937 * Parses the input stream into the bool @a v. It does so by calling
1938 * num_get::do_get().
1940 * If ios_base::boolalpha is set, attempts to read
1941 * ctype<CharT>::truename() or ctype<CharT>::falsename(). Sets
1942 * @a v to true or false if successful. Sets err to
1943 * ios_base::failbit if reading the string fails. Sets err to
1944 * ios_base::eofbit if the stream is emptied.
1946 * If ios_base::boolalpha is not set, proceeds as with reading a long,
1947 * except if the value is 1, sets @a v to true, if the value is 0, sets
1948 * @a v to false, and otherwise set err to ios_base::failbit.
1950 * @param in Start of input stream.
1951 * @param end End of input stream.
1952 * @param io Source of locale and flags.
1953 * @param err Error flags to set.
1954 * @param v Value to format and insert.
1955 * @return Iterator after reading.
1958 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
1959 ios_base::iostate
& __err
, bool& __v
) const
1960 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
1964 * @brief Numeric parsing.
1966 * Parses the input stream into the integral variable @a v. It does so
1967 * by calling num_get::do_get().
1969 * Parsing is affected by the flag settings in @a io.
1971 * The basic parse is affected by the value of io.flags() &
1972 * ios_base::basefield. If equal to ios_base::oct, parses like the
1973 * scanf %o specifier. Else if equal to ios_base::hex, parses like %X
1974 * specifier. Else if basefield equal to 0, parses like the %i
1975 * specifier. Otherwise, parses like %d for signed and %u for unsigned
1976 * types. The matching type length modifier is also used.
1978 * Digit grouping is interpreted according to numpunct::grouping() and
1979 * numpunct::thousands_sep(). If the pattern of digit groups isn't
1980 * consistent, sets err to ios_base::failbit.
1982 * If parsing the string yields a valid value for @a v, @a v is set.
1983 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
1984 * Sets err to ios_base::eofbit if the stream is emptied.
1986 * @param in Start of input stream.
1987 * @param end End of input stream.
1988 * @param io Source of locale and flags.
1989 * @param err Error flags to set.
1990 * @param v Value to format and insert.
1991 * @return Iterator after reading.
1994 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
1995 ios_base::iostate
& __err
, long& __v
) const
1996 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
1999 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2000 ios_base::iostate
& __err
, unsigned short& __v
) const
2001 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2004 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2005 ios_base::iostate
& __err
, unsigned int& __v
) const
2006 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2009 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2010 ios_base::iostate
& __err
, unsigned long& __v
) const
2011 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2013 #ifdef _GLIBCXX_USE_LONG_LONG
2015 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2016 ios_base::iostate
& __err
, long long& __v
) const
2017 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2020 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2021 ios_base::iostate
& __err
, unsigned long long& __v
) const
2022 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2028 * @brief Numeric parsing.
2030 * Parses the input stream into the integral variable @a v. It does so
2031 * by calling num_get::do_get().
2033 * The input characters are parsed like the scanf %g specifier. The
2034 * matching type length modifier is also used.
2036 * The decimal point character used is numpunct::decimal_point().
2037 * Digit grouping is interpreted according to numpunct::grouping() and
2038 * numpunct::thousands_sep(). If the pattern of digit groups isn't
2039 * consistent, sets err to ios_base::failbit.
2041 * If parsing the string yields a valid value for @a v, @a v is set.
2042 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2043 * Sets err to ios_base::eofbit if the stream is emptied.
2045 * @param in Start of input stream.
2046 * @param end End of input stream.
2047 * @param io Source of locale and flags.
2048 * @param err Error flags to set.
2049 * @param v Value to format and insert.
2050 * @return Iterator after reading.
2053 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2054 ios_base::iostate
& __err
, float& __v
) const
2055 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2058 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2059 ios_base::iostate
& __err
, double& __v
) const
2060 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2063 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2064 ios_base::iostate
& __err
, long double& __v
) const
2065 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2069 * @brief Numeric parsing.
2071 * Parses the input stream into the pointer variable @a v. It does so
2072 * by calling num_get::do_get().
2074 * The input characters are parsed like the scanf %p specifier.
2076 * Digit grouping is interpreted according to numpunct::grouping() and
2077 * numpunct::thousands_sep(). If the pattern of digit groups isn't
2078 * consistent, sets err to ios_base::failbit.
2080 * Note that the digit grouping effect for pointers is a bit ambiguous
2081 * in the standard and shouldn't be relied on. See DR 344.
2083 * If parsing the string yields a valid value for @a v, @a v is set.
2084 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2085 * Sets err to ios_base::eofbit if the stream is emptied.
2087 * @param in Start of input stream.
2088 * @param end End of input stream.
2089 * @param io Source of locale and flags.
2090 * @param err Error flags to set.
2091 * @param v Value to format and insert.
2092 * @return Iterator after reading.
2095 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2096 ios_base::iostate
& __err
, void*& __v
) const
2097 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2101 virtual ~num_get() { }
2104 _M_extract_float(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2107 template<typename _ValueT
>
2109 _M_extract_int(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2112 template<typename _CharT2
>
2113 typename
__gnu_cxx::__enable_if
<__is_char
<_CharT2
>::__value
, int>::__type
2114 _M_find(const _CharT2
*, size_t __len
, _CharT2 __c
) const
2119 if (__c
>= _CharT2('0') && __c
< _CharT2(_CharT2('0') + __len
))
2120 __ret
= __c
- _CharT2('0');
2124 if (__c
>= _CharT2('0') && __c
<= _CharT2('9'))
2125 __ret
= __c
- _CharT2('0');
2126 else if (__c
>= _CharT2('a') && __c
<= _CharT2('f'))
2127 __ret
= 10 + (__c
- _CharT2('a'));
2128 else if (__c
>= _CharT2('A') && __c
<= _CharT2('F'))
2129 __ret
= 10 + (__c
- _CharT2('A'));
2134 template<typename _CharT2
>
2135 typename
__gnu_cxx::__enable_if
<!__is_char
<_CharT2
>::__value
,
2137 _M_find(const _CharT2
* __zero
, size_t __len
, _CharT2 __c
) const
2140 const char_type
* __q
= char_traits
<_CharT2
>::find(__zero
, __len
, __c
);
2143 __ret
= __q
- __zero
;
2152 * @brief Numeric parsing.
2154 * Parses the input stream into the variable @a v. This function is a
2155 * hook for derived classes to change the value returned. @see get()
2158 * @param in Start of input stream.
2159 * @param end End of input stream.
2160 * @param io Source of locale and flags.
2161 * @param err Error flags to set.
2162 * @param v Value to format and insert.
2163 * @return Iterator after reading.
2166 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, bool&) const;
2169 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2170 ios_base::iostate
& __err
, long& __v
) const
2171 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2174 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2175 ios_base::iostate
& __err
, unsigned short& __v
) const
2176 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2179 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2180 ios_base::iostate
& __err
, unsigned int& __v
) const
2181 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2184 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2185 ios_base::iostate
& __err
, unsigned long& __v
) const
2186 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2188 #ifdef _GLIBCXX_USE_LONG_LONG
2190 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2191 ios_base::iostate
& __err
, long long& __v
) const
2192 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2195 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2196 ios_base::iostate
& __err
, unsigned long long& __v
) const
2197 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2201 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2205 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2208 // XXX GLIBCXX_ABI Deprecated
2209 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2211 __do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2215 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2216 long double&) const;
2220 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2223 // XXX GLIBCXX_ABI Deprecated
2224 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2226 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2227 long double&) const;
2232 template<typename _CharT
, typename _InIter
>
2233 locale::id num_get
<_CharT
, _InIter
>::id
;
2237 * @brief Primary class template num_put.
2240 * This facet encapsulates the code to convert a number to a string. It is
2241 * used by the ostream numeric insertion operators.
2243 * The num_put template uses protected virtual functions to provide the
2244 * actual results. The public accessors forward the call to the virtual
2245 * functions. These virtual functions are hooks for developers to
2246 * implement the behavior they require from the num_put facet.
2248 template<typename _CharT
, typename _OutIter
>
2249 class num_put
: public locale::facet
2255 typedef _CharT char_type
;
2256 typedef _OutIter iter_type
;
2259 /// Numpunct facet id.
2260 static locale::id id
;
2263 * @brief Constructor performs initialization.
2265 * This is the constructor provided by the standard.
2267 * @param refs Passed to the base facet class.
2270 num_put(size_t __refs
= 0) : facet(__refs
) { }
2273 * @brief Numeric formatting.
2275 * Formats the boolean @a v and inserts it into a stream. It does so
2276 * by calling num_put::do_put().
2278 * If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
2279 * ctype<CharT>::falsename(). Otherwise formats @a v as an int.
2281 * @param s Stream to write to.
2282 * @param io Source of locale and flags.
2283 * @param fill Char_type to use for filling.
2284 * @param v Value to format and insert.
2285 * @return Iterator after writing.
2288 put(iter_type __s
, ios_base
& __f
, char_type __fill
, bool __v
) const
2289 { return this->do_put(__s
, __f
, __fill
, __v
); }
2293 * @brief Numeric formatting.
2295 * Formats the integral value @a v and inserts it into a
2296 * stream. It does so by calling num_put::do_put().
2298 * Formatting is affected by the flag settings in @a io.
2300 * The basic format is affected by the value of io.flags() &
2301 * ios_base::basefield. If equal to ios_base::oct, formats like the
2302 * printf %o specifier. Else if equal to ios_base::hex, formats like
2303 * %x or %X with ios_base::uppercase unset or set respectively.
2304 * Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
2305 * for unsigned values. Note that if both oct and hex are set, neither
2308 * If ios_base::showpos is set, '+' is output before positive values.
2309 * If ios_base::showbase is set, '0' precedes octal values (except 0)
2310 * and '0[xX]' precedes hex values.
2312 * Thousands separators are inserted according to numpunct::grouping()
2313 * and numpunct::thousands_sep(). The decimal point character used is
2314 * numpunct::decimal_point().
2316 * If io.width() is non-zero, enough @a fill characters are inserted to
2317 * make the result at least that wide. If
2318 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2319 * padded at the end. If ios_base::internal, then padding occurs
2320 * immediately after either a '+' or '-' or after '0x' or '0X'.
2321 * Otherwise, padding occurs at the beginning.
2323 * @param s Stream to write to.
2324 * @param io Source of locale and flags.
2325 * @param fill Char_type to use for filling.
2326 * @param v Value to format and insert.
2327 * @return Iterator after writing.
2330 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long __v
) const
2331 { return this->do_put(__s
, __f
, __fill
, __v
); }
2334 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2335 unsigned long __v
) const
2336 { return this->do_put(__s
, __f
, __fill
, __v
); }
2338 #ifdef _GLIBCXX_USE_LONG_LONG
2340 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long long __v
) const
2341 { return this->do_put(__s
, __f
, __fill
, __v
); }
2344 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2345 unsigned long long __v
) const
2346 { return this->do_put(__s
, __f
, __fill
, __v
); }
2352 * @brief Numeric formatting.
2354 * Formats the floating point value @a v and inserts it into a stream.
2355 * It does so by calling num_put::do_put().
2357 * Formatting is affected by the flag settings in @a io.
2359 * The basic format is affected by the value of io.flags() &
2360 * ios_base::floatfield. If equal to ios_base::fixed, formats like the
2361 * printf %f specifier. Else if equal to ios_base::scientific, formats
2362 * like %e or %E with ios_base::uppercase unset or set respectively.
2363 * Otherwise, formats like %g or %G depending on uppercase. Note that
2364 * if both fixed and scientific are set, the effect will also be like
2367 * The output precision is given by io.precision(). This precision is
2368 * capped at numeric_limits::digits10 + 2 (different for double and
2369 * long double). The default precision is 6.
2371 * If ios_base::showpos is set, '+' is output before positive values.
2372 * If ios_base::showpoint is set, a decimal point will always be
2375 * Thousands separators are inserted according to numpunct::grouping()
2376 * and numpunct::thousands_sep(). The decimal point character used is
2377 * numpunct::decimal_point().
2379 * If io.width() is non-zero, enough @a fill characters are inserted to
2380 * make the result at least that wide. If
2381 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2382 * padded at the end. If ios_base::internal, then padding occurs
2383 * immediately after either a '+' or '-' or after '0x' or '0X'.
2384 * Otherwise, padding occurs at the beginning.
2386 * @param s Stream to write to.
2387 * @param io Source of locale and flags.
2388 * @param fill Char_type to use for filling.
2389 * @param v Value to format and insert.
2390 * @return Iterator after writing.
2393 put(iter_type __s
, ios_base
& __f
, char_type __fill
, double __v
) const
2394 { return this->do_put(__s
, __f
, __fill
, __v
); }
2397 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2398 long double __v
) const
2399 { return this->do_put(__s
, __f
, __fill
, __v
); }
2403 * @brief Numeric formatting.
2405 * Formats the pointer value @a v and inserts it into a stream. It
2406 * does so by calling num_put::do_put().
2408 * This function formats @a v as an unsigned long with ios_base::hex
2409 * and ios_base::showbase set.
2411 * @param s Stream to write to.
2412 * @param io Source of locale and flags.
2413 * @param fill Char_type to use for filling.
2414 * @param v Value to format and insert.
2415 * @return Iterator after writing.
2418 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2419 const void* __v
) const
2420 { return this->do_put(__s
, __f
, __fill
, __v
); }
2423 template<typename _ValueT
>
2425 _M_insert_float(iter_type
, ios_base
& __io
, char_type __fill
,
2426 char __mod
, _ValueT __v
) const;
2429 _M_group_float(const char* __grouping
, size_t __grouping_size
,
2430 char_type __sep
, const char_type
* __p
, char_type
* __new
,
2431 char_type
* __cs
, int& __len
) const;
2433 template<typename _ValueT
>
2435 _M_insert_int(iter_type
, ios_base
& __io
, char_type __fill
,
2439 _M_group_int(const char* __grouping
, size_t __grouping_size
,
2440 char_type __sep
, ios_base
& __io
, char_type
* __new
,
2441 char_type
* __cs
, int& __len
) const;
2444 _M_pad(char_type __fill
, streamsize __w
, ios_base
& __io
,
2445 char_type
* __new
, const char_type
* __cs
, int& __len
) const;
2453 * @brief Numeric formatting.
2455 * These functions do the work of formatting numeric values and
2456 * inserting them into a stream. This function is a hook for derived
2457 * classes to change the value returned.
2459 * @param s Stream to write to.
2460 * @param io Source of locale and flags.
2461 * @param fill Char_type to use for filling.
2462 * @param v Value to format and insert.
2463 * @return Iterator after writing.
2466 do_put(iter_type
, ios_base
&, char_type __fill
, bool __v
) const;
2469 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
, long __v
) const
2470 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2473 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2474 unsigned long __v
) const
2475 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2477 #ifdef _GLIBCXX_USE_LONG_LONG
2479 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2480 long long __v
) const
2481 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2484 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2485 unsigned long long __v
) const
2486 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2490 do_put(iter_type
, ios_base
&, char_type __fill
, double __v
) const;
2492 // XXX GLIBCXX_ABI Deprecated
2493 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2495 __do_put(iter_type
, ios_base
&, char_type __fill
, double __v
) const;
2498 do_put(iter_type
, ios_base
&, char_type __fill
, long double __v
) const;
2502 do_put(iter_type
, ios_base
&, char_type __fill
, const void* __v
) const;
2504 // XXX GLIBCXX_ABI Deprecated
2505 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2507 do_put(iter_type
, ios_base
&, char_type __fill
, long double __v
) const;
2512 template <typename _CharT
, typename _OutIter
>
2513 locale::id num_put
<_CharT
, _OutIter
>::id
;
2515 _GLIBCXX_END_LDBL_NAMESPACE
2517 // Subclause convenience interfaces, inlines.
2518 // NB: These are inline because, when used in a loop, some compilers
2519 // can hoist the body out of the loop; then it's just as fast as the
2520 // C is*() function.
2522 /// Convenience interface to ctype.is(ctype_base::space, __c).
2523 template<typename _CharT
>
2525 isspace(_CharT __c
, const locale
& __loc
)
2526 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::space
, __c
); }
2528 /// Convenience interface to ctype.is(ctype_base::print, __c).
2529 template<typename _CharT
>
2531 isprint(_CharT __c
, const locale
& __loc
)
2532 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::print
, __c
); }
2534 /// Convenience interface to ctype.is(ctype_base::cntrl, __c).
2535 template<typename _CharT
>
2537 iscntrl(_CharT __c
, const locale
& __loc
)
2538 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::cntrl
, __c
); }
2540 /// Convenience interface to ctype.is(ctype_base::upper, __c).
2541 template<typename _CharT
>
2543 isupper(_CharT __c
, const locale
& __loc
)
2544 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::upper
, __c
); }
2546 /// Convenience interface to ctype.is(ctype_base::lower, __c).
2547 template<typename _CharT
>
2549 islower(_CharT __c
, const locale
& __loc
)
2550 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::lower
, __c
); }
2552 /// Convenience interface to ctype.is(ctype_base::alpha, __c).
2553 template<typename _CharT
>
2555 isalpha(_CharT __c
, const locale
& __loc
)
2556 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alpha
, __c
); }
2558 /// Convenience interface to ctype.is(ctype_base::digit, __c).
2559 template<typename _CharT
>
2561 isdigit(_CharT __c
, const locale
& __loc
)
2562 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::digit
, __c
); }
2564 /// Convenience interface to ctype.is(ctype_base::punct, __c).
2565 template<typename _CharT
>
2567 ispunct(_CharT __c
, const locale
& __loc
)
2568 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::punct
, __c
); }
2570 /// Convenience interface to ctype.is(ctype_base::xdigit, __c).
2571 template<typename _CharT
>
2573 isxdigit(_CharT __c
, const locale
& __loc
)
2574 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::xdigit
, __c
); }
2576 /// Convenience interface to ctype.is(ctype_base::alnum, __c).
2577 template<typename _CharT
>
2579 isalnum(_CharT __c
, const locale
& __loc
)
2580 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alnum
, __c
); }
2582 /// Convenience interface to ctype.is(ctype_base::graph, __c).
2583 template<typename _CharT
>
2585 isgraph(_CharT __c
, const locale
& __loc
)
2586 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::graph
, __c
); }
2588 /// Convenience interface to ctype.toupper(__c).
2589 template<typename _CharT
>
2591 toupper(_CharT __c
, const locale
& __loc
)
2592 { return use_facet
<ctype
<_CharT
> >(__loc
).toupper(__c
); }
2594 /// Convenience interface to ctype.tolower(__c).
2595 template<typename _CharT
>
2597 tolower(_CharT __c
, const locale
& __loc
)
2598 { return use_facet
<ctype
<_CharT
> >(__loc
).tolower(__c
); }
2600 _GLIBCXX_END_NAMESPACE
2602 #ifndef _GLIBCXX_EXPORT_TEMPLATE
2603 # include <bits/locale_facets.tcc>