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
);
1165 void _M_widen_init() const
1167 char __tmp
[sizeof(_M_widen
)];
1168 for (size_t __i
= 0; __i
< sizeof(_M_widen
); ++__i
)
1170 do_widen(__tmp
, __tmp
+ sizeof(__tmp
), _M_widen
);
1173 // Set _M_widen_ok to 2 if memcpy can't be used.
1174 if (__builtin_memcmp(__tmp
, _M_widen
, sizeof(_M_widen
)))
1178 // Fill in the narrowing cache and flag whether all values are
1179 // valid or not. _M_narrow_ok is set to 2 if memcpy can't
1181 void _M_narrow_init() const
1183 char __tmp
[sizeof(_M_narrow
)];
1184 for (size_t __i
= 0; __i
< sizeof(_M_narrow
); ++__i
)
1186 do_narrow(__tmp
, __tmp
+ sizeof(__tmp
), 0, _M_narrow
);
1189 if (__builtin_memcmp(__tmp
, _M_narrow
, sizeof(_M_narrow
)))
1193 // Deal with the special case of zero: renarrow with a
1194 // different default and compare.
1196 do_narrow(__tmp
, __tmp
+ 1, 1, &__c
);
1205 use_facet
<ctype
<char> >(const locale
& __loc
);
1207 #ifdef _GLIBCXX_USE_WCHAR_T
1208 // 22.2.1.3 ctype<wchar_t> specialization
1210 * @brief The ctype<wchar_t> specialization.
1212 * This class defines classification and conversion functions for the
1213 * wchar_t type. It gets used by wchar_t streams for many I/O operations.
1214 * The wchar_t specialization provides a number of optimizations as well.
1216 * ctype<wchar_t> inherits its public methods from
1217 * __ctype_abstract_base<wchar_t>.
1220 class ctype
<wchar_t> : public __ctype_abstract_base
<wchar_t>
1224 /// Typedef for the template parameter wchar_t.
1225 typedef wchar_t char_type
;
1226 typedef wctype_t __wmask_type
;
1229 __c_locale _M_c_locale_ctype
;
1231 // Pre-computed narrowed and widened chars.
1233 char _M_narrow
[128];
1234 wint_t _M_widen
[1 + static_cast<unsigned char>(-1)];
1236 // Pre-computed elements for do_is.
1238 __wmask_type _M_wmask
[16];
1242 /// The facet id for ctype<wchar_t>
1243 static locale::id id
;
1246 * @brief Constructor performs initialization.
1248 * This is the constructor provided by the standard.
1250 * @param refs Passed to the base facet class.
1253 ctype(size_t __refs
= 0);
1256 * @brief Constructor performs static initialization.
1258 * This constructor is used to construct the initial C locale facet.
1260 * @param cloc Handle to C locale data.
1261 * @param refs Passed to the base facet class.
1264 ctype(__c_locale __cloc
, size_t __refs
= 0);
1268 _M_convert_to_wmask(const mask __m
) const;
1275 * @brief Test wchar_t classification.
1277 * This function finds a mask M for @a c and compares it to mask @a m.
1279 * do_is() is a hook for a derived facet to change the behavior of
1280 * classifying. do_is() must always return the same result for the
1283 * @param c The wchar_t to find the mask of.
1284 * @param m The mask to compare against.
1285 * @return (M & m) != 0.
1288 do_is(mask __m
, char_type __c
) const;
1291 * @brief Return a mask array.
1293 * This function finds the mask for each wchar_t in the range [lo,hi)
1294 * and successively writes it to vec. vec must have as many elements
1297 * do_is() is a hook for a derived facet to change the behavior of
1298 * classifying. do_is() must always return the same result for the
1301 * @param lo Pointer to start of range.
1302 * @param hi Pointer to end of range.
1303 * @param vec Pointer to an array of mask storage.
1306 virtual const char_type
*
1307 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
1310 * @brief Find wchar_t matching mask
1312 * This function searches for and returns the first wchar_t c in
1313 * [lo,hi) for which is(m,c) is true.
1315 * do_scan_is() is a hook for a derived facet to change the behavior of
1316 * match searching. do_is() must always return the same result for the
1319 * @param m The mask to compare against.
1320 * @param lo Pointer to start of range.
1321 * @param hi Pointer to end of range.
1322 * @return Pointer to a matching wchar_t if found, else @a hi.
1324 virtual const char_type
*
1325 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
1328 * @brief Find wchar_t not matching mask
1330 * This function searches for and returns a pointer to the first
1331 * wchar_t c of [lo,hi) for which is(m,c) is false.
1333 * do_scan_is() is a hook for a derived facet to change the behavior of
1334 * match searching. do_is() must always return the same result for the
1337 * @param m The mask to compare against.
1338 * @param lo Pointer to start of range.
1339 * @param hi Pointer to end of range.
1340 * @return Pointer to a non-matching wchar_t if found, else @a hi.
1342 virtual const char_type
*
1343 do_scan_not(mask __m
, const char_type
* __lo
,
1344 const char_type
* __hi
) const;
1347 * @brief Convert to uppercase.
1349 * This virtual function converts the wchar_t argument to uppercase if
1350 * possible. If not possible (for example, '2'), returns the argument.
1352 * do_toupper() is a hook for a derived facet to change the behavior of
1353 * uppercasing. do_toupper() must always return the same result for
1356 * @param c The wchar_t to convert.
1357 * @return The uppercase wchar_t if convertible, else @a c.
1360 do_toupper(char_type
) const;
1363 * @brief Convert array to uppercase.
1365 * This virtual function converts each wchar_t in the range [lo,hi) to
1366 * uppercase if possible. Other elements remain untouched.
1368 * do_toupper() is a hook for a derived facet to change the behavior of
1369 * uppercasing. do_toupper() must always return the same result for
1372 * @param lo Pointer to start of range.
1373 * @param hi Pointer to end of range.
1376 virtual const char_type
*
1377 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
1380 * @brief Convert to lowercase.
1382 * This virtual function converts the argument to lowercase if
1383 * possible. If not possible (for example, '2'), returns the argument.
1385 * do_tolower() is a hook for a derived facet to change the behavior of
1386 * lowercasing. do_tolower() must always return the same result for
1389 * @param c The wchar_t to convert.
1390 * @return The lowercase wchar_t if convertible, else @a c.
1393 do_tolower(char_type
) const;
1396 * @brief Convert array to lowercase.
1398 * This virtual function converts each wchar_t in the range [lo,hi) to
1399 * lowercase if possible. Other elements remain untouched.
1401 * do_tolower() is a hook for a derived facet to change the behavior of
1402 * lowercasing. do_tolower() must always return the same result for
1405 * @param lo Pointer to start of range.
1406 * @param hi Pointer to end of range.
1409 virtual const char_type
*
1410 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
1413 * @brief Widen char to wchar_t
1415 * This virtual function converts the char to wchar_t using the
1416 * simplest reasonable transformation. For an underived ctype<wchar_t>
1417 * facet, the argument will be cast to wchar_t.
1419 * do_widen() is a hook for a derived facet to change the behavior of
1420 * widening. do_widen() must always return the same result for the
1423 * Note: this is not what you want for codepage conversions. See
1426 * @param c The char to convert.
1427 * @return The converted wchar_t.
1430 do_widen(char) const;
1433 * @brief Widen char array to wchar_t array
1435 * This function converts each char in the input to wchar_t using the
1436 * simplest reasonable transformation. For an underived ctype<wchar_t>
1437 * facet, the argument will be copied, casting each element to wchar_t.
1439 * do_widen() is a hook for a derived facet to change the behavior of
1440 * widening. do_widen() must always return the same result for the
1443 * Note: this is not what you want for codepage conversions. See
1446 * @param lo Pointer to start range.
1447 * @param hi Pointer to end of range.
1448 * @param to Pointer to the destination array.
1452 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
1455 * @brief Narrow wchar_t to char
1457 * This virtual function converts the argument to char using
1458 * the simplest reasonable transformation. If the conversion
1459 * fails, dfault is returned instead. For an underived
1460 * ctype<wchar_t> facet, @a c will be cast to char and
1463 * do_narrow() is a hook for a derived facet to change the
1464 * behavior of narrowing. do_narrow() must always return the
1465 * same result for the same input.
1467 * Note: this is not what you want for codepage conversions. See
1470 * @param c The wchar_t to convert.
1471 * @param dfault Char to return if conversion fails.
1472 * @return The converted char.
1475 do_narrow(char_type
, char __dfault
) const;
1478 * @brief Narrow wchar_t array to char array
1480 * This virtual function converts each wchar_t in the range [lo,hi) to
1481 * char using the simplest reasonable transformation and writes the
1482 * results to the destination array. For any wchar_t in the input that
1483 * cannot be converted, @a dfault is used instead. For an underived
1484 * ctype<wchar_t> facet, the argument will be copied, casting each
1487 * do_narrow() is a hook for a derived facet to change the behavior of
1488 * narrowing. do_narrow() must always return the same result for the
1491 * Note: this is not what you want for codepage conversions. See
1494 * @param lo Pointer to start of range.
1495 * @param hi Pointer to end of range.
1496 * @param dfault Char to use if conversion fails.
1497 * @param to Pointer to the destination array.
1500 virtual const char_type
*
1501 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
1502 char __dfault
, char* __dest
) const;
1504 // For use at construction time only.
1506 _M_initialize_ctype();
1510 const ctype
<wchar_t>&
1511 use_facet
<ctype
<wchar_t> >(const locale
& __loc
);
1512 #endif //_GLIBCXX_USE_WCHAR_T
1514 /// class ctype_byname [22.2.1.2].
1515 template<typename _CharT
>
1516 class ctype_byname
: public ctype
<_CharT
>
1519 typedef typename ctype
<_CharT
>::mask mask
;
1522 ctype_byname(const char* __s
, size_t __refs
= 0);
1526 ~ctype_byname() { };
1529 /// 22.2.1.4 Class ctype_byname specializations.
1531 class ctype_byname
<char> : public ctype
<char>
1535 ctype_byname(const char* __s
, size_t __refs
= 0);
1542 #ifdef _GLIBCXX_USE_WCHAR_T
1544 class ctype_byname
<wchar_t> : public ctype
<wchar_t>
1548 ctype_byname(const char* __s
, size_t __refs
= 0);
1556 _GLIBCXX_END_NAMESPACE
1558 // Include host and configuration specific ctype inlines.
1559 #include <bits/ctype_inline.h>
1561 _GLIBCXX_BEGIN_NAMESPACE(std
)
1563 // 22.2.2 The numeric category.
1567 // NB: Code depends on the order of _S_atoms_out elements.
1568 // Below are the indices into _S_atoms_out.
1576 _S_odigits_end
= _S_odigits
+ 16,
1577 _S_oudigits
= _S_odigits_end
,
1578 _S_oudigits_end
= _S_oudigits
+ 16,
1579 _S_oe
= _S_odigits
+ 14, // For scientific notation, 'e'
1580 _S_oE
= _S_oudigits
+ 14, // For scientific notation, 'E'
1581 _S_oend
= _S_oudigits_end
1584 // A list of valid numeric literals for output. This array
1585 // contains chars that will be passed through the current locale's
1586 // ctype<_CharT>.widen() and then used to render numbers.
1587 // For the standard "C" locale, this is
1588 // "-+xX0123456789abcdef0123456789ABCDEF".
1589 static const char* _S_atoms_out
;
1591 // String literal of acceptable (narrow) input, for num_get.
1592 // "-+xX0123456789abcdefABCDEF"
1593 static const char* _S_atoms_in
;
1602 _S_ie
= _S_izero
+ 14,
1603 _S_iE
= _S_izero
+ 20,
1608 // Construct and return valid scanf format for floating point types.
1610 _S_format_float(const ios_base
& __io
, char* __fptr
, char __mod
);
1613 template<typename _CharT
>
1614 struct __numpunct_cache
: public locale::facet
1616 const char* _M_grouping
;
1617 size_t _M_grouping_size
;
1618 bool _M_use_grouping
;
1619 const _CharT
* _M_truename
;
1620 size_t _M_truename_size
;
1621 const _CharT
* _M_falsename
;
1622 size_t _M_falsename_size
;
1623 _CharT _M_decimal_point
;
1624 _CharT _M_thousands_sep
;
1626 // A list of valid numeric literals for output: in the standard
1627 // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
1628 // This array contains the chars after having been passed
1629 // through the current locale's ctype<_CharT>.widen().
1630 _CharT _M_atoms_out
[__num_base::_S_oend
];
1632 // A list of valid numeric literals for input: in the standard
1633 // "C" locale, this is "-+xX0123456789abcdefABCDEF"
1634 // This array contains the chars after having been passed
1635 // through the current locale's ctype<_CharT>.widen().
1636 _CharT _M_atoms_in
[__num_base::_S_iend
];
1640 __numpunct_cache(size_t __refs
= 0) : facet(__refs
),
1641 _M_grouping(NULL
), _M_grouping_size(0), _M_use_grouping(false),
1642 _M_truename(NULL
), _M_truename_size(0), _M_falsename(NULL
),
1643 _M_falsename_size(0), _M_decimal_point(_CharT()),
1644 _M_thousands_sep(_CharT()), _M_allocated(false)
1647 ~__numpunct_cache();
1650 _M_cache(const locale
& __loc
);
1654 operator=(const __numpunct_cache
&);
1657 __numpunct_cache(const __numpunct_cache
&);
1660 template<typename _CharT
>
1661 __numpunct_cache
<_CharT
>::~__numpunct_cache()
1665 delete [] _M_grouping
;
1666 delete [] _M_truename
;
1667 delete [] _M_falsename
;
1672 * @brief Numpunct facet.
1674 * This facet stores several pieces of information related to printing and
1675 * scanning numbers, such as the decimal point character. It takes a
1676 * template parameter specifying the char type. The numpunct facet is
1677 * used by streams for many I/O operations involving numbers.
1679 * The numpunct template uses protected virtual functions to provide the
1680 * actual results. The public accessors forward the call to the virtual
1681 * functions. These virtual functions are hooks for developers to
1682 * implement the behavior they require from a numpunct facet.
1684 template<typename _CharT
>
1685 class numpunct
: public locale::facet
1691 typedef _CharT char_type
;
1692 typedef basic_string
<_CharT
> string_type
;
1694 typedef __numpunct_cache
<_CharT
> __cache_type
;
1697 __cache_type
* _M_data
;
1700 /// Numpunct facet id.
1701 static locale::id id
;
1704 * @brief Numpunct constructor.
1706 * @param refs Refcount to pass to the base class.
1709 numpunct(size_t __refs
= 0) : facet(__refs
), _M_data(NULL
)
1710 { _M_initialize_numpunct(); }
1713 * @brief Internal constructor. Not for general use.
1715 * This is a constructor for use by the library itself to set up the
1716 * predefined locale facets.
1718 * @param cache __numpunct_cache object.
1719 * @param refs Refcount to pass to the base class.
1722 numpunct(__cache_type
* __cache
, size_t __refs
= 0)
1723 : facet(__refs
), _M_data(__cache
)
1724 { _M_initialize_numpunct(); }
1727 * @brief Internal constructor. Not for general use.
1729 * This is a constructor for use by the library itself to set up new
1732 * @param cloc The "C" locale.
1733 * @param refs Refcount to pass to the base class.
1736 numpunct(__c_locale __cloc
, size_t __refs
= 0)
1737 : facet(__refs
), _M_data(NULL
)
1738 { _M_initialize_numpunct(__cloc
); }
1741 * @brief Return decimal point character.
1743 * This function returns a char_type to use as a decimal point. It
1744 * does so by returning returning
1745 * numpunct<char_type>::do_decimal_point().
1747 * @return @a char_type representing a decimal point.
1750 decimal_point() const
1751 { return this->do_decimal_point(); }
1754 * @brief Return thousands separator character.
1756 * This function returns a char_type to use as a thousands
1757 * separator. It does so by returning returning
1758 * numpunct<char_type>::do_thousands_sep().
1760 * @return char_type representing a thousands separator.
1763 thousands_sep() const
1764 { return this->do_thousands_sep(); }
1767 * @brief Return grouping specification.
1769 * This function returns a string representing groupings for the
1770 * integer part of a number. Groupings indicate where thousands
1771 * separators should be inserted in the integer part of a number.
1773 * Each char in the return string is interpret as an integer
1774 * rather than a character. These numbers represent the number
1775 * of digits in a group. The first char in the string
1776 * represents the number of digits in the least significant
1777 * group. If a char is negative, it indicates an unlimited
1778 * number of digits for the group. If more chars from the
1779 * string are required to group a number, the last char is used
1782 * For example, if the grouping() returns "\003\002" and is
1783 * applied to the number 123456789, this corresponds to
1784 * 12,34,56,789. Note that if the string was "32", this would
1785 * put more than 50 digits into the least significant group if
1786 * the character set is ASCII.
1788 * The string is returned by calling
1789 * numpunct<char_type>::do_grouping().
1791 * @return string representing grouping specification.
1795 { return this->do_grouping(); }
1798 * @brief Return string representation of bool true.
1800 * This function returns a string_type containing the text
1801 * representation for true bool variables. It does so by calling
1802 * numpunct<char_type>::do_truename().
1804 * @return string_type representing printed form of true.
1808 { return this->do_truename(); }
1811 * @brief Return string representation of bool false.
1813 * This function returns a string_type containing the text
1814 * representation for false bool variables. It does so by calling
1815 * numpunct<char_type>::do_falsename().
1817 * @return string_type representing printed form of false.
1821 { return this->do_falsename(); }
1829 * @brief Return decimal point character.
1831 * Returns a char_type to use as a decimal point. This function is a
1832 * hook for derived classes to change the value returned.
1834 * @return @a char_type representing a decimal point.
1837 do_decimal_point() const
1838 { return _M_data
->_M_decimal_point
; }
1841 * @brief Return thousands separator character.
1843 * Returns a char_type to use as a thousands separator. This function
1844 * is a hook for derived classes to change the value returned.
1846 * @return @a char_type representing a thousands separator.
1849 do_thousands_sep() const
1850 { return _M_data
->_M_thousands_sep
; }
1853 * @brief Return grouping specification.
1855 * Returns a string representing groupings for the integer part of a
1856 * number. This function is a hook for derived classes to change the
1857 * value returned. @see grouping() for details.
1859 * @return String representing grouping specification.
1863 { return _M_data
->_M_grouping
; }
1866 * @brief Return string representation of bool true.
1868 * Returns a string_type containing the text representation for true
1869 * bool variables. This function is a hook for derived classes to
1870 * change the value returned.
1872 * @return string_type representing printed form of true.
1876 { return _M_data
->_M_truename
; }
1879 * @brief Return string representation of bool false.
1881 * Returns a string_type containing the text representation for false
1882 * bool variables. This function is a hook for derived classes to
1883 * change the value returned.
1885 * @return string_type representing printed form of false.
1888 do_falsename() const
1889 { return _M_data
->_M_falsename
; }
1891 // For use at construction time only.
1893 _M_initialize_numpunct(__c_locale __cloc
= NULL
);
1896 template<typename _CharT
>
1897 locale::id numpunct
<_CharT
>::id
;
1900 numpunct
<char>::~numpunct();
1904 numpunct
<char>::_M_initialize_numpunct(__c_locale __cloc
);
1906 #ifdef _GLIBCXX_USE_WCHAR_T
1908 numpunct
<wchar_t>::~numpunct();
1912 numpunct
<wchar_t>::_M_initialize_numpunct(__c_locale __cloc
);
1915 /// class numpunct_byname [22.2.3.2].
1916 template<typename _CharT
>
1917 class numpunct_byname
: public numpunct
<_CharT
>
1920 typedef _CharT char_type
;
1921 typedef basic_string
<_CharT
> string_type
;
1924 numpunct_byname(const char* __s
, size_t __refs
= 0)
1925 : numpunct
<_CharT
>(__refs
)
1927 if (__builtin_strcmp(__s
, "C") != 0
1928 && __builtin_strcmp(__s
, "POSIX") != 0)
1931 this->_S_create_c_locale(__tmp
, __s
);
1932 this->_M_initialize_numpunct(__tmp
);
1933 this->_S_destroy_c_locale(__tmp
);
1939 ~numpunct_byname() { }
1942 _GLIBCXX_BEGIN_LDBL_NAMESPACE
1945 * @brief Facet for parsing number strings.
1947 * This facet encapsulates the code to parse and return a number
1948 * from a string. It is used by the istream numeric extraction
1951 * The num_get template uses protected virtual functions to provide the
1952 * actual results. The public accessors forward the call to the virtual
1953 * functions. These virtual functions are hooks for developers to
1954 * implement the behavior they require from the num_get facet.
1956 template<typename _CharT
, typename _InIter
>
1957 class num_get
: public locale::facet
1963 typedef _CharT char_type
;
1964 typedef _InIter iter_type
;
1967 /// Numpunct facet id.
1968 static locale::id id
;
1971 * @brief Constructor performs initialization.
1973 * This is the constructor provided by the standard.
1975 * @param refs Passed to the base facet class.
1978 num_get(size_t __refs
= 0) : facet(__refs
) { }
1981 * @brief Numeric parsing.
1983 * Parses the input stream into the bool @a v. It does so by calling
1984 * num_get::do_get().
1986 * If ios_base::boolalpha is set, attempts to read
1987 * ctype<CharT>::truename() or ctype<CharT>::falsename(). Sets
1988 * @a v to true or false if successful. Sets err to
1989 * ios_base::failbit if reading the string fails. Sets err to
1990 * ios_base::eofbit if the stream is emptied.
1992 * If ios_base::boolalpha is not set, proceeds as with reading a long,
1993 * except if the value is 1, sets @a v to true, if the value is 0, sets
1994 * @a v to false, and otherwise set err to ios_base::failbit.
1996 * @param in Start of input stream.
1997 * @param end End of input stream.
1998 * @param io Source of locale and flags.
1999 * @param err Error flags to set.
2000 * @param v Value to format and insert.
2001 * @return Iterator after reading.
2004 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2005 ios_base::iostate
& __err
, bool& __v
) const
2006 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2010 * @brief Numeric parsing.
2012 * Parses the input stream into the integral variable @a v. It does so
2013 * by calling num_get::do_get().
2015 * Parsing is affected by the flag settings in @a io.
2017 * The basic parse is affected by the value of io.flags() &
2018 * ios_base::basefield. If equal to ios_base::oct, parses like the
2019 * scanf %o specifier. Else if equal to ios_base::hex, parses like %X
2020 * specifier. Else if basefield equal to 0, parses like the %i
2021 * specifier. Otherwise, parses like %d for signed and %u for unsigned
2022 * types. The matching type length modifier is also used.
2024 * Digit grouping is interpreted according to numpunct::grouping() and
2025 * numpunct::thousands_sep(). If the pattern of digit groups isn't
2026 * consistent, sets err to ios_base::failbit.
2028 * If parsing the string yields a valid value for @a v, @a v is set.
2029 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2030 * Sets err to ios_base::eofbit if the stream is emptied.
2032 * @param in Start of input stream.
2033 * @param end End of input stream.
2034 * @param io Source of locale and flags.
2035 * @param err Error flags to set.
2036 * @param v Value to format and insert.
2037 * @return Iterator after reading.
2040 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2041 ios_base::iostate
& __err
, long& __v
) const
2042 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2045 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2046 ios_base::iostate
& __err
, unsigned short& __v
) const
2047 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2050 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2051 ios_base::iostate
& __err
, unsigned int& __v
) const
2052 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2055 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2056 ios_base::iostate
& __err
, unsigned long& __v
) const
2057 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2059 #ifdef _GLIBCXX_USE_LONG_LONG
2061 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2062 ios_base::iostate
& __err
, long long& __v
) const
2063 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2066 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2067 ios_base::iostate
& __err
, unsigned long long& __v
) const
2068 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2074 * @brief Numeric parsing.
2076 * Parses the input stream into the integral variable @a v. It does so
2077 * by calling num_get::do_get().
2079 * The input characters are parsed like the scanf %g specifier. The
2080 * matching type length modifier is also used.
2082 * The decimal point character used is numpunct::decimal_point().
2083 * Digit grouping is interpreted according to numpunct::grouping() and
2084 * numpunct::thousands_sep(). If the pattern of digit groups isn't
2085 * consistent, sets err to ios_base::failbit.
2087 * If parsing the string yields a valid value for @a v, @a v is set.
2088 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2089 * Sets err to ios_base::eofbit if the stream is emptied.
2091 * @param in Start of input stream.
2092 * @param end End of input stream.
2093 * @param io Source of locale and flags.
2094 * @param err Error flags to set.
2095 * @param v Value to format and insert.
2096 * @return Iterator after reading.
2099 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2100 ios_base::iostate
& __err
, float& __v
) const
2101 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2104 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2105 ios_base::iostate
& __err
, double& __v
) const
2106 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2109 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2110 ios_base::iostate
& __err
, long double& __v
) const
2111 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2115 * @brief Numeric parsing.
2117 * Parses the input stream into the pointer variable @a v. It does so
2118 * by calling num_get::do_get().
2120 * The input characters are parsed like the scanf %p specifier.
2122 * Digit grouping is interpreted according to numpunct::grouping() and
2123 * numpunct::thousands_sep(). If the pattern of digit groups isn't
2124 * consistent, sets err to ios_base::failbit.
2126 * Note that the digit grouping effect for pointers is a bit ambiguous
2127 * in the standard and shouldn't be relied on. See DR 344.
2129 * If parsing the string yields a valid value for @a v, @a v is set.
2130 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2131 * Sets err to ios_base::eofbit if the stream is emptied.
2133 * @param in Start of input stream.
2134 * @param end End of input stream.
2135 * @param io Source of locale and flags.
2136 * @param err Error flags to set.
2137 * @param v Value to format and insert.
2138 * @return Iterator after reading.
2141 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2142 ios_base::iostate
& __err
, void*& __v
) const
2143 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2147 virtual ~num_get() { }
2150 _M_extract_float(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2151 string
& __xtrc
) const;
2153 template<typename _ValueT
>
2155 _M_extract_int(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2156 _ValueT
& __v
) const;
2158 template<typename _CharT2
>
2159 typename
__gnu_cxx::__enable_if
<__is_char
<_CharT2
>::__value
, int>::__type
2160 _M_find(const _CharT2
*, size_t __len
, _CharT2 __c
) const
2165 if (__c
>= _CharT2('0') && __c
< _CharT2(_CharT2('0') + __len
))
2166 __ret
= __c
- _CharT2('0');
2170 if (__c
>= _CharT2('0') && __c
<= _CharT2('9'))
2171 __ret
= __c
- _CharT2('0');
2172 else if (__c
>= _CharT2('a') && __c
<= _CharT2('f'))
2173 __ret
= 10 + (__c
- _CharT2('a'));
2174 else if (__c
>= _CharT2('A') && __c
<= _CharT2('F'))
2175 __ret
= 10 + (__c
- _CharT2('A'));
2180 template<typename _CharT2
>
2181 typename
__gnu_cxx::__enable_if
<!__is_char
<_CharT2
>::__value
,
2183 _M_find(const _CharT2
* __zero
, size_t __len
, _CharT2 __c
) const
2186 const char_type
* __q
= char_traits
<_CharT2
>::find(__zero
, __len
, __c
);
2189 __ret
= __q
- __zero
;
2198 * @brief Numeric parsing.
2200 * Parses the input stream into the variable @a v. This function is a
2201 * hook for derived classes to change the value returned. @see get()
2204 * @param in Start of input stream.
2205 * @param end End of input stream.
2206 * @param io Source of locale and flags.
2207 * @param err Error flags to set.
2208 * @param v Value to format and insert.
2209 * @return Iterator after reading.
2212 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, bool&) const;
2216 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, long&) const;
2219 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2220 unsigned short&) const;
2223 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2224 unsigned int&) const;
2227 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2228 unsigned long&) const;
2230 #ifdef _GLIBCXX_USE_LONG_LONG
2232 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2236 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2237 unsigned long long&) const;
2241 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2245 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2248 // XXX GLIBCXX_ABI Deprecated
2249 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2251 __do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2255 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2256 long double&) const;
2260 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2263 // XXX GLIBCXX_ABI Deprecated
2264 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2266 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2267 long double&) const;
2272 template<typename _CharT
, typename _InIter
>
2273 locale::id num_get
<_CharT
, _InIter
>::id
;
2277 * @brief Facet for converting numbers to strings.
2279 * This facet encapsulates the code to convert a number to a string. It is
2280 * used by the ostream numeric insertion operators.
2282 * The num_put template uses protected virtual functions to provide the
2283 * actual results. The public accessors forward the call to the virtual
2284 * functions. These virtual functions are hooks for developers to
2285 * implement the behavior they require from the num_put facet.
2287 template<typename _CharT
, typename _OutIter
>
2288 class num_put
: public locale::facet
2294 typedef _CharT char_type
;
2295 typedef _OutIter iter_type
;
2298 /// Numpunct facet id.
2299 static locale::id id
;
2302 * @brief Constructor performs initialization.
2304 * This is the constructor provided by the standard.
2306 * @param refs Passed to the base facet class.
2309 num_put(size_t __refs
= 0) : facet(__refs
) { }
2312 * @brief Numeric formatting.
2314 * Formats the boolean @a v and inserts it into a stream. It does so
2315 * by calling num_put::do_put().
2317 * If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
2318 * ctype<CharT>::falsename(). Otherwise formats @a v as an int.
2320 * @param s Stream to write to.
2321 * @param io Source of locale and flags.
2322 * @param fill Char_type to use for filling.
2323 * @param v Value to format and insert.
2324 * @return Iterator after writing.
2327 put(iter_type __s
, ios_base
& __f
, char_type __fill
, bool __v
) const
2328 { return this->do_put(__s
, __f
, __fill
, __v
); }
2332 * @brief Numeric formatting.
2334 * Formats the integral value @a v and inserts it into a
2335 * stream. It does so by calling num_put::do_put().
2337 * Formatting is affected by the flag settings in @a io.
2339 * The basic format is affected by the value of io.flags() &
2340 * ios_base::basefield. If equal to ios_base::oct, formats like the
2341 * printf %o specifier. Else if equal to ios_base::hex, formats like
2342 * %x or %X with ios_base::uppercase unset or set respectively.
2343 * Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
2344 * for unsigned values. Note that if both oct and hex are set, neither
2347 * If ios_base::showpos is set, '+' is output before positive values.
2348 * If ios_base::showbase is set, '0' precedes octal values (except 0)
2349 * and '0[xX]' precedes hex values.
2351 * Thousands separators are inserted according to numpunct::grouping()
2352 * and numpunct::thousands_sep(). The decimal point character used is
2353 * numpunct::decimal_point().
2355 * If io.width() is non-zero, enough @a fill characters are inserted to
2356 * make the result at least that wide. If
2357 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2358 * padded at the end. If ios_base::internal, then padding occurs
2359 * immediately after either a '+' or '-' or after '0x' or '0X'.
2360 * Otherwise, padding occurs at the beginning.
2362 * @param s Stream to write to.
2363 * @param io Source of locale and flags.
2364 * @param fill Char_type to use for filling.
2365 * @param v Value to format and insert.
2366 * @return Iterator after writing.
2369 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long __v
) const
2370 { return this->do_put(__s
, __f
, __fill
, __v
); }
2373 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2374 unsigned long __v
) const
2375 { return this->do_put(__s
, __f
, __fill
, __v
); }
2377 #ifdef _GLIBCXX_USE_LONG_LONG
2379 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long long __v
) const
2380 { return this->do_put(__s
, __f
, __fill
, __v
); }
2383 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2384 unsigned long long __v
) const
2385 { return this->do_put(__s
, __f
, __fill
, __v
); }
2391 * @brief Numeric formatting.
2393 * Formats the floating point value @a v and inserts it into a stream.
2394 * It does so by calling num_put::do_put().
2396 * Formatting is affected by the flag settings in @a io.
2398 * The basic format is affected by the value of io.flags() &
2399 * ios_base::floatfield. If equal to ios_base::fixed, formats like the
2400 * printf %f specifier. Else if equal to ios_base::scientific, formats
2401 * like %e or %E with ios_base::uppercase unset or set respectively.
2402 * Otherwise, formats like %g or %G depending on uppercase. Note that
2403 * if both fixed and scientific are set, the effect will also be like
2406 * The output precision is given by io.precision(). This precision is
2407 * capped at numeric_limits::digits10 + 2 (different for double and
2408 * long double). The default precision is 6.
2410 * If ios_base::showpos is set, '+' is output before positive values.
2411 * If ios_base::showpoint is set, a decimal point will always be
2414 * Thousands separators are inserted according to numpunct::grouping()
2415 * and numpunct::thousands_sep(). The decimal point character used is
2416 * numpunct::decimal_point().
2418 * If io.width() is non-zero, enough @a fill characters are inserted to
2419 * make the result at least that wide. If
2420 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2421 * padded at the end. If ios_base::internal, then padding occurs
2422 * immediately after either a '+' or '-' or after '0x' or '0X'.
2423 * Otherwise, padding occurs at the beginning.
2425 * @param s Stream to write to.
2426 * @param io Source of locale and flags.
2427 * @param fill Char_type to use for filling.
2428 * @param v Value to format and insert.
2429 * @return Iterator after writing.
2432 put(iter_type __s
, ios_base
& __f
, char_type __fill
, double __v
) const
2433 { return this->do_put(__s
, __f
, __fill
, __v
); }
2436 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2437 long double __v
) const
2438 { return this->do_put(__s
, __f
, __fill
, __v
); }
2442 * @brief Numeric formatting.
2444 * Formats the pointer value @a v and inserts it into a stream. It
2445 * does so by calling num_put::do_put().
2447 * This function formats @a v as an unsigned long with ios_base::hex
2448 * and ios_base::showbase set.
2450 * @param s Stream to write to.
2451 * @param io Source of locale and flags.
2452 * @param fill Char_type to use for filling.
2453 * @param v Value to format and insert.
2454 * @return Iterator after writing.
2457 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2458 const void* __v
) const
2459 { return this->do_put(__s
, __f
, __fill
, __v
); }
2462 template<typename _ValueT
>
2464 _M_insert_float(iter_type
, ios_base
& __io
, char_type __fill
,
2465 char __mod
, _ValueT __v
) const;
2468 _M_group_float(const char* __grouping
, size_t __grouping_size
,
2469 char_type __sep
, const char_type
* __p
, char_type
* __new
,
2470 char_type
* __cs
, int& __len
) const;
2472 template<typename _ValueT
>
2474 _M_insert_int(iter_type
, ios_base
& __io
, char_type __fill
,
2478 _M_group_int(const char* __grouping
, size_t __grouping_size
,
2479 char_type __sep
, ios_base
& __io
, char_type
* __new
,
2480 char_type
* __cs
, int& __len
) const;
2483 _M_pad(char_type __fill
, streamsize __w
, ios_base
& __io
,
2484 char_type
* __new
, const char_type
* __cs
, int& __len
) const;
2492 * @brief Numeric formatting.
2494 * These functions do the work of formatting numeric values and
2495 * inserting them into a stream. This function is a hook for derived
2496 * classes to change the value returned.
2498 * @param s Stream to write to.
2499 * @param io Source of locale and flags.
2500 * @param fill Char_type to use for filling.
2501 * @param v Value to format and insert.
2502 * @return Iterator after writing.
2505 do_put(iter_type
, ios_base
&, char_type __fill
, bool __v
) const;
2508 do_put(iter_type
, ios_base
&, char_type __fill
, long __v
) const;
2511 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long) const;
2513 #ifdef _GLIBCXX_USE_LONG_LONG
2515 do_put(iter_type
, ios_base
&, char_type __fill
, long long __v
) const;
2518 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long long) const;
2522 do_put(iter_type
, ios_base
&, char_type __fill
, double __v
) const;
2524 // XXX GLIBCXX_ABI Deprecated
2525 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2527 __do_put(iter_type
, ios_base
&, char_type __fill
, double __v
) const;
2530 do_put(iter_type
, ios_base
&, char_type __fill
, long double __v
) const;
2534 do_put(iter_type
, ios_base
&, char_type __fill
, const void* __v
) const;
2536 // XXX GLIBCXX_ABI Deprecated
2537 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2539 do_put(iter_type
, ios_base
&, char_type __fill
, long double __v
) const;
2544 template <typename _CharT
, typename _OutIter
>
2545 locale::id num_put
<_CharT
, _OutIter
>::id
;
2547 _GLIBCXX_END_LDBL_NAMESPACE
2549 // Subclause convenience interfaces, inlines.
2550 // NB: These are inline because, when used in a loop, some compilers
2551 // can hoist the body out of the loop; then it's just as fast as the
2552 // C is*() function.
2554 /// Convenience interface to ctype.is(ctype_base::space, __c).
2555 template<typename _CharT
>
2557 isspace(_CharT __c
, const locale
& __loc
)
2558 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::space
, __c
); }
2560 /// Convenience interface to ctype.is(ctype_base::print, __c).
2561 template<typename _CharT
>
2563 isprint(_CharT __c
, const locale
& __loc
)
2564 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::print
, __c
); }
2566 /// Convenience interface to ctype.is(ctype_base::cntrl, __c).
2567 template<typename _CharT
>
2569 iscntrl(_CharT __c
, const locale
& __loc
)
2570 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::cntrl
, __c
); }
2572 /// Convenience interface to ctype.is(ctype_base::upper, __c).
2573 template<typename _CharT
>
2575 isupper(_CharT __c
, const locale
& __loc
)
2576 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::upper
, __c
); }
2578 /// Convenience interface to ctype.is(ctype_base::lower, __c).
2579 template<typename _CharT
>
2581 islower(_CharT __c
, const locale
& __loc
)
2582 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::lower
, __c
); }
2584 /// Convenience interface to ctype.is(ctype_base::alpha, __c).
2585 template<typename _CharT
>
2587 isalpha(_CharT __c
, const locale
& __loc
)
2588 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alpha
, __c
); }
2590 /// Convenience interface to ctype.is(ctype_base::digit, __c).
2591 template<typename _CharT
>
2593 isdigit(_CharT __c
, const locale
& __loc
)
2594 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::digit
, __c
); }
2596 /// Convenience interface to ctype.is(ctype_base::punct, __c).
2597 template<typename _CharT
>
2599 ispunct(_CharT __c
, const locale
& __loc
)
2600 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::punct
, __c
); }
2602 /// Convenience interface to ctype.is(ctype_base::xdigit, __c).
2603 template<typename _CharT
>
2605 isxdigit(_CharT __c
, const locale
& __loc
)
2606 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::xdigit
, __c
); }
2608 /// Convenience interface to ctype.is(ctype_base::alnum, __c).
2609 template<typename _CharT
>
2611 isalnum(_CharT __c
, const locale
& __loc
)
2612 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alnum
, __c
); }
2614 /// Convenience interface to ctype.is(ctype_base::graph, __c).
2615 template<typename _CharT
>
2617 isgraph(_CharT __c
, const locale
& __loc
)
2618 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::graph
, __c
); }
2620 /// Convenience interface to ctype.toupper(__c).
2621 template<typename _CharT
>
2623 toupper(_CharT __c
, const locale
& __loc
)
2624 { return use_facet
<ctype
<_CharT
> >(__loc
).toupper(__c
); }
2626 /// Convenience interface to ctype.tolower(__c).
2627 template<typename _CharT
>
2629 tolower(_CharT __c
, const locale
& __loc
)
2630 { return use_facet
<ctype
<_CharT
> >(__loc
).tolower(__c
); }
2632 _GLIBCXX_END_NAMESPACE
2634 #ifndef _GLIBCXX_EXPORT_TEMPLATE
2635 # include <bits/locale_facets.tcc>