1 // Locale support -*- C++ -*-
3 // Copyright (C) 1997-2014 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file bits/locale_facets.h
26 * This is an internal header file, included by other library headers.
27 * Do not attempt to use it directly. @headername{locale}
31 // ISO C++ 14882: 22.1 Locales
34 #ifndef _LOCALE_FACETS_H
35 #define _LOCALE_FACETS_H 1
37 #pragma GCC system_header
39 #include <cwctype> // For wctype_t
41 #include <bits/ctype_base.h>
43 #include <bits/ios_base.h> // For ios_base, ios_base::iostate
45 #include <bits/cpp_type_traits.h>
46 #include <ext/type_traits.h>
47 #include <ext/numeric_traits.h>
48 #include <bits/streambuf_iterator.h>
50 namespace std
_GLIBCXX_VISIBILITY(default)
52 _GLIBCXX_BEGIN_NAMESPACE_VERSION
54 // NB: Don't instantiate required wchar_t facets if no wchar_t support.
55 #ifdef _GLIBCXX_USE_WCHAR_T
56 # define _GLIBCXX_NUM_FACETS 28
58 # define _GLIBCXX_NUM_FACETS 14
61 // Convert string to numeric value of type _Tp and store results.
62 // NB: This is specialized for all required types, there is no
63 // generic definition.
64 template<typename _Tp
>
66 __convert_to_v(const char*, _Tp
&, ios_base::iostate
&,
67 const __c_locale
&) throw();
69 // Explicit specializations for required types.
72 __convert_to_v(const char*, float&, ios_base::iostate
&,
73 const __c_locale
&) throw();
77 __convert_to_v(const char*, double&, ios_base::iostate
&,
78 const __c_locale
&) throw();
82 __convert_to_v(const char*, long double&, ios_base::iostate
&,
83 const __c_locale
&) throw();
85 // NB: __pad is a struct, rather than a function, so it can be
86 // partially-specialized.
87 template<typename _CharT
, typename _Traits
>
91 _S_pad(ios_base
& __io
, _CharT __fill
, _CharT
* __news
,
92 const _CharT
* __olds
, streamsize __newlen
, streamsize __oldlen
);
95 // Used by both numeric and monetary facets.
96 // Inserts "group separator" characters into an array of characters.
97 // It's recursive, one iteration per group. It moves the characters
98 // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
99 // only with __gsize != 0.
100 template<typename _CharT
>
102 __add_grouping(_CharT
* __s
, _CharT __sep
,
103 const char* __gbeg
, size_t __gsize
,
104 const _CharT
* __first
, const _CharT
* __last
);
106 // This template permits specializing facet output code for
107 // ostreambuf_iterator. For ostreambuf_iterator, sputn is
108 // significantly more efficient than incrementing iterators.
109 template<typename _CharT
>
111 ostreambuf_iterator
<_CharT
>
112 __write(ostreambuf_iterator
<_CharT
> __s
, const _CharT
* __ws
, int __len
)
114 __s
._M_put(__ws
, __len
);
118 // This is the unspecialized form of the template.
119 template<typename _CharT
, typename _OutIter
>
122 __write(_OutIter __s
, const _CharT
* __ws
, int __len
)
124 for (int __j
= 0; __j
< __len
; __j
++, ++__s
)
130 // 22.2.1.1 Template class ctype
131 // Include host and configuration specific ctype enums for ctype_base.
134 * @brief Common base for ctype facet
136 * This template class provides implementations of the public functions
137 * that forward to the protected virtual functions.
139 * This template also provides abstract stubs for the protected virtual
142 template<typename _CharT
>
143 class __ctype_abstract_base
: public locale::facet
, public ctype_base
147 /// Typedef for the template parameter
148 typedef _CharT char_type
;
151 * @brief Test char_type classification.
153 * This function finds a mask M for @a __c and compares it to
154 * mask @a __m. It does so by returning the value of
155 * ctype<char_type>::do_is().
157 * @param __c The char_type to compare the mask of.
158 * @param __m The mask to compare against.
159 * @return (M & __m) != 0.
162 is(mask __m
, char_type __c
) const
163 { return this->do_is(__m
, __c
); }
166 * @brief Return a mask array.
168 * This function finds the mask for each char_type in the range [lo,hi)
169 * and successively writes it to vec. vec must have as many elements
170 * as the char array. It does so by returning the value of
171 * ctype<char_type>::do_is().
173 * @param __lo Pointer to start of range.
174 * @param __hi Pointer to end of range.
175 * @param __vec Pointer to an array of mask storage.
179 is(const char_type
*__lo
, const char_type
*__hi
, mask
*__vec
) const
180 { return this->do_is(__lo
, __hi
, __vec
); }
183 * @brief Find char_type matching a mask
185 * This function searches for and returns the first char_type c in
186 * [lo,hi) for which is(m,c) is true. It does so by returning
187 * ctype<char_type>::do_scan_is().
189 * @param __m The mask to compare against.
190 * @param __lo Pointer to start of range.
191 * @param __hi Pointer to end of range.
192 * @return Pointer to matching char_type if found, else @a __hi.
195 scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
196 { return this->do_scan_is(__m
, __lo
, __hi
); }
199 * @brief Find char_type not matching a mask
201 * This function searches for and returns the first char_type c in
202 * [lo,hi) for which is(m,c) is false. It does so by returning
203 * ctype<char_type>::do_scan_not().
205 * @param __m The mask to compare against.
206 * @param __lo Pointer to first char in range.
207 * @param __hi Pointer to end of range.
208 * @return Pointer to non-matching char if found, else @a __hi.
211 scan_not(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
212 { return this->do_scan_not(__m
, __lo
, __hi
); }
215 * @brief Convert to uppercase.
217 * This function converts the argument to uppercase if possible.
218 * If not possible (for example, '2'), returns the argument. It does
219 * so by returning ctype<char_type>::do_toupper().
221 * @param __c The char_type to convert.
222 * @return The uppercase char_type if convertible, else @a __c.
225 toupper(char_type __c
) const
226 { return this->do_toupper(__c
); }
229 * @brief Convert array to uppercase.
231 * This function converts each char_type in the range [lo,hi) to
232 * uppercase if possible. Other elements remain untouched. It does so
233 * by returning ctype<char_type>:: do_toupper(lo, hi).
235 * @param __lo Pointer to start of range.
236 * @param __hi Pointer to end of range.
240 toupper(char_type
*__lo
, const char_type
* __hi
) const
241 { return this->do_toupper(__lo
, __hi
); }
244 * @brief Convert to lowercase.
246 * This function converts the argument to lowercase if possible. If
247 * not possible (for example, '2'), returns the argument. It does so
248 * by returning ctype<char_type>::do_tolower(c).
250 * @param __c The char_type to convert.
251 * @return The lowercase char_type if convertible, else @a __c.
254 tolower(char_type __c
) const
255 { return this->do_tolower(__c
); }
258 * @brief Convert array to lowercase.
260 * This function converts each char_type in the range [__lo,__hi) to
261 * lowercase if possible. Other elements remain untouched. It does so
262 * by returning ctype<char_type>:: do_tolower(__lo, __hi).
264 * @param __lo Pointer to start of range.
265 * @param __hi Pointer to end of range.
269 tolower(char_type
* __lo
, const char_type
* __hi
) const
270 { return this->do_tolower(__lo
, __hi
); }
273 * @brief Widen char to char_type
275 * This function converts the char argument to char_type using the
276 * simplest reasonable transformation. It does so by returning
277 * ctype<char_type>::do_widen(c).
279 * Note: this is not what you want for codepage conversions. See
282 * @param __c The char to convert.
283 * @return The converted char_type.
286 widen(char __c
) const
287 { return this->do_widen(__c
); }
290 * @brief Widen array to char_type
292 * This function converts each char in the input to char_type using the
293 * simplest reasonable transformation. It does so by returning
294 * ctype<char_type>::do_widen(c).
296 * Note: this is not what you want for codepage conversions. See
299 * @param __lo Pointer to start of range.
300 * @param __hi Pointer to end of range.
301 * @param __to Pointer to the destination array.
305 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
306 { return this->do_widen(__lo
, __hi
, __to
); }
309 * @brief Narrow char_type to char
311 * This function converts the char_type to char using the simplest
312 * reasonable transformation. If the conversion fails, dfault is
313 * returned instead. It does so by returning
314 * ctype<char_type>::do_narrow(__c).
316 * Note: this is not what you want for codepage conversions. See
319 * @param __c The char_type to convert.
320 * @param __dfault Char to return if conversion fails.
321 * @return The converted char.
324 narrow(char_type __c
, char __dfault
) const
325 { return this->do_narrow(__c
, __dfault
); }
328 * @brief Narrow array to char array
330 * This function converts each char_type in the input to char using the
331 * simplest reasonable transformation and writes the results to the
332 * destination array. For any char_type in the input that cannot be
333 * converted, @a dfault is used instead. It does so by returning
334 * ctype<char_type>::do_narrow(__lo, __hi, __dfault, __to).
336 * Note: this is not what you want for codepage conversions. See
339 * @param __lo Pointer to start of range.
340 * @param __hi Pointer to end of range.
341 * @param __dfault Char to use if conversion fails.
342 * @param __to Pointer to the destination array.
346 narrow(const char_type
* __lo
, const char_type
* __hi
,
347 char __dfault
, char* __to
) const
348 { return this->do_narrow(__lo
, __hi
, __dfault
, __to
); }
352 __ctype_abstract_base(size_t __refs
= 0): facet(__refs
) { }
355 ~__ctype_abstract_base() { }
358 * @brief Test char_type classification.
360 * This function finds a mask M for @a c and compares it to mask @a m.
362 * do_is() is a hook for a derived facet to change the behavior of
363 * classifying. do_is() must always return the same result for the
366 * @param __c The char_type to find the mask of.
367 * @param __m The mask to compare against.
368 * @return (M & __m) != 0.
371 do_is(mask __m
, char_type __c
) const = 0;
374 * @brief Return a mask array.
376 * This function finds the mask for each char_type in the range [lo,hi)
377 * and successively writes it to vec. vec must have as many elements
380 * do_is() is a hook for a derived facet to change the behavior of
381 * classifying. do_is() must always return the same result for the
384 * @param __lo Pointer to start of range.
385 * @param __hi Pointer to end of range.
386 * @param __vec Pointer to an array of mask storage.
389 virtual const char_type
*
390 do_is(const char_type
* __lo
, const char_type
* __hi
,
391 mask
* __vec
) const = 0;
394 * @brief Find char_type matching mask
396 * This function searches for and returns the first char_type c in
397 * [__lo,__hi) for which is(__m,c) is true.
399 * do_scan_is() is a hook for a derived facet to change the behavior of
400 * match searching. do_is() must always return the same result for the
403 * @param __m The mask to compare against.
404 * @param __lo Pointer to start of range.
405 * @param __hi Pointer to end of range.
406 * @return Pointer to a matching char_type if found, else @a __hi.
408 virtual const char_type
*
409 do_scan_is(mask __m
, const char_type
* __lo
,
410 const char_type
* __hi
) const = 0;
413 * @brief Find char_type not matching mask
415 * This function searches for and returns a pointer to the first
416 * char_type c of [lo,hi) for which is(m,c) is false.
418 * do_scan_is() is a hook for a derived facet to change the behavior of
419 * match searching. do_is() must always return the same result for the
422 * @param __m The mask to compare against.
423 * @param __lo Pointer to start of range.
424 * @param __hi Pointer to end of range.
425 * @return Pointer to a non-matching char_type if found, else @a __hi.
427 virtual const char_type
*
428 do_scan_not(mask __m
, const char_type
* __lo
,
429 const char_type
* __hi
) const = 0;
432 * @brief Convert to uppercase.
434 * This virtual function converts the char_type argument to uppercase
435 * if possible. If not possible (for example, '2'), returns the
438 * do_toupper() is a hook for a derived facet to change the behavior of
439 * uppercasing. do_toupper() must always return the same result for
442 * @param __c The char_type to convert.
443 * @return The uppercase char_type if convertible, else @a __c.
446 do_toupper(char_type __c
) const = 0;
449 * @brief Convert array to uppercase.
451 * This virtual function converts each char_type in the range [__lo,__hi)
452 * to uppercase if possible. Other elements remain untouched.
454 * do_toupper() is a hook for a derived facet to change the behavior of
455 * uppercasing. do_toupper() must always return the same result for
458 * @param __lo Pointer to start of range.
459 * @param __hi Pointer to end of range.
462 virtual const char_type
*
463 do_toupper(char_type
* __lo
, const char_type
* __hi
) const = 0;
466 * @brief Convert to lowercase.
468 * This virtual function converts the argument to lowercase if
469 * possible. If not possible (for example, '2'), returns the argument.
471 * do_tolower() is a hook for a derived facet to change the behavior of
472 * lowercasing. do_tolower() must always return the same result for
475 * @param __c The char_type to convert.
476 * @return The lowercase char_type if convertible, else @a __c.
479 do_tolower(char_type __c
) const = 0;
482 * @brief Convert array to lowercase.
484 * This virtual function converts each char_type in the range [__lo,__hi)
485 * to lowercase if possible. Other elements remain untouched.
487 * do_tolower() is a hook for a derived facet to change the behavior of
488 * lowercasing. do_tolower() must always return the same result for
491 * @param __lo Pointer to start of range.
492 * @param __hi Pointer to end of range.
495 virtual const char_type
*
496 do_tolower(char_type
* __lo
, const char_type
* __hi
) const = 0;
501 * This virtual function converts the char to char_type using the
502 * simplest reasonable transformation.
504 * do_widen() is a hook for a derived facet to change the behavior of
505 * widening. do_widen() must always return the same result for the
508 * Note: this is not what you want for codepage conversions. See
511 * @param __c The char to convert.
512 * @return The converted char_type
515 do_widen(char __c
) const = 0;
518 * @brief Widen char array
520 * This function converts each char in the input to char_type using the
521 * simplest reasonable transformation.
523 * do_widen() is a hook for a derived facet to change the behavior of
524 * widening. do_widen() must always return the same result for the
527 * Note: this is not what you want for codepage conversions. See
530 * @param __lo Pointer to start range.
531 * @param __hi Pointer to end of range.
532 * @param __to Pointer to the destination array.
536 do_widen(const char* __lo
, const char* __hi
, char_type
* __to
) const = 0;
539 * @brief Narrow char_type to char
541 * This virtual function converts the argument to char using the
542 * simplest reasonable transformation. If the conversion fails, dfault
543 * is returned instead.
545 * do_narrow() is a hook for a derived facet to change the behavior of
546 * narrowing. do_narrow() must always return the same result for the
549 * Note: this is not what you want for codepage conversions. See
552 * @param __c The char_type to convert.
553 * @param __dfault Char to return if conversion fails.
554 * @return The converted char.
557 do_narrow(char_type __c
, char __dfault
) const = 0;
560 * @brief Narrow char_type array to char
562 * This virtual function converts each char_type in the range
563 * [__lo,__hi) to char using the simplest reasonable
564 * transformation and writes the results to the destination
565 * array. For any element in the input that cannot be
566 * converted, @a __dfault is used instead.
568 * do_narrow() is a hook for a derived facet to change the behavior of
569 * narrowing. do_narrow() must always return the same result for the
572 * Note: this is not what you want for codepage conversions. See
575 * @param __lo Pointer to start of range.
576 * @param __hi Pointer to end of range.
577 * @param __dfault Char to use if conversion fails.
578 * @param __to Pointer to the destination array.
581 virtual const char_type
*
582 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
583 char __dfault
, char* __to
) const = 0;
587 * @brief Primary class template ctype facet.
590 * This template class defines classification and conversion functions for
591 * character sets. It wraps cctype functionality. Ctype gets used by
592 * streams for many I/O operations.
594 * This template provides the protected virtual functions the developer
595 * will have to replace in a derived class or specialization to make a
596 * working facet. The public functions that access them are defined in
597 * __ctype_abstract_base, to allow for implementation flexibility. See
598 * ctype<wchar_t> for an example. The functions are documented in
599 * __ctype_abstract_base.
601 * Note: implementations are provided for all the protected virtual
602 * functions, but will likely not be useful.
604 template<typename _CharT
>
605 class ctype
: public __ctype_abstract_base
<_CharT
>
609 typedef _CharT char_type
;
610 typedef typename __ctype_abstract_base
<_CharT
>::mask mask
;
612 /// The facet id for ctype<char_type>
613 static locale::id id
;
616 ctype(size_t __refs
= 0) : __ctype_abstract_base
<_CharT
>(__refs
) { }
623 do_is(mask __m
, char_type __c
) const;
625 virtual const char_type
*
626 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
628 virtual const char_type
*
629 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
631 virtual const char_type
*
632 do_scan_not(mask __m
, const char_type
* __lo
,
633 const char_type
* __hi
) const;
636 do_toupper(char_type __c
) const;
638 virtual const char_type
*
639 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
642 do_tolower(char_type __c
) const;
644 virtual const char_type
*
645 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
648 do_widen(char __c
) const;
651 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
654 do_narrow(char_type
, char __dfault
) const;
656 virtual const char_type
*
657 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
658 char __dfault
, char* __to
) const;
661 template<typename _CharT
>
662 locale::id ctype
<_CharT
>::id
;
665 * @brief The ctype<char> specialization.
668 * This class defines classification and conversion functions for
669 * the char type. It gets used by char streams for many I/O
670 * operations. The char specialization provides a number of
671 * optimizations as well.
674 class ctype
<char> : public locale::facet
, public ctype_base
678 /// Typedef for the template parameter char.
679 typedef char char_type
;
683 __c_locale _M_c_locale_ctype
;
685 __to_type _M_toupper
;
686 __to_type _M_tolower
;
687 const mask
* _M_table
;
688 mutable char _M_widen_ok
;
689 mutable char _M_widen
[1 + static_cast<unsigned char>(-1)];
690 mutable char _M_narrow
[1 + static_cast<unsigned char>(-1)];
691 mutable char _M_narrow_ok
; // 0 uninitialized, 1 init,
692 // 2 memcpy can't be used
695 /// The facet id for ctype<char>
696 static locale::id id
;
697 /// The size of the mask table. It is SCHAR_MAX + 1.
698 static const size_t table_size
= 1 + static_cast<unsigned char>(-1);
701 * @brief Constructor performs initialization.
703 * This is the constructor provided by the standard.
705 * @param __table If non-zero, table is used as the per-char mask.
706 * Else classic_table() is used.
707 * @param __del If true, passes ownership of table to this facet.
708 * @param __refs Passed to the base facet class.
711 ctype(const mask
* __table
= 0, bool __del
= false, size_t __refs
= 0);
714 * @brief Constructor performs static initialization.
716 * This constructor is used to construct the initial C locale facet.
718 * @param __cloc Handle to C locale data.
719 * @param __table If non-zero, table is used as the per-char mask.
720 * @param __del If true, passes ownership of table to this facet.
721 * @param __refs Passed to the base facet class.
724 ctype(__c_locale __cloc
, const mask
* __table
= 0, bool __del
= false,
728 * @brief Test char classification.
730 * This function compares the mask table[c] to @a __m.
732 * @param __c The char to compare the mask of.
733 * @param __m The mask to compare against.
734 * @return True if __m & table[__c] is true, false otherwise.
737 is(mask __m
, char __c
) const;
740 * @brief Return a mask array.
742 * This function finds the mask for each char in the range [lo, hi) and
743 * successively writes it to vec. vec must have as many elements as
746 * @param __lo Pointer to start of range.
747 * @param __hi Pointer to end of range.
748 * @param __vec Pointer to an array of mask storage.
752 is(const char* __lo
, const char* __hi
, mask
* __vec
) const;
755 * @brief Find char matching a mask
757 * This function searches for and returns the first char in [lo,hi) for
758 * which is(m,char) is true.
760 * @param __m The mask to compare against.
761 * @param __lo Pointer to start of range.
762 * @param __hi Pointer to end of range.
763 * @return Pointer to a matching char if found, else @a __hi.
766 scan_is(mask __m
, const char* __lo
, const char* __hi
) const;
769 * @brief Find char not matching a mask
771 * This function searches for and returns a pointer to the first char
772 * in [__lo,__hi) for which is(m,char) is false.
774 * @param __m The mask to compare against.
775 * @param __lo Pointer to start of range.
776 * @param __hi Pointer to end of range.
777 * @return Pointer to a non-matching char if found, else @a __hi.
780 scan_not(mask __m
, const char* __lo
, const char* __hi
) const;
783 * @brief Convert to uppercase.
785 * This function converts the char argument to uppercase if possible.
786 * If not possible (for example, '2'), returns the argument.
788 * toupper() acts as if it returns ctype<char>::do_toupper(c).
789 * do_toupper() must always return the same result for the same input.
791 * @param __c The char to convert.
792 * @return The uppercase char if convertible, else @a __c.
795 toupper(char_type __c
) const
796 { return this->do_toupper(__c
); }
799 * @brief Convert array to uppercase.
801 * This function converts each char in the range [__lo,__hi) to uppercase
802 * if possible. Other chars remain untouched.
804 * toupper() acts as if it returns ctype<char>:: do_toupper(__lo, __hi).
805 * do_toupper() must always return the same result for the same input.
807 * @param __lo Pointer to first char in range.
808 * @param __hi Pointer to end of range.
812 toupper(char_type
*__lo
, const char_type
* __hi
) const
813 { return this->do_toupper(__lo
, __hi
); }
816 * @brief Convert to lowercase.
818 * This function converts the char argument to lowercase if possible.
819 * If not possible (for example, '2'), returns the argument.
821 * tolower() acts as if it returns ctype<char>::do_tolower(__c).
822 * do_tolower() must always return the same result for the same input.
824 * @param __c The char to convert.
825 * @return The lowercase char if convertible, else @a __c.
828 tolower(char_type __c
) const
829 { return this->do_tolower(__c
); }
832 * @brief Convert array to lowercase.
834 * This function converts each char in the range [lo,hi) to lowercase
835 * if possible. Other chars remain untouched.
837 * tolower() acts as if it returns ctype<char>:: do_tolower(__lo, __hi).
838 * do_tolower() must always return the same result for the same input.
840 * @param __lo Pointer to first char in range.
841 * @param __hi Pointer to end of range.
845 tolower(char_type
* __lo
, const char_type
* __hi
) const
846 { return this->do_tolower(__lo
, __hi
); }
851 * This function converts the char to char_type using the simplest
852 * reasonable transformation. For an underived ctype<char> facet, the
853 * argument will be returned unchanged.
855 * This function works as if it returns ctype<char>::do_widen(c).
856 * do_widen() must always return the same result for the same input.
858 * Note: this is not what you want for codepage conversions. See
861 * @param __c The char to convert.
862 * @return The converted character.
865 widen(char __c
) const
868 return _M_widen
[static_cast<unsigned char>(__c
)];
869 this->_M_widen_init();
870 return this->do_widen(__c
);
874 * @brief Widen char array
876 * This function converts each char in the input to char using the
877 * simplest reasonable transformation. For an underived ctype<char>
878 * facet, the argument will be copied unchanged.
880 * This function works as if it returns ctype<char>::do_widen(c).
881 * do_widen() must always return the same result for the same input.
883 * Note: this is not what you want for codepage conversions. See
886 * @param __lo Pointer to first char in range.
887 * @param __hi Pointer to end of range.
888 * @param __to Pointer to the destination array.
892 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
894 if (_M_widen_ok
== 1)
896 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
901 return this->do_widen(__lo
, __hi
, __to
);
907 * This function converts the char to char using the simplest
908 * reasonable transformation. If the conversion fails, dfault is
909 * returned instead. For an underived ctype<char> facet, @a c
910 * will be returned unchanged.
912 * This function works as if it returns ctype<char>::do_narrow(c).
913 * do_narrow() must always return the same result for the same input.
915 * Note: this is not what you want for codepage conversions. See
918 * @param __c The char to convert.
919 * @param __dfault Char to return if conversion fails.
920 * @return The converted character.
923 narrow(char_type __c
, char __dfault
) const
925 if (_M_narrow
[static_cast<unsigned char>(__c
)])
926 return _M_narrow
[static_cast<unsigned char>(__c
)];
927 const char __t
= do_narrow(__c
, __dfault
);
929 _M_narrow
[static_cast<unsigned char>(__c
)] = __t
;
934 * @brief Narrow char array
936 * This function converts each char in the input to char using the
937 * simplest reasonable transformation and writes the results to the
938 * destination array. For any char in the input that cannot be
939 * converted, @a dfault is used instead. For an underived ctype<char>
940 * facet, the argument will be copied unchanged.
942 * This function works as if it returns ctype<char>::do_narrow(lo, hi,
943 * dfault, to). do_narrow() must always return the same result for the
946 * Note: this is not what you want for codepage conversions. See
949 * @param __lo Pointer to start of range.
950 * @param __hi Pointer to end of range.
951 * @param __dfault Char to use if conversion fails.
952 * @param __to Pointer to the destination array.
956 narrow(const char_type
* __lo
, const char_type
* __hi
,
957 char __dfault
, char* __to
) const
959 if (__builtin_expect(_M_narrow_ok
== 1, true))
961 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
966 return this->do_narrow(__lo
, __hi
, __dfault
, __to
);
969 // _GLIBCXX_RESOLVE_LIB_DEFECTS
970 // DR 695. ctype<char>::classic_table() not accessible.
971 /// Returns a pointer to the mask table provided to the constructor, or
972 /// the default from classic_table() if none was provided.
974 table() const throw()
977 /// Returns a pointer to the C locale mask table.
979 classic_table() throw();
985 * This function deletes table() if @a del was true in the
992 * @brief Convert to uppercase.
994 * This virtual function converts the char argument to uppercase if
995 * possible. If not possible (for example, '2'), returns the argument.
997 * do_toupper() is a hook for a derived facet to change the behavior of
998 * uppercasing. do_toupper() must always return the same result for
1001 * @param __c The char to convert.
1002 * @return The uppercase char if convertible, else @a __c.
1005 do_toupper(char_type __c
) const;
1008 * @brief Convert array to uppercase.
1010 * This virtual function converts each char in the range [lo,hi) to
1011 * uppercase if possible. Other chars remain untouched.
1013 * do_toupper() is a hook for a derived facet to change the behavior of
1014 * uppercasing. do_toupper() must always return the same result for
1017 * @param __lo Pointer to start of range.
1018 * @param __hi Pointer to end of range.
1021 virtual const char_type
*
1022 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
1025 * @brief Convert to lowercase.
1027 * This virtual function converts the char argument to lowercase if
1028 * possible. If not possible (for example, '2'), returns the argument.
1030 * do_tolower() is a hook for a derived facet to change the behavior of
1031 * lowercasing. do_tolower() must always return the same result for
1034 * @param __c The char to convert.
1035 * @return The lowercase char if convertible, else @a __c.
1038 do_tolower(char_type __c
) const;
1041 * @brief Convert array to lowercase.
1043 * This virtual function converts each char in the range [lo,hi) to
1044 * lowercase if possible. Other chars remain untouched.
1046 * do_tolower() is a hook for a derived facet to change the behavior of
1047 * lowercasing. do_tolower() must always return the same result for
1050 * @param __lo Pointer to first char in range.
1051 * @param __hi Pointer to end of range.
1054 virtual const char_type
*
1055 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
1060 * This virtual function converts the char to char using the simplest
1061 * reasonable transformation. For an underived ctype<char> facet, the
1062 * argument will be returned unchanged.
1064 * do_widen() is a hook for a derived facet to change the behavior of
1065 * widening. do_widen() must always return the same result for the
1068 * Note: this is not what you want for codepage conversions. See
1071 * @param __c The char to convert.
1072 * @return The converted character.
1075 do_widen(char __c
) const
1079 * @brief Widen char array
1081 * This function converts each char in the range [lo,hi) to char using
1082 * the simplest reasonable transformation. For an underived
1083 * ctype<char> facet, the argument will be copied unchanged.
1085 * do_widen() is a hook for a derived facet to change the behavior of
1086 * widening. do_widen() must always return the same result for the
1089 * Note: this is not what you want for codepage conversions. See
1092 * @param __lo Pointer to start of range.
1093 * @param __hi Pointer to end of range.
1094 * @param __to Pointer to the destination array.
1098 do_widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
1100 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
1105 * @brief Narrow char
1107 * This virtual function converts the char to char using the simplest
1108 * reasonable transformation. If the conversion fails, dfault is
1109 * returned instead. For an underived ctype<char> facet, @a c will be
1110 * returned unchanged.
1112 * do_narrow() is a hook for a derived facet to change the behavior of
1113 * narrowing. do_narrow() must always return the same result for the
1116 * Note: this is not what you want for codepage conversions. See
1119 * @param __c The char to convert.
1120 * @param __dfault Char to return if conversion fails.
1121 * @return The converted char.
1124 do_narrow(char_type __c
, char __dfault
) const
1128 * @brief Narrow char array to char array
1130 * This virtual function converts each char in the range [lo,hi) to
1131 * char using the simplest reasonable transformation and writes the
1132 * results to the destination array. For any char in the input that
1133 * cannot be converted, @a dfault is used instead. For an underived
1134 * ctype<char> facet, the argument will be copied unchanged.
1136 * do_narrow() is a hook for a derived facet to change the behavior of
1137 * narrowing. do_narrow() must always return the same result for the
1140 * Note: this is not what you want for codepage conversions. See
1143 * @param __lo Pointer to start of range.
1144 * @param __hi Pointer to end of range.
1145 * @param __dfault Char to use if conversion fails.
1146 * @param __to Pointer to the destination array.
1149 virtual const char_type
*
1150 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
1151 char __dfault
, char* __to
) const
1153 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
1158 void _M_narrow_init() const;
1159 void _M_widen_init() const;
1162 #ifdef _GLIBCXX_USE_WCHAR_T
1164 * @brief The ctype<wchar_t> specialization.
1167 * This class defines classification and conversion functions for the
1168 * wchar_t type. It gets used by wchar_t streams for many I/O operations.
1169 * The wchar_t specialization provides a number of optimizations as well.
1171 * ctype<wchar_t> inherits its public methods from
1172 * __ctype_abstract_base<wchar_t>.
1175 class ctype
<wchar_t> : public __ctype_abstract_base
<wchar_t>
1179 /// Typedef for the template parameter wchar_t.
1180 typedef wchar_t char_type
;
1181 typedef wctype_t __wmask_type
;
1184 __c_locale _M_c_locale_ctype
;
1186 // Pre-computed narrowed and widened chars.
1188 char _M_narrow
[128];
1189 wint_t _M_widen
[1 + static_cast<unsigned char>(-1)];
1191 // Pre-computed elements for do_is.
1193 __wmask_type _M_wmask
[16];
1197 /// The facet id for ctype<wchar_t>
1198 static locale::id id
;
1201 * @brief Constructor performs initialization.
1203 * This is the constructor provided by the standard.
1205 * @param __refs Passed to the base facet class.
1208 ctype(size_t __refs
= 0);
1211 * @brief Constructor performs static initialization.
1213 * This constructor is used to construct the initial C locale facet.
1215 * @param __cloc Handle to C locale data.
1216 * @param __refs Passed to the base facet class.
1219 ctype(__c_locale __cloc
, size_t __refs
= 0);
1223 _M_convert_to_wmask(const mask __m
) const throw();
1230 * @brief Test wchar_t classification.
1232 * This function finds a mask M for @a c and compares it to mask @a m.
1234 * do_is() is a hook for a derived facet to change the behavior of
1235 * classifying. do_is() must always return the same result for the
1238 * @param __c The wchar_t to find the mask of.
1239 * @param __m The mask to compare against.
1240 * @return (M & __m) != 0.
1243 do_is(mask __m
, char_type __c
) const;
1246 * @brief Return a mask array.
1248 * This function finds the mask for each wchar_t in the range [lo,hi)
1249 * and successively writes it to vec. vec must have as many elements
1252 * do_is() is a hook for a derived facet to change the behavior of
1253 * classifying. do_is() must always return the same result for the
1256 * @param __lo Pointer to start of range.
1257 * @param __hi Pointer to end of range.
1258 * @param __vec Pointer to an array of mask storage.
1261 virtual const char_type
*
1262 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
1265 * @brief Find wchar_t matching mask
1267 * This function searches for and returns the first wchar_t c in
1268 * [__lo,__hi) for which is(__m,c) is true.
1270 * do_scan_is() is a hook for a derived facet to change the behavior of
1271 * match searching. do_is() must always return the same result for the
1274 * @param __m The mask to compare against.
1275 * @param __lo Pointer to start of range.
1276 * @param __hi Pointer to end of range.
1277 * @return Pointer to a matching wchar_t if found, else @a __hi.
1279 virtual const char_type
*
1280 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
1283 * @brief Find wchar_t not matching mask
1285 * This function searches for and returns a pointer to the first
1286 * wchar_t c of [__lo,__hi) for which is(__m,c) is false.
1288 * do_scan_is() is a hook for a derived facet to change the behavior of
1289 * match searching. do_is() must always return the same result for the
1292 * @param __m The mask to compare against.
1293 * @param __lo Pointer to start of range.
1294 * @param __hi Pointer to end of range.
1295 * @return Pointer to a non-matching wchar_t if found, else @a __hi.
1297 virtual const char_type
*
1298 do_scan_not(mask __m
, const char_type
* __lo
,
1299 const char_type
* __hi
) const;
1302 * @brief Convert to uppercase.
1304 * This virtual function converts the wchar_t argument to uppercase if
1305 * possible. If not possible (for example, '2'), returns the argument.
1307 * do_toupper() is a hook for a derived facet to change the behavior of
1308 * uppercasing. do_toupper() must always return the same result for
1311 * @param __c The wchar_t to convert.
1312 * @return The uppercase wchar_t if convertible, else @a __c.
1315 do_toupper(char_type __c
) const;
1318 * @brief Convert array to uppercase.
1320 * This virtual function converts each wchar_t in the range [lo,hi) to
1321 * uppercase if possible. Other elements remain untouched.
1323 * do_toupper() is a hook for a derived facet to change the behavior of
1324 * uppercasing. do_toupper() must always return the same result for
1327 * @param __lo Pointer to start of range.
1328 * @param __hi Pointer to end of range.
1331 virtual const char_type
*
1332 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
1335 * @brief Convert to lowercase.
1337 * This virtual function converts the argument to lowercase if
1338 * possible. If not possible (for example, '2'), returns the argument.
1340 * do_tolower() is a hook for a derived facet to change the behavior of
1341 * lowercasing. do_tolower() must always return the same result for
1344 * @param __c The wchar_t to convert.
1345 * @return The lowercase wchar_t if convertible, else @a __c.
1348 do_tolower(char_type __c
) const;
1351 * @brief Convert array to lowercase.
1353 * This virtual function converts each wchar_t in the range [lo,hi) to
1354 * lowercase if possible. Other elements remain untouched.
1356 * do_tolower() is a hook for a derived facet to change the behavior of
1357 * lowercasing. do_tolower() must always return the same result for
1360 * @param __lo Pointer to start of range.
1361 * @param __hi Pointer to end of range.
1364 virtual const char_type
*
1365 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
1368 * @brief Widen char to wchar_t
1370 * This virtual function converts the char to wchar_t using the
1371 * simplest reasonable transformation. For an underived ctype<wchar_t>
1372 * facet, the argument will be cast to wchar_t.
1374 * do_widen() is a hook for a derived facet to change the behavior of
1375 * widening. do_widen() must always return the same result for the
1378 * Note: this is not what you want for codepage conversions. See
1381 * @param __c The char to convert.
1382 * @return The converted wchar_t.
1385 do_widen(char __c
) const;
1388 * @brief Widen char array to wchar_t array
1390 * This function converts each char in the input to wchar_t using the
1391 * simplest reasonable transformation. For an underived ctype<wchar_t>
1392 * facet, the argument will be copied, casting each element to wchar_t.
1394 * do_widen() is a hook for a derived facet to change the behavior of
1395 * widening. do_widen() must always return the same result for the
1398 * Note: this is not what you want for codepage conversions. See
1401 * @param __lo Pointer to start range.
1402 * @param __hi Pointer to end of range.
1403 * @param __to Pointer to the destination array.
1407 do_widen(const char* __lo
, const char* __hi
, char_type
* __to
) const;
1410 * @brief Narrow wchar_t to char
1412 * This virtual function converts the argument to char using
1413 * the simplest reasonable transformation. If the conversion
1414 * fails, dfault is returned instead. For an underived
1415 * ctype<wchar_t> facet, @a c will be cast to char and
1418 * do_narrow() is a hook for a derived facet to change the
1419 * behavior of narrowing. do_narrow() must always return the
1420 * same result for the same input.
1422 * Note: this is not what you want for codepage conversions. See
1425 * @param __c The wchar_t to convert.
1426 * @param __dfault Char to return if conversion fails.
1427 * @return The converted char.
1430 do_narrow(char_type __c
, char __dfault
) const;
1433 * @brief Narrow wchar_t array to char array
1435 * This virtual function converts each wchar_t in the range [lo,hi) to
1436 * char using the simplest reasonable transformation and writes the
1437 * results to the destination array. For any wchar_t in the input that
1438 * cannot be converted, @a dfault is used instead. For an underived
1439 * ctype<wchar_t> facet, the argument will be copied, casting each
1442 * do_narrow() is a hook for a derived facet to change the behavior of
1443 * narrowing. do_narrow() must always return the same result for the
1446 * Note: this is not what you want for codepage conversions. See
1449 * @param __lo Pointer to start of range.
1450 * @param __hi Pointer to end of range.
1451 * @param __dfault Char to use if conversion fails.
1452 * @param __to Pointer to the destination array.
1455 virtual const char_type
*
1456 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
1457 char __dfault
, char* __to
) const;
1459 // For use at construction time only.
1461 _M_initialize_ctype() throw();
1463 #endif //_GLIBCXX_USE_WCHAR_T
1465 /// class ctype_byname [22.2.1.2].
1466 template<typename _CharT
>
1467 class ctype_byname
: public ctype
<_CharT
>
1470 typedef typename ctype
<_CharT
>::mask mask
;
1473 ctype_byname(const char* __s
, size_t __refs
= 0);
1477 ~ctype_byname() { };
1480 /// 22.2.1.4 Class ctype_byname specializations.
1482 class ctype_byname
<char> : public ctype
<char>
1486 ctype_byname(const char* __s
, size_t __refs
= 0);
1493 #ifdef _GLIBCXX_USE_WCHAR_T
1495 class ctype_byname
<wchar_t> : public ctype
<wchar_t>
1499 ctype_byname(const char* __s
, size_t __refs
= 0);
1507 _GLIBCXX_END_NAMESPACE_VERSION
1510 // Include host and configuration specific ctype inlines.
1511 #include <bits/ctype_inline.h>
1513 namespace std
_GLIBCXX_VISIBILITY(default)
1515 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1517 // 22.2.2 The numeric category.
1521 // NB: Code depends on the order of _S_atoms_out elements.
1522 // Below are the indices into _S_atoms_out.
1530 _S_odigits_end
= _S_odigits
+ 16,
1531 _S_oudigits
= _S_odigits_end
,
1532 _S_oudigits_end
= _S_oudigits
+ 16,
1533 _S_oe
= _S_odigits
+ 14, // For scientific notation, 'e'
1534 _S_oE
= _S_oudigits
+ 14, // For scientific notation, 'E'
1535 _S_oend
= _S_oudigits_end
1538 // A list of valid numeric literals for output. This array
1539 // contains chars that will be passed through the current locale's
1540 // ctype<_CharT>.widen() and then used to render numbers.
1541 // For the standard "C" locale, this is
1542 // "-+xX0123456789abcdef0123456789ABCDEF".
1543 static const char* _S_atoms_out
;
1545 // String literal of acceptable (narrow) input, for num_get.
1546 // "-+xX0123456789abcdefABCDEF"
1547 static const char* _S_atoms_in
;
1556 _S_ie
= _S_izero
+ 14,
1557 _S_iE
= _S_izero
+ 20,
1562 // Construct and return valid scanf format for floating point types.
1564 _S_format_float(const ios_base
& __io
, char* __fptr
, char __mod
) throw();
1567 template<typename _CharT
>
1568 struct __numpunct_cache
: public locale::facet
1570 const char* _M_grouping
;
1571 size_t _M_grouping_size
;
1572 bool _M_use_grouping
;
1573 const _CharT
* _M_truename
;
1574 size_t _M_truename_size
;
1575 const _CharT
* _M_falsename
;
1576 size_t _M_falsename_size
;
1577 _CharT _M_decimal_point
;
1578 _CharT _M_thousands_sep
;
1580 // A list of valid numeric literals for output: in the standard
1581 // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
1582 // This array contains the chars after having been passed
1583 // through the current locale's ctype<_CharT>.widen().
1584 _CharT _M_atoms_out
[__num_base::_S_oend
];
1586 // A list of valid numeric literals for input: in the standard
1587 // "C" locale, this is "-+xX0123456789abcdefABCDEF"
1588 // This array contains the chars after having been passed
1589 // through the current locale's ctype<_CharT>.widen().
1590 _CharT _M_atoms_in
[__num_base::_S_iend
];
1594 __numpunct_cache(size_t __refs
= 0)
1595 : facet(__refs
), _M_grouping(0), _M_grouping_size(0),
1596 _M_use_grouping(false),
1597 _M_truename(0), _M_truename_size(0), _M_falsename(0),
1598 _M_falsename_size(0), _M_decimal_point(_CharT()),
1599 _M_thousands_sep(_CharT()), _M_allocated(false)
1602 ~__numpunct_cache();
1605 _M_cache(const locale
& __loc
);
1609 operator=(const __numpunct_cache
&);
1612 __numpunct_cache(const __numpunct_cache
&);
1615 template<typename _CharT
>
1616 __numpunct_cache
<_CharT
>::~__numpunct_cache()
1620 delete [] _M_grouping
;
1621 delete [] _M_truename
;
1622 delete [] _M_falsename
;
1627 * @brief Primary class template numpunct.
1630 * This facet stores several pieces of information related to printing and
1631 * scanning numbers, such as the decimal point character. It takes a
1632 * template parameter specifying the char type. The numpunct facet is
1633 * used by streams for many I/O operations involving numbers.
1635 * The numpunct template uses protected virtual functions to provide the
1636 * actual results. The public accessors forward the call to the virtual
1637 * functions. These virtual functions are hooks for developers to
1638 * implement the behavior they require from a numpunct facet.
1640 template<typename _CharT
>
1641 class numpunct
: public locale::facet
1647 typedef _CharT char_type
;
1648 typedef basic_string
<_CharT
> string_type
;
1650 typedef __numpunct_cache
<_CharT
> __cache_type
;
1653 __cache_type
* _M_data
;
1656 /// Numpunct facet id.
1657 static locale::id id
;
1660 * @brief Numpunct constructor.
1662 * @param __refs Refcount to pass to the base class.
1665 numpunct(size_t __refs
= 0)
1666 : facet(__refs
), _M_data(0)
1667 { _M_initialize_numpunct(); }
1670 * @brief Internal constructor. Not for general use.
1672 * This is a constructor for use by the library itself to set up the
1673 * predefined locale facets.
1675 * @param __cache __numpunct_cache object.
1676 * @param __refs Refcount to pass to the base class.
1679 numpunct(__cache_type
* __cache
, size_t __refs
= 0)
1680 : facet(__refs
), _M_data(__cache
)
1681 { _M_initialize_numpunct(); }
1684 * @brief Internal constructor. Not for general use.
1686 * This is a constructor for use by the library itself to set up new
1689 * @param __cloc The C locale.
1690 * @param __refs Refcount to pass to the base class.
1693 numpunct(__c_locale __cloc
, size_t __refs
= 0)
1694 : facet(__refs
), _M_data(0)
1695 { _M_initialize_numpunct(__cloc
); }
1698 * @brief Return decimal point character.
1700 * This function returns a char_type to use as a decimal point. It
1701 * does so by returning returning
1702 * numpunct<char_type>::do_decimal_point().
1704 * @return @a char_type representing a decimal point.
1707 decimal_point() const
1708 { return this->do_decimal_point(); }
1711 * @brief Return thousands separator character.
1713 * This function returns a char_type to use as a thousands
1714 * separator. It does so by returning returning
1715 * numpunct<char_type>::do_thousands_sep().
1717 * @return char_type representing a thousands separator.
1720 thousands_sep() const
1721 { return this->do_thousands_sep(); }
1724 * @brief Return grouping specification.
1726 * This function returns a string representing groupings for the
1727 * integer part of a number. Groupings indicate where thousands
1728 * separators should be inserted in the integer part of a number.
1730 * Each char in the return string is interpret as an integer
1731 * rather than a character. These numbers represent the number
1732 * of digits in a group. The first char in the string
1733 * represents the number of digits in the least significant
1734 * group. If a char is negative, it indicates an unlimited
1735 * number of digits for the group. If more chars from the
1736 * string are required to group a number, the last char is used
1739 * For example, if the grouping() returns "\003\002" and is
1740 * applied to the number 123456789, this corresponds to
1741 * 12,34,56,789. Note that if the string was "32", this would
1742 * put more than 50 digits into the least significant group if
1743 * the character set is ASCII.
1745 * The string is returned by calling
1746 * numpunct<char_type>::do_grouping().
1748 * @return string representing grouping specification.
1752 { return this->do_grouping(); }
1755 * @brief Return string representation of bool true.
1757 * This function returns a string_type containing the text
1758 * representation for true bool variables. It does so by calling
1759 * numpunct<char_type>::do_truename().
1761 * @return string_type representing printed form of true.
1765 { return this->do_truename(); }
1768 * @brief Return string representation of bool false.
1770 * This function returns a string_type containing the text
1771 * representation for false bool variables. It does so by calling
1772 * numpunct<char_type>::do_falsename().
1774 * @return string_type representing printed form of false.
1778 { return this->do_falsename(); }
1786 * @brief Return decimal point character.
1788 * Returns a char_type to use as a decimal point. This function is a
1789 * hook for derived classes to change the value returned.
1791 * @return @a char_type representing a decimal point.
1794 do_decimal_point() const
1795 { return _M_data
->_M_decimal_point
; }
1798 * @brief Return thousands separator character.
1800 * Returns a char_type to use as a thousands separator. This function
1801 * is a hook for derived classes to change the value returned.
1803 * @return @a char_type representing a thousands separator.
1806 do_thousands_sep() const
1807 { return _M_data
->_M_thousands_sep
; }
1810 * @brief Return grouping specification.
1812 * Returns a string representing groupings for the integer part of a
1813 * number. This function is a hook for derived classes to change the
1814 * value returned. @see grouping() for details.
1816 * @return String representing grouping specification.
1820 { return _M_data
->_M_grouping
; }
1823 * @brief Return string representation of bool true.
1825 * Returns a string_type containing the text representation for true
1826 * bool variables. This function is a hook for derived classes to
1827 * change the value returned.
1829 * @return string_type representing printed form of true.
1833 { return _M_data
->_M_truename
; }
1836 * @brief Return string representation of bool false.
1838 * Returns a string_type containing the text representation for false
1839 * bool variables. This function is a hook for derived classes to
1840 * change the value returned.
1842 * @return string_type representing printed form of false.
1845 do_falsename() const
1846 { return _M_data
->_M_falsename
; }
1848 // For use at construction time only.
1850 _M_initialize_numpunct(__c_locale __cloc
= 0);
1853 template<typename _CharT
>
1854 locale::id numpunct
<_CharT
>::id
;
1857 numpunct
<char>::~numpunct();
1861 numpunct
<char>::_M_initialize_numpunct(__c_locale __cloc
);
1863 #ifdef _GLIBCXX_USE_WCHAR_T
1865 numpunct
<wchar_t>::~numpunct();
1869 numpunct
<wchar_t>::_M_initialize_numpunct(__c_locale __cloc
);
1872 /// class numpunct_byname [22.2.3.2].
1873 template<typename _CharT
>
1874 class numpunct_byname
: public numpunct
<_CharT
>
1877 typedef _CharT char_type
;
1878 typedef basic_string
<_CharT
> string_type
;
1881 numpunct_byname(const char* __s
, size_t __refs
= 0)
1882 : numpunct
<_CharT
>(__refs
)
1884 if (__builtin_strcmp(__s
, "C") != 0
1885 && __builtin_strcmp(__s
, "POSIX") != 0)
1888 this->_S_create_c_locale(__tmp
, __s
);
1889 this->_M_initialize_numpunct(__tmp
);
1890 this->_S_destroy_c_locale(__tmp
);
1896 ~numpunct_byname() { }
1899 _GLIBCXX_BEGIN_NAMESPACE_LDBL
1902 * @brief Primary class template num_get.
1905 * This facet encapsulates the code to parse and return a number
1906 * from a string. It is used by the istream numeric extraction
1909 * The num_get template uses protected virtual functions to provide the
1910 * actual results. The public accessors forward the call to the virtual
1911 * functions. These virtual functions are hooks for developers to
1912 * implement the behavior they require from the num_get facet.
1914 template<typename _CharT
, typename _InIter
>
1915 class num_get
: public locale::facet
1921 typedef _CharT char_type
;
1922 typedef _InIter iter_type
;
1925 /// Numpunct facet id.
1926 static locale::id id
;
1929 * @brief Constructor performs initialization.
1931 * This is the constructor provided by the standard.
1933 * @param __refs Passed to the base facet class.
1936 num_get(size_t __refs
= 0) : facet(__refs
) { }
1939 * @brief Numeric parsing.
1941 * Parses the input stream into the bool @a v. It does so by calling
1942 * num_get::do_get().
1944 * If ios_base::boolalpha is set, attempts to read
1945 * ctype<CharT>::truename() or ctype<CharT>::falsename(). Sets
1946 * @a v to true or false if successful. Sets err to
1947 * ios_base::failbit if reading the string fails. Sets err to
1948 * ios_base::eofbit if the stream is emptied.
1950 * If ios_base::boolalpha is not set, proceeds as with reading a long,
1951 * except if the value is 1, sets @a v to true, if the value is 0, sets
1952 * @a v to false, and otherwise set err to ios_base::failbit.
1954 * @param __in Start of input stream.
1955 * @param __end End of input stream.
1956 * @param __io Source of locale and flags.
1957 * @param __err Error flags to set.
1958 * @param __v Value to format and insert.
1959 * @return Iterator after reading.
1962 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
1963 ios_base::iostate
& __err
, bool& __v
) const
1964 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
1968 * @brief Numeric parsing.
1970 * Parses the input stream into the integral variable @a v. It does so
1971 * by calling num_get::do_get().
1973 * Parsing is affected by the flag settings in @a io.
1975 * The basic parse is affected by the value of io.flags() &
1976 * ios_base::basefield. If equal to ios_base::oct, parses like the
1977 * scanf %o specifier. Else if equal to ios_base::hex, parses like %X
1978 * specifier. Else if basefield equal to 0, parses like the %i
1979 * specifier. Otherwise, parses like %d for signed and %u for unsigned
1980 * types. The matching type length modifier is also used.
1982 * Digit grouping is interpreted according to
1983 * numpunct::grouping() and numpunct::thousands_sep(). If the
1984 * pattern of digit groups isn't consistent, sets err to
1985 * ios_base::failbit.
1987 * If parsing the string yields a valid value for @a v, @a v is set.
1988 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
1989 * Sets err to ios_base::eofbit if the stream is emptied.
1991 * @param __in Start of input stream.
1992 * @param __end End of input stream.
1993 * @param __io Source of locale and flags.
1994 * @param __err Error flags to set.
1995 * @param __v Value to format and insert.
1996 * @return Iterator after reading.
1999 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2000 ios_base::iostate
& __err
, long& __v
) const
2001 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2004 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2005 ios_base::iostate
& __err
, unsigned short& __v
) const
2006 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2009 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2010 ios_base::iostate
& __err
, unsigned int& __v
) const
2011 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2014 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2015 ios_base::iostate
& __err
, unsigned long& __v
) const
2016 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2018 #ifdef _GLIBCXX_USE_LONG_LONG
2020 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2021 ios_base::iostate
& __err
, long long& __v
) const
2022 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2025 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2026 ios_base::iostate
& __err
, unsigned long long& __v
) const
2027 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2033 * @brief Numeric parsing.
2035 * Parses the input stream into the integral variable @a v. It does so
2036 * by calling num_get::do_get().
2038 * The input characters are parsed like the scanf %g specifier. The
2039 * matching type length modifier is also used.
2041 * The decimal point character used is numpunct::decimal_point().
2042 * Digit grouping is interpreted according to
2043 * numpunct::grouping() and numpunct::thousands_sep(). If the
2044 * pattern of digit groups isn't consistent, sets err to
2045 * ios_base::failbit.
2047 * If parsing the string yields a valid value for @a v, @a v is set.
2048 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2049 * Sets err to ios_base::eofbit if the stream is emptied.
2051 * @param __in Start of input stream.
2052 * @param __end End of input stream.
2053 * @param __io Source of locale and flags.
2054 * @param __err Error flags to set.
2055 * @param __v Value to format and insert.
2056 * @return Iterator after reading.
2059 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2060 ios_base::iostate
& __err
, float& __v
) const
2061 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2064 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2065 ios_base::iostate
& __err
, double& __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
, long double& __v
) const
2071 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2075 * @brief Numeric parsing.
2077 * Parses the input stream into the pointer variable @a v. It does so
2078 * by calling num_get::do_get().
2080 * The input characters are parsed like the scanf %p specifier.
2082 * Digit grouping is interpreted according to
2083 * numpunct::grouping() and numpunct::thousands_sep(). If the
2084 * pattern of digit groups isn't consistent, sets err to
2085 * ios_base::failbit.
2087 * Note that the digit grouping effect for pointers is a bit ambiguous
2088 * in the standard and shouldn't be relied on. See DR 344.
2090 * If parsing the string yields a valid value for @a v, @a v is set.
2091 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2092 * Sets err to ios_base::eofbit if the stream is emptied.
2094 * @param __in Start of input stream.
2095 * @param __end End of input stream.
2096 * @param __io Source of locale and flags.
2097 * @param __err Error flags to set.
2098 * @param __v Value to format and insert.
2099 * @return Iterator after reading.
2102 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2103 ios_base::iostate
& __err
, void*& __v
) const
2104 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2108 virtual ~num_get() { }
2111 _M_extract_float(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2114 template<typename _ValueT
>
2116 _M_extract_int(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2119 template<typename _CharT2
>
2120 typename
__gnu_cxx::__enable_if
<__is_char
<_CharT2
>::__value
, int>::__type
2121 _M_find(const _CharT2
*, size_t __len
, _CharT2 __c
) const
2126 if (__c
>= _CharT2('0') && __c
< _CharT2(_CharT2('0') + __len
))
2127 __ret
= __c
- _CharT2('0');
2131 if (__c
>= _CharT2('0') && __c
<= _CharT2('9'))
2132 __ret
= __c
- _CharT2('0');
2133 else if (__c
>= _CharT2('a') && __c
<= _CharT2('f'))
2134 __ret
= 10 + (__c
- _CharT2('a'));
2135 else if (__c
>= _CharT2('A') && __c
<= _CharT2('F'))
2136 __ret
= 10 + (__c
- _CharT2('A'));
2141 template<typename _CharT2
>
2142 typename
__gnu_cxx::__enable_if
<!__is_char
<_CharT2
>::__value
,
2144 _M_find(const _CharT2
* __zero
, size_t __len
, _CharT2 __c
) const
2147 const char_type
* __q
= char_traits
<_CharT2
>::find(__zero
, __len
, __c
);
2150 __ret
= __q
- __zero
;
2159 * @brief Numeric parsing.
2161 * Parses the input stream into the variable @a v. This function is a
2162 * hook for derived classes to change the value returned. @see get()
2165 * @param __beg Start of input stream.
2166 * @param __end End of input stream.
2167 * @param __io Source of locale and flags.
2168 * @param __err Error flags to set.
2169 * @param __v Value to format and insert.
2170 * @return Iterator after reading.
2173 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, bool&) const;
2176 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2177 ios_base::iostate
& __err
, long& __v
) const
2178 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2181 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2182 ios_base::iostate
& __err
, unsigned short& __v
) const
2183 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2186 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2187 ios_base::iostate
& __err
, unsigned int& __v
) const
2188 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2191 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2192 ios_base::iostate
& __err
, unsigned long& __v
) const
2193 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2195 #ifdef _GLIBCXX_USE_LONG_LONG
2197 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2198 ios_base::iostate
& __err
, long long& __v
) const
2199 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2202 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2203 ios_base::iostate
& __err
, unsigned long long& __v
) const
2204 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2208 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, float&) const;
2211 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2214 // XXX GLIBCXX_ABI Deprecated
2215 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2217 __do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2221 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2222 long double&) const;
2226 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, void*&) const;
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
&,
2232 long double&) const;
2237 template<typename _CharT
, typename _InIter
>
2238 locale::id num_get
<_CharT
, _InIter
>::id
;
2242 * @brief Primary class template num_put.
2245 * This facet encapsulates the code to convert a number to a string. It is
2246 * used by the ostream numeric insertion operators.
2248 * The num_put template uses protected virtual functions to provide the
2249 * actual results. The public accessors forward the call to the virtual
2250 * functions. These virtual functions are hooks for developers to
2251 * implement the behavior they require from the num_put facet.
2253 template<typename _CharT
, typename _OutIter
>
2254 class num_put
: public locale::facet
2260 typedef _CharT char_type
;
2261 typedef _OutIter iter_type
;
2264 /// Numpunct facet id.
2265 static locale::id id
;
2268 * @brief Constructor performs initialization.
2270 * This is the constructor provided by the standard.
2272 * @param __refs Passed to the base facet class.
2275 num_put(size_t __refs
= 0) : facet(__refs
) { }
2278 * @brief Numeric formatting.
2280 * Formats the boolean @a v and inserts it into a stream. It does so
2281 * by calling num_put::do_put().
2283 * If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
2284 * ctype<CharT>::falsename(). Otherwise formats @a v as an int.
2286 * @param __s Stream to write to.
2287 * @param __io Source of locale and flags.
2288 * @param __fill Char_type to use for filling.
2289 * @param __v Value to format and insert.
2290 * @return Iterator after writing.
2293 put(iter_type __s
, ios_base
& __io
, char_type __fill
, bool __v
) const
2294 { return this->do_put(__s
, __io
, __fill
, __v
); }
2298 * @brief Numeric formatting.
2300 * Formats the integral value @a v and inserts it into a
2301 * stream. It does so by calling num_put::do_put().
2303 * Formatting is affected by the flag settings in @a io.
2305 * The basic format is affected by the value of io.flags() &
2306 * ios_base::basefield. If equal to ios_base::oct, formats like the
2307 * printf %o specifier. Else if equal to ios_base::hex, formats like
2308 * %x or %X with ios_base::uppercase unset or set respectively.
2309 * Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
2310 * for unsigned values. Note that if both oct and hex are set, neither
2313 * If ios_base::showpos is set, '+' is output before positive values.
2314 * If ios_base::showbase is set, '0' precedes octal values (except 0)
2315 * and '0[xX]' precedes hex values.
2317 * The decimal point character used is numpunct::decimal_point().
2318 * Thousands separators are inserted according to
2319 * numpunct::grouping() and numpunct::thousands_sep().
2321 * If io.width() is non-zero, enough @a fill characters are inserted to
2322 * make the result at least that wide. If
2323 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2324 * padded at the end. If ios_base::internal, then padding occurs
2325 * immediately after either a '+' or '-' or after '0x' or '0X'.
2326 * Otherwise, padding occurs at the beginning.
2328 * @param __s Stream to write to.
2329 * @param __io Source of locale and flags.
2330 * @param __fill Char_type to use for filling.
2331 * @param __v Value to format and insert.
2332 * @return Iterator after writing.
2335 put(iter_type __s
, ios_base
& __io
, char_type __fill
, long __v
) const
2336 { return this->do_put(__s
, __io
, __fill
, __v
); }
2339 put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2340 unsigned long __v
) const
2341 { return this->do_put(__s
, __io
, __fill
, __v
); }
2343 #ifdef _GLIBCXX_USE_LONG_LONG
2345 put(iter_type __s
, ios_base
& __io
, char_type __fill
, long long __v
) const
2346 { return this->do_put(__s
, __io
, __fill
, __v
); }
2349 put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2350 unsigned long long __v
) const
2351 { return this->do_put(__s
, __io
, __fill
, __v
); }
2357 * @brief Numeric formatting.
2359 * Formats the floating point value @a v and inserts it into a stream.
2360 * It does so by calling num_put::do_put().
2362 * Formatting is affected by the flag settings in @a io.
2364 * The basic format is affected by the value of io.flags() &
2365 * ios_base::floatfield. If equal to ios_base::fixed, formats like the
2366 * printf %f specifier. Else if equal to ios_base::scientific, formats
2367 * like %e or %E with ios_base::uppercase unset or set respectively.
2368 * Otherwise, formats like %g or %G depending on uppercase. Note that
2369 * if both fixed and scientific are set, the effect will also be like
2372 * The output precision is given by io.precision(). This precision is
2373 * capped at numeric_limits::digits10 + 2 (different for double and
2374 * long double). The default precision is 6.
2376 * If ios_base::showpos is set, '+' is output before positive values.
2377 * If ios_base::showpoint is set, a decimal point will always be
2380 * The decimal point character used is numpunct::decimal_point().
2381 * Thousands separators are inserted according to
2382 * numpunct::grouping() and numpunct::thousands_sep().
2384 * If io.width() is non-zero, enough @a fill characters are inserted to
2385 * make the result at least that wide. If
2386 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2387 * padded at the end. If ios_base::internal, then padding occurs
2388 * immediately after either a '+' or '-' or after '0x' or '0X'.
2389 * Otherwise, padding occurs at the beginning.
2391 * @param __s Stream to write to.
2392 * @param __io Source of locale and flags.
2393 * @param __fill Char_type to use for filling.
2394 * @param __v Value to format and insert.
2395 * @return Iterator after writing.
2398 put(iter_type __s
, ios_base
& __io
, char_type __fill
, double __v
) const
2399 { return this->do_put(__s
, __io
, __fill
, __v
); }
2402 put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2403 long double __v
) const
2404 { return this->do_put(__s
, __io
, __fill
, __v
); }
2408 * @brief Numeric formatting.
2410 * Formats the pointer value @a v and inserts it into a stream. It
2411 * does so by calling num_put::do_put().
2413 * This function formats @a v as an unsigned long with ios_base::hex
2414 * and ios_base::showbase set.
2416 * @param __s Stream to write to.
2417 * @param __io Source of locale and flags.
2418 * @param __fill Char_type to use for filling.
2419 * @param __v Value to format and insert.
2420 * @return Iterator after writing.
2423 put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2424 const void* __v
) const
2425 { return this->do_put(__s
, __io
, __fill
, __v
); }
2428 template<typename _ValueT
>
2430 _M_insert_float(iter_type
, ios_base
& __io
, char_type __fill
,
2431 char __mod
, _ValueT __v
) const;
2434 _M_group_float(const char* __grouping
, size_t __grouping_size
,
2435 char_type __sep
, const char_type
* __p
, char_type
* __new
,
2436 char_type
* __cs
, int& __len
) const;
2438 template<typename _ValueT
>
2440 _M_insert_int(iter_type
, ios_base
& __io
, char_type __fill
,
2444 _M_group_int(const char* __grouping
, size_t __grouping_size
,
2445 char_type __sep
, ios_base
& __io
, char_type
* __new
,
2446 char_type
* __cs
, int& __len
) const;
2449 _M_pad(char_type __fill
, streamsize __w
, ios_base
& __io
,
2450 char_type
* __new
, const char_type
* __cs
, int& __len
) const;
2458 * @brief Numeric formatting.
2460 * These functions do the work of formatting numeric values and
2461 * inserting them into a stream. This function is a hook for derived
2462 * classes to change the value returned.
2464 * @param __s Stream to write to.
2465 * @param __io Source of locale and flags.
2466 * @param __fill Char_type to use for filling.
2467 * @param __v Value to format and insert.
2468 * @return Iterator after writing.
2471 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
, bool __v
) const;
2474 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
, long __v
) const
2475 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2478 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2479 unsigned long __v
) const
2480 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2482 #ifdef _GLIBCXX_USE_LONG_LONG
2484 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2485 long long __v
) const
2486 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2489 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2490 unsigned long long __v
) const
2491 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2495 do_put(iter_type
, ios_base
&, char_type
, double) const;
2497 // XXX GLIBCXX_ABI Deprecated
2498 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2500 __do_put(iter_type
, ios_base
&, char_type
, double) const;
2503 do_put(iter_type
, ios_base
&, char_type
, long double) const;
2507 do_put(iter_type
, ios_base
&, char_type
, const void*) const;
2509 // XXX GLIBCXX_ABI Deprecated
2510 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2512 do_put(iter_type
, ios_base
&, char_type
, long double) const;
2517 template <typename _CharT
, typename _OutIter
>
2518 locale::id num_put
<_CharT
, _OutIter
>::id
;
2520 _GLIBCXX_END_NAMESPACE_LDBL
2522 // Subclause convenience interfaces, inlines.
2523 // NB: These are inline because, when used in a loop, some compilers
2524 // can hoist the body out of the loop; then it's just as fast as the
2525 // C is*() function.
2527 /// Convenience interface to ctype.is(ctype_base::space, __c).
2528 template<typename _CharT
>
2530 isspace(_CharT __c
, const locale
& __loc
)
2531 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::space
, __c
); }
2533 /// Convenience interface to ctype.is(ctype_base::print, __c).
2534 template<typename _CharT
>
2536 isprint(_CharT __c
, const locale
& __loc
)
2537 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::print
, __c
); }
2539 /// Convenience interface to ctype.is(ctype_base::cntrl, __c).
2540 template<typename _CharT
>
2542 iscntrl(_CharT __c
, const locale
& __loc
)
2543 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::cntrl
, __c
); }
2545 /// Convenience interface to ctype.is(ctype_base::upper, __c).
2546 template<typename _CharT
>
2548 isupper(_CharT __c
, const locale
& __loc
)
2549 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::upper
, __c
); }
2551 /// Convenience interface to ctype.is(ctype_base::lower, __c).
2552 template<typename _CharT
>
2554 islower(_CharT __c
, const locale
& __loc
)
2555 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::lower
, __c
); }
2557 /// Convenience interface to ctype.is(ctype_base::alpha, __c).
2558 template<typename _CharT
>
2560 isalpha(_CharT __c
, const locale
& __loc
)
2561 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alpha
, __c
); }
2563 /// Convenience interface to ctype.is(ctype_base::digit, __c).
2564 template<typename _CharT
>
2566 isdigit(_CharT __c
, const locale
& __loc
)
2567 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::digit
, __c
); }
2569 /// Convenience interface to ctype.is(ctype_base::punct, __c).
2570 template<typename _CharT
>
2572 ispunct(_CharT __c
, const locale
& __loc
)
2573 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::punct
, __c
); }
2575 /// Convenience interface to ctype.is(ctype_base::xdigit, __c).
2576 template<typename _CharT
>
2578 isxdigit(_CharT __c
, const locale
& __loc
)
2579 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::xdigit
, __c
); }
2581 /// Convenience interface to ctype.is(ctype_base::alnum, __c).
2582 template<typename _CharT
>
2584 isalnum(_CharT __c
, const locale
& __loc
)
2585 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alnum
, __c
); }
2587 /// Convenience interface to ctype.is(ctype_base::graph, __c).
2588 template<typename _CharT
>
2590 isgraph(_CharT __c
, const locale
& __loc
)
2591 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::graph
, __c
); }
2593 /// Convenience interface to ctype.toupper(__c).
2594 template<typename _CharT
>
2596 toupper(_CharT __c
, const locale
& __loc
)
2597 { return use_facet
<ctype
<_CharT
> >(__loc
).toupper(__c
); }
2599 /// Convenience interface to ctype.tolower(__c).
2600 template<typename _CharT
>
2602 tolower(_CharT __c
, const locale
& __loc
)
2603 { return use_facet
<ctype
<_CharT
> >(__loc
).tolower(__c
); }
2605 _GLIBCXX_END_NAMESPACE_VERSION
2608 # include <bits/locale_facets.tcc>