1 // Locale support -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
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 2, 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 // 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,
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.
32 /** @file locale_facets.h
33 * This is an internal header file, included by other library headers.
34 * You should not attempt to use it directly.
38 // ISO C++ 14882: 22.1 Locales
41 #ifndef _LOCALE_FACETS_H
42 #define _LOCALE_FACETS_H 1
44 #pragma GCC system_header
46 #include <cwctype> // For wctype_t
48 #include <bits/ctype_base.h>
50 #include <bits/ios_base.h> // For ios_base, ios_base::iostate
52 #include <bits/cpp_type_traits.h>
53 #include <ext/type_traits.h>
54 #include <ext/numeric_traits.h>
55 #include <bits/streambuf_iterator.h>
57 _GLIBCXX_BEGIN_NAMESPACE(std
)
59 // NB: Don't instantiate required wchar_t facets if no wchar_t support.
60 #ifdef _GLIBCXX_USE_WCHAR_T
61 # define _GLIBCXX_NUM_FACETS 28
63 # define _GLIBCXX_NUM_FACETS 14
66 // Convert string to numeric value of type _Tv and store results.
67 // NB: This is specialized for all required types, there is no
68 // generic definition.
69 template<typename _Tv
>
71 __convert_to_v(const char* __in
, _Tv
& __out
, ios_base::iostate
& __err
,
72 const __c_locale
& __cloc
);
74 // Explicit specializations for required types.
77 __convert_to_v(const char*, float&, ios_base::iostate
&,
82 __convert_to_v(const char*, double&, ios_base::iostate
&,
87 __convert_to_v(const char*, long double&, ios_base::iostate
&,
90 // NB: __pad is a struct, rather than a function, so it can be
91 // partially-specialized.
92 template<typename _CharT
, typename _Traits
>
96 _S_pad(ios_base
& __io
, _CharT __fill
, _CharT
* __news
,
97 const _CharT
* __olds
, const streamsize __newlen
,
98 const streamsize __oldlen
);
101 // Used by both numeric and monetary facets.
102 // Inserts "group separator" characters into an array of characters.
103 // It's recursive, one iteration per group. It moves the characters
104 // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
105 // only with __gsize != 0.
106 template<typename _CharT
>
108 __add_grouping(_CharT
* __s
, _CharT __sep
,
109 const char* __gbeg
, size_t __gsize
,
110 const _CharT
* __first
, const _CharT
* __last
);
112 // This template permits specializing facet output code for
113 // ostreambuf_iterator. For ostreambuf_iterator, sputn is
114 // significantly more efficient than incrementing iterators.
115 template<typename _CharT
>
117 ostreambuf_iterator
<_CharT
>
118 __write(ostreambuf_iterator
<_CharT
> __s
, const _CharT
* __ws
, int __len
)
120 __s
._M_put(__ws
, __len
);
124 // This is the unspecialized form of the template.
125 template<typename _CharT
, typename _OutIter
>
128 __write(_OutIter __s
, const _CharT
* __ws
, int __len
)
130 for (int __j
= 0; __j
< __len
; __j
++, ++__s
)
136 // 22.2.1.1 Template class ctype
137 // Include host and configuration specific ctype enums for ctype_base.
139 // Common base for ctype<_CharT>.
141 * @brief Common base for ctype facet
143 * This template class provides implementations of the public functions
144 * that forward to the protected virtual functions.
146 * This template also provides abstract stubs for the protected virtual
149 template<typename _CharT
>
150 class __ctype_abstract_base
: public locale::facet
, public ctype_base
154 /// Typedef for the template parameter
155 typedef _CharT char_type
;
158 * @brief Test char_type classification.
160 * This function finds a mask M for @a c and compares it to mask @a m.
161 * It does so by returning the value of ctype<char_type>::do_is().
163 * @param c The char_type to compare the mask of.
164 * @param m The mask to compare against.
165 * @return (M & m) != 0.
168 is(mask __m
, char_type __c
) const
169 { return this->do_is(__m
, __c
); }
172 * @brief Return a mask array.
174 * This function finds the mask for each char_type in the range [lo,hi)
175 * and successively writes it to vec. vec must have as many elements
176 * as the char array. It does so by returning the value of
177 * ctype<char_type>::do_is().
179 * @param lo Pointer to start of range.
180 * @param hi Pointer to end of range.
181 * @param vec Pointer to an array of mask storage.
185 is(const char_type
*__lo
, const char_type
*__hi
, mask
*__vec
) const
186 { return this->do_is(__lo
, __hi
, __vec
); }
189 * @brief Find char_type matching a mask
191 * This function searches for and returns the first char_type c in
192 * [lo,hi) for which is(m,c) is true. It does so by returning
193 * ctype<char_type>::do_scan_is().
195 * @param m The mask to compare against.
196 * @param lo Pointer to start of range.
197 * @param hi Pointer to end of range.
198 * @return Pointer to matching char_type if found, else @a hi.
201 scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
202 { return this->do_scan_is(__m
, __lo
, __hi
); }
205 * @brief Find char_type not matching a mask
207 * This function searches for and returns the first char_type c in
208 * [lo,hi) for which is(m,c) is false. It does so by returning
209 * ctype<char_type>::do_scan_not().
211 * @param m The mask to compare against.
212 * @param lo Pointer to first char in range.
213 * @param hi Pointer to end of range.
214 * @return Pointer to non-matching char if found, else @a hi.
217 scan_not(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
218 { return this->do_scan_not(__m
, __lo
, __hi
); }
221 * @brief Convert to uppercase.
223 * This function converts the argument to uppercase if possible.
224 * If not possible (for example, '2'), returns the argument. It does
225 * so by returning ctype<char_type>::do_toupper().
227 * @param c The char_type to convert.
228 * @return The uppercase char_type if convertible, else @a c.
231 toupper(char_type __c
) const
232 { return this->do_toupper(__c
); }
235 * @brief Convert array to uppercase.
237 * This function converts each char_type in the range [lo,hi) to
238 * uppercase if possible. Other elements remain untouched. It does so
239 * by returning ctype<char_type>:: do_toupper(lo, hi).
241 * @param lo Pointer to start of range.
242 * @param hi Pointer to end of range.
246 toupper(char_type
*__lo
, const char_type
* __hi
) const
247 { return this->do_toupper(__lo
, __hi
); }
250 * @brief Convert to lowercase.
252 * This function converts the argument to lowercase if possible. If
253 * not possible (for example, '2'), returns the argument. It does so
254 * by returning ctype<char_type>::do_tolower(c).
256 * @param c The char_type to convert.
257 * @return The lowercase char_type if convertible, else @a c.
260 tolower(char_type __c
) const
261 { return this->do_tolower(__c
); }
264 * @brief Convert array to lowercase.
266 * This function converts each char_type in the range [lo,hi) to
267 * lowercase if possible. Other elements remain untouched. It does so
268 * by returning ctype<char_type>:: do_tolower(lo, hi).
270 * @param lo Pointer to start of range.
271 * @param hi Pointer to end of range.
275 tolower(char_type
* __lo
, const char_type
* __hi
) const
276 { return this->do_tolower(__lo
, __hi
); }
279 * @brief Widen char to char_type
281 * This function converts the char argument to char_type using the
282 * simplest reasonable transformation. It does so by returning
283 * ctype<char_type>::do_widen(c).
285 * Note: this is not what you want for codepage conversions. See
288 * @param c The char to convert.
289 * @return The converted char_type.
292 widen(char __c
) const
293 { return this->do_widen(__c
); }
296 * @brief Widen array to char_type
298 * This function converts each char in the input to char_type using the
299 * simplest reasonable transformation. It does so by returning
300 * ctype<char_type>::do_widen(c).
302 * Note: this is not what you want for codepage conversions. See
305 * @param lo Pointer to start of range.
306 * @param hi Pointer to end of range.
307 * @param to Pointer to the destination array.
311 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
312 { return this->do_widen(__lo
, __hi
, __to
); }
315 * @brief Narrow char_type to char
317 * This function converts the char_type to char using the simplest
318 * reasonable transformation. If the conversion fails, dfault is
319 * returned instead. It does so by returning
320 * ctype<char_type>::do_narrow(c).
322 * Note: this is not what you want for codepage conversions. See
325 * @param c The char_type to convert.
326 * @param dfault Char to return if conversion fails.
327 * @return The converted char.
330 narrow(char_type __c
, char __dfault
) const
331 { return this->do_narrow(__c
, __dfault
); }
334 * @brief Narrow array to char array
336 * This function converts each char_type in the input to char using the
337 * simplest reasonable transformation and writes the results to the
338 * destination array. For any char_type in the input that cannot be
339 * converted, @a dfault is used instead. It does so by returning
340 * ctype<char_type>::do_narrow(lo, hi, dfault, to).
342 * Note: this is not what you want for codepage conversions. See
345 * @param lo Pointer to start of range.
346 * @param hi Pointer to end of range.
347 * @param dfault Char to use if conversion fails.
348 * @param to Pointer to the destination array.
352 narrow(const char_type
* __lo
, const char_type
* __hi
,
353 char __dfault
, char *__to
) const
354 { return this->do_narrow(__lo
, __hi
, __dfault
, __to
); }
358 __ctype_abstract_base(size_t __refs
= 0): facet(__refs
) { }
361 ~__ctype_abstract_base() { }
364 * @brief Test char_type classification.
366 * This function finds a mask M for @a c and compares it to mask @a m.
368 * do_is() is a hook for a derived facet to change the behavior of
369 * classifying. do_is() must always return the same result for the
372 * @param c The char_type to find the mask of.
373 * @param m The mask to compare against.
374 * @return (M & m) != 0.
377 do_is(mask __m
, char_type __c
) const = 0;
380 * @brief Return a mask array.
382 * This function finds the mask for each char_type in the range [lo,hi)
383 * and successively writes it to vec. vec must have as many elements
386 * do_is() is a hook for a derived facet to change the behavior of
387 * classifying. do_is() must always return the same result for the
390 * @param lo Pointer to start of range.
391 * @param hi Pointer to end of range.
392 * @param vec Pointer to an array of mask storage.
395 virtual const char_type
*
396 do_is(const char_type
* __lo
, const char_type
* __hi
,
397 mask
* __vec
) const = 0;
400 * @brief Find char_type matching mask
402 * This function searches for and returns the first char_type c in
403 * [lo,hi) for which is(m,c) is true.
405 * do_scan_is() is a hook for a derived facet to change the behavior of
406 * match searching. do_is() must always return the same result for the
409 * @param m The mask to compare against.
410 * @param lo Pointer to start of range.
411 * @param hi Pointer to end of range.
412 * @return Pointer to a matching char_type if found, else @a hi.
414 virtual const char_type
*
415 do_scan_is(mask __m
, const char_type
* __lo
,
416 const char_type
* __hi
) const = 0;
419 * @brief Find char_type not matching mask
421 * This function searches for and returns a pointer to the first
422 * char_type c of [lo,hi) for which is(m,c) is false.
424 * do_scan_is() is a hook for a derived facet to change the behavior of
425 * match searching. do_is() must always return the same result for the
428 * @param m The mask to compare against.
429 * @param lo Pointer to start of range.
430 * @param hi Pointer to end of range.
431 * @return Pointer to a non-matching char_type if found, else @a hi.
433 virtual const char_type
*
434 do_scan_not(mask __m
, const char_type
* __lo
,
435 const char_type
* __hi
) const = 0;
438 * @brief Convert to uppercase.
440 * This virtual function converts the char_type argument to uppercase
441 * if possible. If not possible (for example, '2'), returns the
444 * do_toupper() is a hook for a derived facet to change the behavior of
445 * uppercasing. do_toupper() must always return the same result for
448 * @param c The char_type to convert.
449 * @return The uppercase char_type if convertible, else @a c.
452 do_toupper(char_type
) const = 0;
455 * @brief Convert array to uppercase.
457 * This virtual function converts each char_type in the range [lo,hi)
458 * to uppercase if possible. Other elements remain untouched.
460 * do_toupper() is a hook for a derived facet to change the behavior of
461 * uppercasing. do_toupper() must always return the same result for
464 * @param lo Pointer to start of range.
465 * @param hi Pointer to end of range.
468 virtual const char_type
*
469 do_toupper(char_type
* __lo
, const char_type
* __hi
) const = 0;
472 * @brief Convert to lowercase.
474 * This virtual function converts the argument to lowercase if
475 * possible. If not possible (for example, '2'), returns the argument.
477 * do_tolower() is a hook for a derived facet to change the behavior of
478 * lowercasing. do_tolower() must always return the same result for
481 * @param c The char_type to convert.
482 * @return The lowercase char_type if convertible, else @a c.
485 do_tolower(char_type
) const = 0;
488 * @brief Convert array to lowercase.
490 * This virtual function converts each char_type in the range [lo,hi)
491 * to lowercase if possible. Other elements remain untouched.
493 * do_tolower() is a hook for a derived facet to change the behavior of
494 * lowercasing. do_tolower() must always return the same result for
497 * @param lo Pointer to start of range.
498 * @param hi Pointer to end of range.
501 virtual const char_type
*
502 do_tolower(char_type
* __lo
, const char_type
* __hi
) const = 0;
507 * This virtual function converts the char to char_type using the
508 * simplest reasonable transformation.
510 * do_widen() is a hook for a derived facet to change the behavior of
511 * widening. do_widen() must always return the same result for the
514 * Note: this is not what you want for codepage conversions. See
517 * @param c The char to convert.
518 * @return The converted char_type
521 do_widen(char) const = 0;
524 * @brief Widen char array
526 * This function converts each char in the input to char_type using the
527 * simplest reasonable transformation.
529 * do_widen() is a hook for a derived facet to change the behavior of
530 * widening. do_widen() must always return the same result for the
533 * Note: this is not what you want for codepage conversions. See
536 * @param lo Pointer to start range.
537 * @param hi Pointer to end of range.
538 * @param to Pointer to the destination array.
542 do_widen(const char* __lo
, const char* __hi
,
543 char_type
* __dest
) const = 0;
546 * @brief Narrow char_type to char
548 * This virtual function converts the argument to char using the
549 * simplest reasonable transformation. If the conversion fails, dfault
550 * is returned instead.
552 * do_narrow() is a hook for a derived facet to change the behavior of
553 * narrowing. do_narrow() must always return the same result for the
556 * Note: this is not what you want for codepage conversions. See
559 * @param c The char_type to convert.
560 * @param dfault Char to return if conversion fails.
561 * @return The converted char.
564 do_narrow(char_type
, char __dfault
) const = 0;
567 * @brief Narrow char_type array to char
569 * This virtual function converts each char_type in the range [lo,hi) to
570 * char using the simplest reasonable transformation and writes the
571 * results to the destination array. For any element in the input that
572 * cannot be converted, @a dfault is used instead.
574 * do_narrow() is a hook for a derived facet to change the behavior of
575 * narrowing. do_narrow() must always return the same result for the
578 * Note: this is not what you want for codepage conversions. See
581 * @param lo Pointer to start of range.
582 * @param hi Pointer to end of range.
583 * @param dfault Char to use if conversion fails.
584 * @param to Pointer to the destination array.
587 virtual const char_type
*
588 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
589 char __dfault
, char* __dest
) const = 0;
592 // NB: Generic, mostly useless implementation.
594 * @brief Template ctype facet
596 * This template class defines classification and conversion functions for
597 * character sets. It wraps <cctype> functionality. Ctype gets used by
598 * streams for many I/O operations.
600 * This template provides the protected virtual functions the developer
601 * will have to replace in a derived class or specialization to make a
602 * working facet. The public functions that access them are defined in
603 * __ctype_abstract_base, to allow for implementation flexibility. See
604 * ctype<wchar_t> for an example. The functions are documented in
605 * __ctype_abstract_base.
607 * Note: implementations are provided for all the protected virtual
608 * functions, but will likely not be useful.
610 template<typename _CharT
>
611 class ctype
: public __ctype_abstract_base
<_CharT
>
615 typedef _CharT char_type
;
616 typedef typename __ctype_abstract_base
<_CharT
>::mask mask
;
618 /// The facet id for ctype<char_type>
619 static locale::id id
;
622 ctype(size_t __refs
= 0) : __ctype_abstract_base
<_CharT
>(__refs
) { }
629 do_is(mask __m
, char_type __c
) const;
631 virtual const char_type
*
632 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
634 virtual const char_type
*
635 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
637 virtual const char_type
*
638 do_scan_not(mask __m
, const char_type
* __lo
,
639 const char_type
* __hi
) const;
642 do_toupper(char_type __c
) const;
644 virtual const char_type
*
645 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
648 do_tolower(char_type __c
) const;
650 virtual const char_type
*
651 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
654 do_widen(char __c
) const;
657 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
660 do_narrow(char_type
, char __dfault
) const;
662 virtual const char_type
*
663 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
664 char __dfault
, char* __dest
) const;
667 template<typename _CharT
>
668 locale::id ctype
<_CharT
>::id
;
670 // 22.2.1.3 ctype<char> specialization.
672 * @brief The ctype<char> specialization.
674 * This class defines classification and conversion functions for
675 * the char type. It gets used by char streams for many I/O
676 * operations. The char specialization provides a number of
677 * optimizations as well.
680 class ctype
<char> : public locale::facet
, public ctype_base
684 /// Typedef for the template parameter char.
685 typedef char char_type
;
689 __c_locale _M_c_locale_ctype
;
691 __to_type _M_toupper
;
692 __to_type _M_tolower
;
693 const mask
* _M_table
;
694 mutable char _M_widen_ok
;
695 mutable char _M_widen
[1 + static_cast<unsigned char>(-1)];
696 mutable char _M_narrow
[1 + static_cast<unsigned char>(-1)];
697 mutable char _M_narrow_ok
; // 0 uninitialized, 1 init,
698 // 2 memcpy can't be used
701 /// The facet id for ctype<char>
702 static locale::id id
;
703 /// The size of the mask table. It is SCHAR_MAX + 1.
704 static const size_t table_size
= 1 + static_cast<unsigned char>(-1);
707 * @brief Constructor performs initialization.
709 * This is the constructor provided by the standard.
711 * @param table If non-zero, table is used as the per-char mask.
712 * Else classic_table() is used.
713 * @param del If true, passes ownership of table to this facet.
714 * @param refs Passed to the base facet class.
717 ctype(const mask
* __table
= 0, bool __del
= false, size_t __refs
= 0);
720 * @brief Constructor performs static initialization.
722 * This constructor is used to construct the initial C locale facet.
724 * @param cloc Handle to C locale data.
725 * @param table If non-zero, table is used as the per-char mask.
726 * @param del If true, passes ownership of table to this facet.
727 * @param refs Passed to the base facet class.
730 ctype(__c_locale __cloc
, const mask
* __table
= 0, bool __del
= false,
734 * @brief Test char classification.
736 * This function compares the mask table[c] to @a m.
738 * @param c The char to compare the mask of.
739 * @param m The mask to compare against.
740 * @return True if m & table[c] is true, false otherwise.
743 is(mask __m
, char __c
) const;
746 * @brief Return a mask array.
748 * This function finds the mask for each char in the range [lo, hi) and
749 * successively writes it to vec. vec must have as many elements as
752 * @param lo Pointer to start of range.
753 * @param hi Pointer to end of range.
754 * @param vec Pointer to an array of mask storage.
758 is(const char* __lo
, const char* __hi
, mask
* __vec
) const;
761 * @brief Find char matching a mask
763 * This function searches for and returns the first char in [lo,hi) for
764 * which is(m,char) is true.
766 * @param m The mask to compare against.
767 * @param lo Pointer to start of range.
768 * @param hi Pointer to end of range.
769 * @return Pointer to a matching char if found, else @a hi.
772 scan_is(mask __m
, const char* __lo
, const char* __hi
) const;
775 * @brief Find char not matching a mask
777 * This function searches for and returns a pointer to the first char
778 * in [lo,hi) for which is(m,char) is false.
780 * @param m The mask to compare against.
781 * @param lo Pointer to start of range.
782 * @param hi Pointer to end of range.
783 * @return Pointer to a non-matching char if found, else @a hi.
786 scan_not(mask __m
, const char* __lo
, const char* __hi
) const;
789 * @brief Convert to uppercase.
791 * This function converts the char argument to uppercase if possible.
792 * If not possible (for example, '2'), returns the argument.
794 * toupper() acts as if it returns ctype<char>::do_toupper(c).
795 * do_toupper() must always return the same result for the same input.
797 * @param c The char to convert.
798 * @return The uppercase char if convertible, else @a c.
801 toupper(char_type __c
) const
802 { return this->do_toupper(__c
); }
805 * @brief Convert array to uppercase.
807 * This function converts each char in the range [lo,hi) to uppercase
808 * if possible. Other chars remain untouched.
810 * toupper() acts as if it returns ctype<char>:: do_toupper(lo, hi).
811 * do_toupper() must always return the same result for the same input.
813 * @param lo Pointer to first char in range.
814 * @param hi Pointer to end of range.
818 toupper(char_type
*__lo
, const char_type
* __hi
) const
819 { return this->do_toupper(__lo
, __hi
); }
822 * @brief Convert to lowercase.
824 * This function converts the char argument to lowercase if possible.
825 * If not possible (for example, '2'), returns the argument.
827 * tolower() acts as if it returns ctype<char>::do_tolower(c).
828 * do_tolower() must always return the same result for the same input.
830 * @param c The char to convert.
831 * @return The lowercase char if convertible, else @a c.
834 tolower(char_type __c
) const
835 { return this->do_tolower(__c
); }
838 * @brief Convert array to lowercase.
840 * This function converts each char in the range [lo,hi) to lowercase
841 * if possible. Other chars remain untouched.
843 * tolower() acts as if it returns ctype<char>:: do_tolower(lo, hi).
844 * do_tolower() must always return the same result for the same input.
846 * @param lo Pointer to first char in range.
847 * @param hi Pointer to end of range.
851 tolower(char_type
* __lo
, const char_type
* __hi
) const
852 { return this->do_tolower(__lo
, __hi
); }
857 * This function converts the char to char_type using the simplest
858 * reasonable transformation. For an underived ctype<char> facet, the
859 * argument will be returned unchanged.
861 * This function works as if it returns ctype<char>::do_widen(c).
862 * do_widen() must always return the same result for the same input.
864 * Note: this is not what you want for codepage conversions. See
867 * @param c The char to convert.
868 * @return The converted character.
871 widen(char __c
) const
874 return _M_widen
[static_cast<unsigned char>(__c
)];
875 this->_M_widen_init();
876 return this->do_widen(__c
);
880 * @brief Widen char array
882 * This function converts each char in the input to char using the
883 * simplest reasonable transformation. For an underived ctype<char>
884 * facet, the argument will be copied unchanged.
886 * This function works as if it returns ctype<char>::do_widen(c).
887 * do_widen() must always return the same result for the same input.
889 * Note: this is not what you want for codepage conversions. See
892 * @param lo Pointer to first char in range.
893 * @param hi Pointer to end of range.
894 * @param to Pointer to the destination array.
898 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
900 if (_M_widen_ok
== 1)
902 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
907 return this->do_widen(__lo
, __hi
, __to
);
913 * This function converts the char to char using the simplest
914 * reasonable transformation. If the conversion fails, dfault is
915 * returned instead. For an underived ctype<char> facet, @a c
916 * will be returned unchanged.
918 * This function works as if it returns ctype<char>::do_narrow(c).
919 * do_narrow() must always return the same result for the same input.
921 * Note: this is not what you want for codepage conversions. See
924 * @param c The char to convert.
925 * @param dfault Char to return if conversion fails.
926 * @return The converted character.
929 narrow(char_type __c
, char __dfault
) const
931 if (_M_narrow
[static_cast<unsigned char>(__c
)])
932 return _M_narrow
[static_cast<unsigned char>(__c
)];
933 const char __t
= do_narrow(__c
, __dfault
);
935 _M_narrow
[static_cast<unsigned char>(__c
)] = __t
;
940 * @brief Narrow char array
942 * This function converts each char in the input to char using the
943 * simplest reasonable transformation and writes the results to the
944 * destination array. For any char in the input that cannot be
945 * converted, @a dfault is used instead. For an underived ctype<char>
946 * facet, the argument will be copied unchanged.
948 * This function works as if it returns ctype<char>::do_narrow(lo, hi,
949 * dfault, to). do_narrow() must always return the same result for the
952 * Note: this is not what you want for codepage conversions. See
955 * @param lo Pointer to start of range.
956 * @param hi Pointer to end of range.
957 * @param dfault Char to use if conversion fails.
958 * @param to Pointer to the destination array.
962 narrow(const char_type
* __lo
, const char_type
* __hi
,
963 char __dfault
, char *__to
) const
965 if (__builtin_expect(_M_narrow_ok
== 1, true))
967 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
972 return this->do_narrow(__lo
, __hi
, __dfault
, __to
);
975 // _GLIBCXX_RESOLVE_LIB_DEFECTS
976 // DR 695. ctype<char>::classic_table() not accessible.
977 /// Returns a pointer to the mask table provided to the constructor, or
978 /// the default from classic_table() if none was provided.
980 table() const throw()
983 /// Returns a pointer to the C locale mask table.
985 classic_table() throw();
991 * This function deletes table() if @a del was true in the
998 * @brief Convert to uppercase.
1000 * This virtual function converts the char argument to uppercase if
1001 * possible. If not possible (for example, '2'), returns the argument.
1003 * do_toupper() is a hook for a derived facet to change the behavior of
1004 * uppercasing. do_toupper() must always return the same result for
1007 * @param c The char to convert.
1008 * @return The uppercase char if convertible, else @a c.
1011 do_toupper(char_type
) const;
1014 * @brief Convert array to uppercase.
1016 * This virtual function converts each char in the range [lo,hi) to
1017 * uppercase if possible. Other chars remain untouched.
1019 * do_toupper() is a hook for a derived facet to change the behavior of
1020 * uppercasing. do_toupper() must always return the same result for
1023 * @param lo Pointer to start of range.
1024 * @param hi Pointer to end of range.
1027 virtual const char_type
*
1028 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
1031 * @brief Convert to lowercase.
1033 * This virtual function converts the char argument to lowercase if
1034 * possible. If not possible (for example, '2'), returns the argument.
1036 * do_tolower() is a hook for a derived facet to change the behavior of
1037 * lowercasing. do_tolower() must always return the same result for
1040 * @param c The char to convert.
1041 * @return The lowercase char if convertible, else @a c.
1044 do_tolower(char_type
) const;
1047 * @brief Convert array to lowercase.
1049 * This virtual function converts each char in the range [lo,hi) to
1050 * lowercase if possible. Other chars remain untouched.
1052 * do_tolower() is a hook for a derived facet to change the behavior of
1053 * lowercasing. do_tolower() must always return the same result for
1056 * @param lo Pointer to first char in range.
1057 * @param hi Pointer to end of range.
1060 virtual const char_type
*
1061 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
1066 * This virtual function converts the char to char using the simplest
1067 * reasonable transformation. For an underived ctype<char> facet, the
1068 * argument will be returned unchanged.
1070 * do_widen() is a hook for a derived facet to change the behavior of
1071 * widening. do_widen() must always return the same result for the
1074 * Note: this is not what you want for codepage conversions. See
1077 * @param c The char to convert.
1078 * @return The converted character.
1081 do_widen(char __c
) const
1085 * @brief Widen char array
1087 * This function converts each char in the range [lo,hi) to char using
1088 * the simplest reasonable transformation. For an underived
1089 * ctype<char> facet, the argument will be copied unchanged.
1091 * do_widen() is a hook for a derived facet to change the behavior of
1092 * widening. do_widen() must always return the same result for the
1095 * Note: this is not what you want for codepage conversions. See
1098 * @param lo Pointer to start of range.
1099 * @param hi Pointer to end of range.
1100 * @param to Pointer to the destination array.
1104 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const
1106 __builtin_memcpy(__dest
, __lo
, __hi
- __lo
);
1111 * @brief Narrow char
1113 * This virtual function converts the char to char using the simplest
1114 * reasonable transformation. If the conversion fails, dfault is
1115 * returned instead. For an underived ctype<char> facet, @a c will be
1116 * returned unchanged.
1118 * do_narrow() is a hook for a derived facet to change the behavior of
1119 * narrowing. do_narrow() must always return the same result for the
1122 * Note: this is not what you want for codepage conversions. See
1125 * @param c The char to convert.
1126 * @param dfault Char to return if conversion fails.
1127 * @return The converted char.
1130 do_narrow(char_type __c
, char) const
1134 * @brief Narrow char array to char array
1136 * This virtual function converts each char in the range [lo,hi) to
1137 * char using the simplest reasonable transformation and writes the
1138 * results to the destination array. For any char in the input that
1139 * cannot be converted, @a dfault is used instead. For an underived
1140 * ctype<char> facet, the argument will be copied unchanged.
1142 * do_narrow() is a hook for a derived facet to change the behavior of
1143 * narrowing. do_narrow() must always return the same result for the
1146 * Note: this is not what you want for codepage conversions. See
1149 * @param lo Pointer to start of range.
1150 * @param hi Pointer to end of range.
1151 * @param dfault Char to use if conversion fails.
1152 * @param to Pointer to the destination array.
1155 virtual const char_type
*
1156 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
1157 char, char* __dest
) const
1159 __builtin_memcpy(__dest
, __lo
, __hi
- __lo
);
1164 void _M_narrow_init() const;
1165 void _M_widen_init() const;
1170 use_facet
<ctype
<char> >(const locale
& __loc
);
1172 #ifdef _GLIBCXX_USE_WCHAR_T
1173 // 22.2.1.3 ctype<wchar_t> specialization
1175 * @brief The ctype<wchar_t> specialization.
1177 * This class defines classification and conversion functions for the
1178 * wchar_t type. It gets used by wchar_t streams for many I/O operations.
1179 * The wchar_t specialization provides a number of optimizations as well.
1181 * ctype<wchar_t> inherits its public methods from
1182 * __ctype_abstract_base<wchar_t>.
1185 class ctype
<wchar_t> : public __ctype_abstract_base
<wchar_t>
1189 /// Typedef for the template parameter wchar_t.
1190 typedef wchar_t char_type
;
1191 typedef wctype_t __wmask_type
;
1194 __c_locale _M_c_locale_ctype
;
1196 // Pre-computed narrowed and widened chars.
1198 char _M_narrow
[128];
1199 wint_t _M_widen
[1 + static_cast<unsigned char>(-1)];
1201 // Pre-computed elements for do_is.
1203 __wmask_type _M_wmask
[16];
1207 /// The facet id for ctype<wchar_t>
1208 static locale::id id
;
1211 * @brief Constructor performs initialization.
1213 * This is the constructor provided by the standard.
1215 * @param refs Passed to the base facet class.
1218 ctype(size_t __refs
= 0);
1221 * @brief Constructor performs static initialization.
1223 * This constructor is used to construct the initial C locale facet.
1225 * @param cloc Handle to C locale data.
1226 * @param refs Passed to the base facet class.
1229 ctype(__c_locale __cloc
, size_t __refs
= 0);
1233 _M_convert_to_wmask(const mask __m
) const;
1240 * @brief Test wchar_t classification.
1242 * This function finds a mask M for @a c and compares it to mask @a m.
1244 * do_is() is a hook for a derived facet to change the behavior of
1245 * classifying. do_is() must always return the same result for the
1248 * @param c The wchar_t to find the mask of.
1249 * @param m The mask to compare against.
1250 * @return (M & m) != 0.
1253 do_is(mask __m
, char_type __c
) const;
1256 * @brief Return a mask array.
1258 * This function finds the mask for each wchar_t in the range [lo,hi)
1259 * and successively writes it to vec. vec must have as many elements
1262 * do_is() is a hook for a derived facet to change the behavior of
1263 * classifying. do_is() must always return the same result for the
1266 * @param lo Pointer to start of range.
1267 * @param hi Pointer to end of range.
1268 * @param vec Pointer to an array of mask storage.
1271 virtual const char_type
*
1272 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
1275 * @brief Find wchar_t matching mask
1277 * This function searches for and returns the first wchar_t c in
1278 * [lo,hi) for which is(m,c) is true.
1280 * do_scan_is() is a hook for a derived facet to change the behavior of
1281 * match searching. do_is() must always return the same result for the
1284 * @param m The mask to compare against.
1285 * @param lo Pointer to start of range.
1286 * @param hi Pointer to end of range.
1287 * @return Pointer to a matching wchar_t if found, else @a hi.
1289 virtual const char_type
*
1290 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
1293 * @brief Find wchar_t not matching mask
1295 * This function searches for and returns a pointer to the first
1296 * wchar_t c of [lo,hi) for which is(m,c) is false.
1298 * do_scan_is() is a hook for a derived facet to change the behavior of
1299 * match searching. do_is() must always return the same result for the
1302 * @param m The mask to compare against.
1303 * @param lo Pointer to start of range.
1304 * @param hi Pointer to end of range.
1305 * @return Pointer to a non-matching wchar_t if found, else @a hi.
1307 virtual const char_type
*
1308 do_scan_not(mask __m
, const char_type
* __lo
,
1309 const char_type
* __hi
) const;
1312 * @brief Convert to uppercase.
1314 * This virtual function converts the wchar_t argument to uppercase if
1315 * possible. If not possible (for example, '2'), returns the argument.
1317 * do_toupper() is a hook for a derived facet to change the behavior of
1318 * uppercasing. do_toupper() must always return the same result for
1321 * @param c The wchar_t to convert.
1322 * @return The uppercase wchar_t if convertible, else @a c.
1325 do_toupper(char_type
) const;
1328 * @brief Convert array to uppercase.
1330 * This virtual function converts each wchar_t in the range [lo,hi) to
1331 * uppercase if possible. Other elements remain untouched.
1333 * do_toupper() is a hook for a derived facet to change the behavior of
1334 * uppercasing. do_toupper() must always return the same result for
1337 * @param lo Pointer to start of range.
1338 * @param hi Pointer to end of range.
1341 virtual const char_type
*
1342 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
1345 * @brief Convert to lowercase.
1347 * This virtual function converts the argument to lowercase if
1348 * possible. If not possible (for example, '2'), returns the argument.
1350 * do_tolower() is a hook for a derived facet to change the behavior of
1351 * lowercasing. do_tolower() must always return the same result for
1354 * @param c The wchar_t to convert.
1355 * @return The lowercase wchar_t if convertible, else @a c.
1358 do_tolower(char_type
) const;
1361 * @brief Convert array to lowercase.
1363 * This virtual function converts each wchar_t in the range [lo,hi) to
1364 * lowercase if possible. Other elements remain untouched.
1366 * do_tolower() is a hook for a derived facet to change the behavior of
1367 * lowercasing. do_tolower() must always return the same result for
1370 * @param lo Pointer to start of range.
1371 * @param hi Pointer to end of range.
1374 virtual const char_type
*
1375 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
1378 * @brief Widen char to wchar_t
1380 * This virtual function converts the char to wchar_t using the
1381 * simplest reasonable transformation. For an underived ctype<wchar_t>
1382 * facet, the argument will be cast to wchar_t.
1384 * do_widen() is a hook for a derived facet to change the behavior of
1385 * widening. do_widen() must always return the same result for the
1388 * Note: this is not what you want for codepage conversions. See
1391 * @param c The char to convert.
1392 * @return The converted wchar_t.
1395 do_widen(char) const;
1398 * @brief Widen char array to wchar_t array
1400 * This function converts each char in the input to wchar_t using the
1401 * simplest reasonable transformation. For an underived ctype<wchar_t>
1402 * facet, the argument will be copied, casting each element to wchar_t.
1404 * do_widen() is a hook for a derived facet to change the behavior of
1405 * widening. do_widen() must always return the same result for the
1408 * Note: this is not what you want for codepage conversions. See
1411 * @param lo Pointer to start range.
1412 * @param hi Pointer to end of range.
1413 * @param to Pointer to the destination array.
1417 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
1420 * @brief Narrow wchar_t to char
1422 * This virtual function converts the argument to char using
1423 * the simplest reasonable transformation. If the conversion
1424 * fails, dfault is returned instead. For an underived
1425 * ctype<wchar_t> facet, @a c will be cast to char and
1428 * do_narrow() is a hook for a derived facet to change the
1429 * behavior of narrowing. do_narrow() must always return the
1430 * same result for the same input.
1432 * Note: this is not what you want for codepage conversions. See
1435 * @param c The wchar_t to convert.
1436 * @param dfault Char to return if conversion fails.
1437 * @return The converted char.
1440 do_narrow(char_type
, char __dfault
) const;
1443 * @brief Narrow wchar_t array to char array
1445 * This virtual function converts each wchar_t in the range [lo,hi) to
1446 * char using the simplest reasonable transformation and writes the
1447 * results to the destination array. For any wchar_t in the input that
1448 * cannot be converted, @a dfault is used instead. For an underived
1449 * ctype<wchar_t> facet, the argument will be copied, casting each
1452 * do_narrow() is a hook for a derived facet to change the behavior of
1453 * narrowing. do_narrow() must always return the same result for the
1456 * Note: this is not what you want for codepage conversions. See
1459 * @param lo Pointer to start of range.
1460 * @param hi Pointer to end of range.
1461 * @param dfault Char to use if conversion fails.
1462 * @param to Pointer to the destination array.
1465 virtual const char_type
*
1466 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
1467 char __dfault
, char* __dest
) const;
1469 // For use at construction time only.
1471 _M_initialize_ctype();
1475 const ctype
<wchar_t>&
1476 use_facet
<ctype
<wchar_t> >(const locale
& __loc
);
1477 #endif //_GLIBCXX_USE_WCHAR_T
1479 /// class ctype_byname [22.2.1.2].
1480 template<typename _CharT
>
1481 class ctype_byname
: public ctype
<_CharT
>
1484 typedef typename ctype
<_CharT
>::mask mask
;
1487 ctype_byname(const char* __s
, size_t __refs
= 0);
1491 ~ctype_byname() { };
1494 /// 22.2.1.4 Class ctype_byname specializations.
1496 class ctype_byname
<char> : public ctype
<char>
1500 ctype_byname(const char* __s
, size_t __refs
= 0);
1507 #ifdef _GLIBCXX_USE_WCHAR_T
1509 class ctype_byname
<wchar_t> : public ctype
<wchar_t>
1513 ctype_byname(const char* __s
, size_t __refs
= 0);
1521 _GLIBCXX_END_NAMESPACE
1523 // Include host and configuration specific ctype inlines.
1524 #include <bits/ctype_inline.h>
1526 _GLIBCXX_BEGIN_NAMESPACE(std
)
1528 // 22.2.2 The numeric category.
1532 // NB: Code depends on the order of _S_atoms_out elements.
1533 // Below are the indices into _S_atoms_out.
1541 _S_odigits_end
= _S_odigits
+ 16,
1542 _S_oudigits
= _S_odigits_end
,
1543 _S_oudigits_end
= _S_oudigits
+ 16,
1544 _S_oe
= _S_odigits
+ 14, // For scientific notation, 'e'
1545 _S_oE
= _S_oudigits
+ 14, // For scientific notation, 'E'
1546 _S_oend
= _S_oudigits_end
1549 // A list of valid numeric literals for output. This array
1550 // contains chars that will be passed through the current locale's
1551 // ctype<_CharT>.widen() and then used to render numbers.
1552 // For the standard "C" locale, this is
1553 // "-+xX0123456789abcdef0123456789ABCDEF".
1554 static const char* _S_atoms_out
;
1556 // String literal of acceptable (narrow) input, for num_get.
1557 // "-+xX0123456789abcdefABCDEF"
1558 static const char* _S_atoms_in
;
1567 _S_ie
= _S_izero
+ 14,
1568 _S_iE
= _S_izero
+ 20,
1573 // Construct and return valid scanf format for floating point types.
1575 _S_format_float(const ios_base
& __io
, char* __fptr
, char __mod
);
1578 template<typename _CharT
>
1579 struct __numpunct_cache
: public locale::facet
1581 const char* _M_grouping
;
1582 size_t _M_grouping_size
;
1583 bool _M_use_grouping
;
1584 const _CharT
* _M_truename
;
1585 size_t _M_truename_size
;
1586 const _CharT
* _M_falsename
;
1587 size_t _M_falsename_size
;
1588 _CharT _M_decimal_point
;
1589 _CharT _M_thousands_sep
;
1591 // A list of valid numeric literals for output: in the standard
1592 // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
1593 // This array contains the chars after having been passed
1594 // through the current locale's ctype<_CharT>.widen().
1595 _CharT _M_atoms_out
[__num_base::_S_oend
];
1597 // A list of valid numeric literals for input: in the standard
1598 // "C" locale, this is "-+xX0123456789abcdefABCDEF"
1599 // This array contains the chars after having been passed
1600 // through the current locale's ctype<_CharT>.widen().
1601 _CharT _M_atoms_in
[__num_base::_S_iend
];
1605 __numpunct_cache(size_t __refs
= 0) : facet(__refs
),
1606 _M_grouping(NULL
), _M_grouping_size(0), _M_use_grouping(false),
1607 _M_truename(NULL
), _M_truename_size(0), _M_falsename(NULL
),
1608 _M_falsename_size(0), _M_decimal_point(_CharT()),
1609 _M_thousands_sep(_CharT()), _M_allocated(false)
1612 ~__numpunct_cache();
1615 _M_cache(const locale
& __loc
);
1619 operator=(const __numpunct_cache
&);
1622 __numpunct_cache(const __numpunct_cache
&);
1625 template<typename _CharT
>
1626 __numpunct_cache
<_CharT
>::~__numpunct_cache()
1630 delete [] _M_grouping
;
1631 delete [] _M_truename
;
1632 delete [] _M_falsename
;
1637 * @brief Numpunct facet.
1639 * This facet stores several pieces of information related to printing and
1640 * scanning numbers, such as the decimal point character. It takes a
1641 * template parameter specifying the char type. The numpunct facet is
1642 * used by streams for many I/O operations involving numbers.
1644 * The numpunct template uses protected virtual functions to provide the
1645 * actual results. The public accessors forward the call to the virtual
1646 * functions. These virtual functions are hooks for developers to
1647 * implement the behavior they require from a numpunct facet.
1649 template<typename _CharT
>
1650 class numpunct
: public locale::facet
1656 typedef _CharT char_type
;
1657 typedef basic_string
<_CharT
> string_type
;
1659 typedef __numpunct_cache
<_CharT
> __cache_type
;
1662 __cache_type
* _M_data
;
1665 /// Numpunct facet id.
1666 static locale::id id
;
1669 * @brief Numpunct constructor.
1671 * @param refs Refcount to pass to the base class.
1674 numpunct(size_t __refs
= 0) : facet(__refs
), _M_data(NULL
)
1675 { _M_initialize_numpunct(); }
1678 * @brief Internal constructor. Not for general use.
1680 * This is a constructor for use by the library itself to set up the
1681 * predefined locale facets.
1683 * @param cache __numpunct_cache object.
1684 * @param refs Refcount to pass to the base class.
1687 numpunct(__cache_type
* __cache
, size_t __refs
= 0)
1688 : facet(__refs
), _M_data(__cache
)
1689 { _M_initialize_numpunct(); }
1692 * @brief Internal constructor. Not for general use.
1694 * This is a constructor for use by the library itself to set up new
1697 * @param cloc The "C" locale.
1698 * @param refs Refcount to pass to the base class.
1701 numpunct(__c_locale __cloc
, size_t __refs
= 0)
1702 : facet(__refs
), _M_data(NULL
)
1703 { _M_initialize_numpunct(__cloc
); }
1706 * @brief Return decimal point character.
1708 * This function returns a char_type to use as a decimal point. It
1709 * does so by returning returning
1710 * numpunct<char_type>::do_decimal_point().
1712 * @return @a char_type representing a decimal point.
1715 decimal_point() const
1716 { return this->do_decimal_point(); }
1719 * @brief Return thousands separator character.
1721 * This function returns a char_type to use as a thousands
1722 * separator. It does so by returning returning
1723 * numpunct<char_type>::do_thousands_sep().
1725 * @return char_type representing a thousands separator.
1728 thousands_sep() const
1729 { return this->do_thousands_sep(); }
1732 * @brief Return grouping specification.
1734 * This function returns a string representing groupings for the
1735 * integer part of a number. Groupings indicate where thousands
1736 * separators should be inserted in the integer part of a number.
1738 * Each char in the return string is interpret as an integer
1739 * rather than a character. These numbers represent the number
1740 * of digits in a group. The first char in the string
1741 * represents the number of digits in the least significant
1742 * group. If a char is negative, it indicates an unlimited
1743 * number of digits for the group. If more chars from the
1744 * string are required to group a number, the last char is used
1747 * For example, if the grouping() returns "\003\002" and is
1748 * applied to the number 123456789, this corresponds to
1749 * 12,34,56,789. Note that if the string was "32", this would
1750 * put more than 50 digits into the least significant group if
1751 * the character set is ASCII.
1753 * The string is returned by calling
1754 * numpunct<char_type>::do_grouping().
1756 * @return string representing grouping specification.
1760 { return this->do_grouping(); }
1763 * @brief Return string representation of bool true.
1765 * This function returns a string_type containing the text
1766 * representation for true bool variables. It does so by calling
1767 * numpunct<char_type>::do_truename().
1769 * @return string_type representing printed form of true.
1773 { return this->do_truename(); }
1776 * @brief Return string representation of bool false.
1778 * This function returns a string_type containing the text
1779 * representation for false bool variables. It does so by calling
1780 * numpunct<char_type>::do_falsename().
1782 * @return string_type representing printed form of false.
1786 { return this->do_falsename(); }
1794 * @brief Return decimal point character.
1796 * Returns a char_type to use as a decimal point. This function is a
1797 * hook for derived classes to change the value returned.
1799 * @return @a char_type representing a decimal point.
1802 do_decimal_point() const
1803 { return _M_data
->_M_decimal_point
; }
1806 * @brief Return thousands separator character.
1808 * Returns a char_type to use as a thousands separator. This function
1809 * is a hook for derived classes to change the value returned.
1811 * @return @a char_type representing a thousands separator.
1814 do_thousands_sep() const
1815 { return _M_data
->_M_thousands_sep
; }
1818 * @brief Return grouping specification.
1820 * Returns a string representing groupings for the integer part of a
1821 * number. This function is a hook for derived classes to change the
1822 * value returned. @see grouping() for details.
1824 * @return String representing grouping specification.
1828 { return _M_data
->_M_grouping
; }
1831 * @brief Return string representation of bool true.
1833 * Returns a string_type containing the text representation for true
1834 * bool variables. This function is a hook for derived classes to
1835 * change the value returned.
1837 * @return string_type representing printed form of true.
1841 { return _M_data
->_M_truename
; }
1844 * @brief Return string representation of bool false.
1846 * Returns a string_type containing the text representation for false
1847 * bool variables. This function is a hook for derived classes to
1848 * change the value returned.
1850 * @return string_type representing printed form of false.
1853 do_falsename() const
1854 { return _M_data
->_M_falsename
; }
1856 // For use at construction time only.
1858 _M_initialize_numpunct(__c_locale __cloc
= NULL
);
1861 template<typename _CharT
>
1862 locale::id numpunct
<_CharT
>::id
;
1865 numpunct
<char>::~numpunct();
1869 numpunct
<char>::_M_initialize_numpunct(__c_locale __cloc
);
1871 #ifdef _GLIBCXX_USE_WCHAR_T
1873 numpunct
<wchar_t>::~numpunct();
1877 numpunct
<wchar_t>::_M_initialize_numpunct(__c_locale __cloc
);
1880 /// class numpunct_byname [22.2.3.2].
1881 template<typename _CharT
>
1882 class numpunct_byname
: public numpunct
<_CharT
>
1885 typedef _CharT char_type
;
1886 typedef basic_string
<_CharT
> string_type
;
1889 numpunct_byname(const char* __s
, size_t __refs
= 0)
1890 : numpunct
<_CharT
>(__refs
)
1892 if (__builtin_strcmp(__s
, "C") != 0
1893 && __builtin_strcmp(__s
, "POSIX") != 0)
1896 this->_S_create_c_locale(__tmp
, __s
);
1897 this->_M_initialize_numpunct(__tmp
);
1898 this->_S_destroy_c_locale(__tmp
);
1904 ~numpunct_byname() { }
1907 _GLIBCXX_BEGIN_LDBL_NAMESPACE
1910 * @brief Facet for parsing number strings.
1912 * This facet encapsulates the code to parse and return a number
1913 * from a string. It is used by the istream numeric extraction
1916 * The num_get template uses protected virtual functions to provide the
1917 * actual results. The public accessors forward the call to the virtual
1918 * functions. These virtual functions are hooks for developers to
1919 * implement the behavior they require from the num_get facet.
1921 template<typename _CharT
, typename _InIter
>
1922 class num_get
: public locale::facet
1928 typedef _CharT char_type
;
1929 typedef _InIter iter_type
;
1932 /// Numpunct facet id.
1933 static locale::id id
;
1936 * @brief Constructor performs initialization.
1938 * This is the constructor provided by the standard.
1940 * @param refs Passed to the base facet class.
1943 num_get(size_t __refs
= 0) : facet(__refs
) { }
1946 * @brief Numeric parsing.
1948 * Parses the input stream into the bool @a v. It does so by calling
1949 * num_get::do_get().
1951 * If ios_base::boolalpha is set, attempts to read
1952 * ctype<CharT>::truename() or ctype<CharT>::falsename(). Sets
1953 * @a v to true or false if successful. Sets err to
1954 * ios_base::failbit if reading the string fails. Sets err to
1955 * ios_base::eofbit if the stream is emptied.
1957 * If ios_base::boolalpha is not set, proceeds as with reading a long,
1958 * except if the value is 1, sets @a v to true, if the value is 0, sets
1959 * @a v to false, and otherwise set err to ios_base::failbit.
1961 * @param in Start of input stream.
1962 * @param end End of input stream.
1963 * @param io Source of locale and flags.
1964 * @param err Error flags to set.
1965 * @param v Value to format and insert.
1966 * @return Iterator after reading.
1969 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
1970 ios_base::iostate
& __err
, bool& __v
) const
1971 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
1975 * @brief Numeric parsing.
1977 * Parses the input stream into the integral variable @a v. It does so
1978 * by calling num_get::do_get().
1980 * Parsing is affected by the flag settings in @a io.
1982 * The basic parse is affected by the value of io.flags() &
1983 * ios_base::basefield. If equal to ios_base::oct, parses like the
1984 * scanf %o specifier. Else if equal to ios_base::hex, parses like %X
1985 * specifier. Else if basefield equal to 0, parses like the %i
1986 * specifier. Otherwise, parses like %d for signed and %u for unsigned
1987 * types. The matching type length modifier is also used.
1989 * Digit grouping is interpreted according to numpunct::grouping() and
1990 * numpunct::thousands_sep(). If the pattern of digit groups isn't
1991 * consistent, sets err to ios_base::failbit.
1993 * If parsing the string yields a valid value for @a v, @a v is set.
1994 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
1995 * Sets err to ios_base::eofbit if the stream is emptied.
1997 * @param in Start of input stream.
1998 * @param end End of input stream.
1999 * @param io Source of locale and flags.
2000 * @param err Error flags to set.
2001 * @param v Value to format and insert.
2002 * @return Iterator after reading.
2005 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2006 ios_base::iostate
& __err
, long& __v
) const
2007 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2010 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2011 ios_base::iostate
& __err
, unsigned short& __v
) const
2012 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2015 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2016 ios_base::iostate
& __err
, unsigned int& __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& __v
) const
2022 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2024 #ifdef _GLIBCXX_USE_LONG_LONG
2026 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2027 ios_base::iostate
& __err
, long long& __v
) const
2028 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2031 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2032 ios_base::iostate
& __err
, unsigned long long& __v
) const
2033 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2039 * @brief Numeric parsing.
2041 * Parses the input stream into the integral variable @a v. It does so
2042 * by calling num_get::do_get().
2044 * The input characters are parsed like the scanf %g specifier. The
2045 * matching type length modifier is also used.
2047 * The decimal point character used is numpunct::decimal_point().
2048 * Digit grouping is interpreted according to numpunct::grouping() and
2049 * numpunct::thousands_sep(). If the pattern of digit groups isn't
2050 * consistent, sets err to ios_base::failbit.
2052 * If parsing the string yields a valid value for @a v, @a v is set.
2053 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2054 * Sets err to ios_base::eofbit if the stream is emptied.
2056 * @param in Start of input stream.
2057 * @param end End of input stream.
2058 * @param io Source of locale and flags.
2059 * @param err Error flags to set.
2060 * @param v Value to format and insert.
2061 * @return Iterator after reading.
2064 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2065 ios_base::iostate
& __err
, float& __v
) const
2066 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2069 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2070 ios_base::iostate
& __err
, double& __v
) const
2071 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2074 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2075 ios_base::iostate
& __err
, long double& __v
) const
2076 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2080 * @brief Numeric parsing.
2082 * Parses the input stream into the pointer variable @a v. It does so
2083 * by calling num_get::do_get().
2085 * The input characters are parsed like the scanf %p specifier.
2087 * Digit grouping is interpreted according to numpunct::grouping() and
2088 * numpunct::thousands_sep(). If the pattern of digit groups isn't
2089 * consistent, sets err to ios_base::failbit.
2091 * Note that the digit grouping effect for pointers is a bit ambiguous
2092 * in the standard and shouldn't be relied on. See DR 344.
2094 * If parsing the string yields a valid value for @a v, @a v is set.
2095 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2096 * Sets err to ios_base::eofbit if the stream is emptied.
2098 * @param in Start of input stream.
2099 * @param end End of input stream.
2100 * @param io Source of locale and flags.
2101 * @param err Error flags to set.
2102 * @param v Value to format and insert.
2103 * @return Iterator after reading.
2106 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2107 ios_base::iostate
& __err
, void*& __v
) const
2108 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2112 virtual ~num_get() { }
2115 _M_extract_float(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2116 string
& __xtrc
) const;
2118 template<typename _ValueT
>
2120 _M_extract_int(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2121 _ValueT
& __v
) const;
2123 template<typename _CharT2
>
2124 typename
__gnu_cxx::__enable_if
<__is_char
<_CharT2
>::__value
, int>::__type
2125 _M_find(const _CharT2
*, size_t __len
, _CharT2 __c
) const
2130 if (__c
>= _CharT2('0') && __c
< _CharT2(_CharT2('0') + __len
))
2131 __ret
= __c
- _CharT2('0');
2135 if (__c
>= _CharT2('0') && __c
<= _CharT2('9'))
2136 __ret
= __c
- _CharT2('0');
2137 else if (__c
>= _CharT2('a') && __c
<= _CharT2('f'))
2138 __ret
= 10 + (__c
- _CharT2('a'));
2139 else if (__c
>= _CharT2('A') && __c
<= _CharT2('F'))
2140 __ret
= 10 + (__c
- _CharT2('A'));
2145 template<typename _CharT2
>
2146 typename
__gnu_cxx::__enable_if
<!__is_char
<_CharT2
>::__value
,
2148 _M_find(const _CharT2
* __zero
, size_t __len
, _CharT2 __c
) const
2151 const char_type
* __q
= char_traits
<_CharT2
>::find(__zero
, __len
, __c
);
2154 __ret
= __q
- __zero
;
2163 * @brief Numeric parsing.
2165 * Parses the input stream into the variable @a v. This function is a
2166 * hook for derived classes to change the value returned. @see get()
2169 * @param in Start of input stream.
2170 * @param end End of input stream.
2171 * @param io Source of locale and flags.
2172 * @param err Error flags to set.
2173 * @param v Value to format and insert.
2174 * @return Iterator after reading.
2177 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, bool&) const;
2181 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, long&) const;
2184 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2185 unsigned short&) const;
2188 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2189 unsigned int&) const;
2192 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2193 unsigned long&) const;
2195 #ifdef _GLIBCXX_USE_LONG_LONG
2197 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2201 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2202 unsigned long long&) const;
2206 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2210 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2213 // XXX GLIBCXX_ABI Deprecated
2214 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2216 __do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2220 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2221 long double&) const;
2225 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2228 // XXX GLIBCXX_ABI Deprecated
2229 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2231 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2232 long double&) const;
2237 template<typename _CharT
, typename _InIter
>
2238 locale::id num_get
<_CharT
, _InIter
>::id
;
2242 * @brief Facet for converting numbers to strings.
2244 * This facet encapsulates the code to convert a number to a string. It is
2245 * used by the ostream numeric insertion operators.
2247 * The num_put template uses protected virtual functions to provide the
2248 * actual results. The public accessors forward the call to the virtual
2249 * functions. These virtual functions are hooks for developers to
2250 * implement the behavior they require from the num_put facet.
2252 template<typename _CharT
, typename _OutIter
>
2253 class num_put
: public locale::facet
2259 typedef _CharT char_type
;
2260 typedef _OutIter iter_type
;
2263 /// Numpunct facet id.
2264 static locale::id id
;
2267 * @brief Constructor performs initialization.
2269 * This is the constructor provided by the standard.
2271 * @param refs Passed to the base facet class.
2274 num_put(size_t __refs
= 0) : facet(__refs
) { }
2277 * @brief Numeric formatting.
2279 * Formats the boolean @a v and inserts it into a stream. It does so
2280 * by calling num_put::do_put().
2282 * If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
2283 * ctype<CharT>::falsename(). Otherwise formats @a v as an int.
2285 * @param s Stream to write to.
2286 * @param io Source of locale and flags.
2287 * @param fill Char_type to use for filling.
2288 * @param v Value to format and insert.
2289 * @return Iterator after writing.
2292 put(iter_type __s
, ios_base
& __f
, char_type __fill
, bool __v
) const
2293 { return this->do_put(__s
, __f
, __fill
, __v
); }
2297 * @brief Numeric formatting.
2299 * Formats the integral value @a v and inserts it into a
2300 * stream. It does so by calling num_put::do_put().
2302 * Formatting is affected by the flag settings in @a io.
2304 * The basic format is affected by the value of io.flags() &
2305 * ios_base::basefield. If equal to ios_base::oct, formats like the
2306 * printf %o specifier. Else if equal to ios_base::hex, formats like
2307 * %x or %X with ios_base::uppercase unset or set respectively.
2308 * Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
2309 * for unsigned values. Note that if both oct and hex are set, neither
2312 * If ios_base::showpos is set, '+' is output before positive values.
2313 * If ios_base::showbase is set, '0' precedes octal values (except 0)
2314 * and '0[xX]' precedes hex values.
2316 * Thousands separators are inserted according to numpunct::grouping()
2317 * and numpunct::thousands_sep(). The decimal point character used is
2318 * numpunct::decimal_point().
2320 * If io.width() is non-zero, enough @a fill characters are inserted to
2321 * make the result at least that wide. If
2322 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2323 * padded at the end. If ios_base::internal, then padding occurs
2324 * immediately after either a '+' or '-' or after '0x' or '0X'.
2325 * Otherwise, padding occurs at the beginning.
2327 * @param s Stream to write to.
2328 * @param io Source of locale and flags.
2329 * @param fill Char_type to use for filling.
2330 * @param v Value to format and insert.
2331 * @return Iterator after writing.
2334 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long __v
) const
2335 { return this->do_put(__s
, __f
, __fill
, __v
); }
2338 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2339 unsigned long __v
) const
2340 { return this->do_put(__s
, __f
, __fill
, __v
); }
2342 #ifdef _GLIBCXX_USE_LONG_LONG
2344 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long long __v
) const
2345 { return this->do_put(__s
, __f
, __fill
, __v
); }
2348 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2349 unsigned long long __v
) const
2350 { return this->do_put(__s
, __f
, __fill
, __v
); }
2356 * @brief Numeric formatting.
2358 * Formats the floating point value @a v and inserts it into a stream.
2359 * It does so by calling num_put::do_put().
2361 * Formatting is affected by the flag settings in @a io.
2363 * The basic format is affected by the value of io.flags() &
2364 * ios_base::floatfield. If equal to ios_base::fixed, formats like the
2365 * printf %f specifier. Else if equal to ios_base::scientific, formats
2366 * like %e or %E with ios_base::uppercase unset or set respectively.
2367 * Otherwise, formats like %g or %G depending on uppercase. Note that
2368 * if both fixed and scientific are set, the effect will also be like
2371 * The output precision is given by io.precision(). This precision is
2372 * capped at numeric_limits::digits10 + 2 (different for double and
2373 * long double). The default precision is 6.
2375 * If ios_base::showpos is set, '+' is output before positive values.
2376 * If ios_base::showpoint is set, a decimal point will always be
2379 * Thousands separators are inserted according to numpunct::grouping()
2380 * and numpunct::thousands_sep(). The decimal point character used is
2381 * numpunct::decimal_point().
2383 * If io.width() is non-zero, enough @a fill characters are inserted to
2384 * make the result at least that wide. If
2385 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2386 * padded at the end. If ios_base::internal, then padding occurs
2387 * immediately after either a '+' or '-' or after '0x' or '0X'.
2388 * Otherwise, padding occurs at the beginning.
2390 * @param s Stream to write to.
2391 * @param io Source of locale and flags.
2392 * @param fill Char_type to use for filling.
2393 * @param v Value to format and insert.
2394 * @return Iterator after writing.
2397 put(iter_type __s
, ios_base
& __f
, char_type __fill
, double __v
) const
2398 { return this->do_put(__s
, __f
, __fill
, __v
); }
2401 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2402 long double __v
) const
2403 { return this->do_put(__s
, __f
, __fill
, __v
); }
2407 * @brief Numeric formatting.
2409 * Formats the pointer value @a v and inserts it into a stream. It
2410 * does so by calling num_put::do_put().
2412 * This function formats @a v as an unsigned long with ios_base::hex
2413 * and ios_base::showbase set.
2415 * @param s Stream to write to.
2416 * @param io Source of locale and flags.
2417 * @param fill Char_type to use for filling.
2418 * @param v Value to format and insert.
2419 * @return Iterator after writing.
2422 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2423 const void* __v
) const
2424 { return this->do_put(__s
, __f
, __fill
, __v
); }
2427 template<typename _ValueT
>
2429 _M_insert_float(iter_type
, ios_base
& __io
, char_type __fill
,
2430 char __mod
, _ValueT __v
) const;
2433 _M_group_float(const char* __grouping
, size_t __grouping_size
,
2434 char_type __sep
, const char_type
* __p
, char_type
* __new
,
2435 char_type
* __cs
, int& __len
) const;
2437 template<typename _ValueT
>
2439 _M_insert_int(iter_type
, ios_base
& __io
, char_type __fill
,
2443 _M_group_int(const char* __grouping
, size_t __grouping_size
,
2444 char_type __sep
, ios_base
& __io
, char_type
* __new
,
2445 char_type
* __cs
, int& __len
) const;
2448 _M_pad(char_type __fill
, streamsize __w
, ios_base
& __io
,
2449 char_type
* __new
, const char_type
* __cs
, int& __len
) const;
2457 * @brief Numeric formatting.
2459 * These functions do the work of formatting numeric values and
2460 * inserting them into a stream. This function is a hook for derived
2461 * classes to change the value returned.
2463 * @param s Stream to write to.
2464 * @param io Source of locale and flags.
2465 * @param fill Char_type to use for filling.
2466 * @param v Value to format and insert.
2467 * @return Iterator after writing.
2470 do_put(iter_type
, ios_base
&, char_type __fill
, bool __v
) const;
2473 do_put(iter_type
, ios_base
&, char_type __fill
, long __v
) const;
2476 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long) const;
2478 #ifdef _GLIBCXX_USE_LONG_LONG
2480 do_put(iter_type
, ios_base
&, char_type __fill
, long long __v
) const;
2483 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long long) const;
2487 do_put(iter_type
, ios_base
&, char_type __fill
, double __v
) const;
2489 // XXX GLIBCXX_ABI Deprecated
2490 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2492 __do_put(iter_type
, ios_base
&, char_type __fill
, double __v
) const;
2495 do_put(iter_type
, ios_base
&, char_type __fill
, long double __v
) const;
2499 do_put(iter_type
, ios_base
&, char_type __fill
, const void* __v
) const;
2501 // XXX GLIBCXX_ABI Deprecated
2502 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2504 do_put(iter_type
, ios_base
&, char_type __fill
, long double __v
) const;
2509 template <typename _CharT
, typename _OutIter
>
2510 locale::id num_put
<_CharT
, _OutIter
>::id
;
2512 _GLIBCXX_END_LDBL_NAMESPACE
2514 // Subclause convenience interfaces, inlines.
2515 // NB: These are inline because, when used in a loop, some compilers
2516 // can hoist the body out of the loop; then it's just as fast as the
2517 // C is*() function.
2519 /// Convenience interface to ctype.is(ctype_base::space, __c).
2520 template<typename _CharT
>
2522 isspace(_CharT __c
, const locale
& __loc
)
2523 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::space
, __c
); }
2525 /// Convenience interface to ctype.is(ctype_base::print, __c).
2526 template<typename _CharT
>
2528 isprint(_CharT __c
, const locale
& __loc
)
2529 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::print
, __c
); }
2531 /// Convenience interface to ctype.is(ctype_base::cntrl, __c).
2532 template<typename _CharT
>
2534 iscntrl(_CharT __c
, const locale
& __loc
)
2535 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::cntrl
, __c
); }
2537 /// Convenience interface to ctype.is(ctype_base::upper, __c).
2538 template<typename _CharT
>
2540 isupper(_CharT __c
, const locale
& __loc
)
2541 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::upper
, __c
); }
2543 /// Convenience interface to ctype.is(ctype_base::lower, __c).
2544 template<typename _CharT
>
2546 islower(_CharT __c
, const locale
& __loc
)
2547 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::lower
, __c
); }
2549 /// Convenience interface to ctype.is(ctype_base::alpha, __c).
2550 template<typename _CharT
>
2552 isalpha(_CharT __c
, const locale
& __loc
)
2553 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alpha
, __c
); }
2555 /// Convenience interface to ctype.is(ctype_base::digit, __c).
2556 template<typename _CharT
>
2558 isdigit(_CharT __c
, const locale
& __loc
)
2559 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::digit
, __c
); }
2561 /// Convenience interface to ctype.is(ctype_base::punct, __c).
2562 template<typename _CharT
>
2564 ispunct(_CharT __c
, const locale
& __loc
)
2565 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::punct
, __c
); }
2567 /// Convenience interface to ctype.is(ctype_base::xdigit, __c).
2568 template<typename _CharT
>
2570 isxdigit(_CharT __c
, const locale
& __loc
)
2571 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::xdigit
, __c
); }
2573 /// Convenience interface to ctype.is(ctype_base::alnum, __c).
2574 template<typename _CharT
>
2576 isalnum(_CharT __c
, const locale
& __loc
)
2577 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alnum
, __c
); }
2579 /// Convenience interface to ctype.is(ctype_base::graph, __c).
2580 template<typename _CharT
>
2582 isgraph(_CharT __c
, const locale
& __loc
)
2583 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::graph
, __c
); }
2585 /// Convenience interface to ctype.toupper(__c).
2586 template<typename _CharT
>
2588 toupper(_CharT __c
, const locale
& __loc
)
2589 { return use_facet
<ctype
<_CharT
> >(__loc
).toupper(__c
); }
2591 /// Convenience interface to ctype.tolower(__c).
2592 template<typename _CharT
>
2594 tolower(_CharT __c
, const locale
& __loc
)
2595 { return use_facet
<ctype
<_CharT
> >(__loc
).tolower(__c
); }
2597 _GLIBCXX_END_NAMESPACE
2599 #ifndef _GLIBCXX_EXPORT_TEMPLATE
2600 # include <bits/locale_facets.tcc>