1 // Locale support -*- C++ -*-
3 // Copyright (C) 1997-2018 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
57 # define _GLIBCXX_NUM_CXX11_FACETS 16
59 # define _GLIBCXX_NUM_FACETS 14
60 # define _GLIBCXX_NUM_CXX11_FACETS 8
62 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
63 # define _GLIBCXX_NUM_UNICODE_FACETS 2
65 # define _GLIBCXX_NUM_UNICODE_FACETS 0
68 // Convert string to numeric value of type _Tp and store results.
69 // NB: This is specialized for all required types, there is no
70 // generic definition.
71 template<typename _Tp
>
73 __convert_to_v(const char*, _Tp
&, ios_base::iostate
&,
74 const __c_locale
&) throw();
76 // Explicit specializations for required types.
79 __convert_to_v(const char*, float&, ios_base::iostate
&,
80 const __c_locale
&) throw();
84 __convert_to_v(const char*, double&, ios_base::iostate
&,
85 const __c_locale
&) throw();
89 __convert_to_v(const char*, long double&, ios_base::iostate
&,
90 const __c_locale
&) throw();
92 // NB: __pad is a struct, rather than a function, so it can be
93 // partially-specialized.
94 template<typename _CharT
, typename _Traits
>
98 _S_pad(ios_base
& __io
, _CharT __fill
, _CharT
* __news
,
99 const _CharT
* __olds
, streamsize __newlen
, streamsize __oldlen
);
102 // Used by both numeric and monetary facets.
103 // Inserts "group separator" characters into an array of characters.
104 // It's recursive, one iteration per group. It moves the characters
105 // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
106 // only with __gsize != 0.
107 template<typename _CharT
>
109 __add_grouping(_CharT
* __s
, _CharT __sep
,
110 const char* __gbeg
, size_t __gsize
,
111 const _CharT
* __first
, const _CharT
* __last
);
113 // This template permits specializing facet output code for
114 // ostreambuf_iterator. For ostreambuf_iterator, sputn is
115 // significantly more efficient than incrementing iterators.
116 template<typename _CharT
>
118 ostreambuf_iterator
<_CharT
>
119 __write(ostreambuf_iterator
<_CharT
> __s
, const _CharT
* __ws
, int __len
)
121 __s
._M_put(__ws
, __len
);
125 // This is the unspecialized form of the template.
126 template<typename _CharT
, typename _OutIter
>
129 __write(_OutIter __s
, const _CharT
* __ws
, int __len
)
131 for (int __j
= 0; __j
< __len
; __j
++, ++__s
)
137 // 22.2.1.1 Template class ctype
138 // Include host and configuration specific ctype enums for ctype_base.
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
161 * mask @a __m. It does so by returning the value of
162 * ctype<char_type>::do_is().
164 * @param __c The char_type to compare the mask of.
165 * @param __m The mask to compare against.
166 * @return (M & __m) != 0.
169 is(mask __m
, char_type __c
) const
170 { return this->do_is(__m
, __c
); }
173 * @brief Return a mask array.
175 * This function finds the mask for each char_type in the range [lo,hi)
176 * and successively writes it to vec. vec must have as many elements
177 * as the char array. It does so by returning the value of
178 * ctype<char_type>::do_is().
180 * @param __lo Pointer to start of range.
181 * @param __hi Pointer to end of range.
182 * @param __vec Pointer to an array of mask storage.
186 is(const char_type
*__lo
, const char_type
*__hi
, mask
*__vec
) const
187 { return this->do_is(__lo
, __hi
, __vec
); }
190 * @brief Find char_type matching a mask
192 * This function searches for and returns the first char_type c in
193 * [lo,hi) for which is(m,c) is true. It does so by returning
194 * ctype<char_type>::do_scan_is().
196 * @param __m The mask to compare against.
197 * @param __lo Pointer to start of range.
198 * @param __hi Pointer to end of range.
199 * @return Pointer to matching char_type if found, else @a __hi.
202 scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
203 { return this->do_scan_is(__m
, __lo
, __hi
); }
206 * @brief Find char_type not matching a mask
208 * This function searches for and returns the first char_type c in
209 * [lo,hi) for which is(m,c) is false. It does so by returning
210 * ctype<char_type>::do_scan_not().
212 * @param __m The mask to compare against.
213 * @param __lo Pointer to first char in range.
214 * @param __hi Pointer to end of range.
215 * @return Pointer to non-matching char if found, else @a __hi.
218 scan_not(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
219 { return this->do_scan_not(__m
, __lo
, __hi
); }
222 * @brief Convert to uppercase.
224 * This function converts the argument to uppercase if possible.
225 * If not possible (for example, '2'), returns the argument. It does
226 * so by returning ctype<char_type>::do_toupper().
228 * @param __c The char_type to convert.
229 * @return The uppercase char_type if convertible, else @a __c.
232 toupper(char_type __c
) const
233 { return this->do_toupper(__c
); }
236 * @brief Convert array to uppercase.
238 * This function converts each char_type in the range [lo,hi) to
239 * uppercase if possible. Other elements remain untouched. It does so
240 * by returning ctype<char_type>:: do_toupper(lo, hi).
242 * @param __lo Pointer to start of range.
243 * @param __hi Pointer to end of range.
247 toupper(char_type
*__lo
, const char_type
* __hi
) const
248 { return this->do_toupper(__lo
, __hi
); }
251 * @brief Convert to lowercase.
253 * This function converts the argument to lowercase if possible. If
254 * not possible (for example, '2'), returns the argument. It does so
255 * by returning ctype<char_type>::do_tolower(c).
257 * @param __c The char_type to convert.
258 * @return The lowercase char_type if convertible, else @a __c.
261 tolower(char_type __c
) const
262 { return this->do_tolower(__c
); }
265 * @brief Convert array to lowercase.
267 * This function converts each char_type in the range [__lo,__hi) to
268 * lowercase if possible. Other elements remain untouched. It does so
269 * by returning ctype<char_type>:: do_tolower(__lo, __hi).
271 * @param __lo Pointer to start of range.
272 * @param __hi Pointer to end of range.
276 tolower(char_type
* __lo
, const char_type
* __hi
) const
277 { return this->do_tolower(__lo
, __hi
); }
280 * @brief Widen char to char_type
282 * This function converts the char argument to char_type using the
283 * simplest reasonable transformation. It does so by returning
284 * ctype<char_type>::do_widen(c).
286 * Note: this is not what you want for codepage conversions. See
289 * @param __c The char to convert.
290 * @return The converted char_type.
293 widen(char __c
) const
294 { return this->do_widen(__c
); }
297 * @brief Widen array to char_type
299 * This function converts each char in the input to char_type using the
300 * simplest reasonable transformation. It does so by returning
301 * ctype<char_type>::do_widen(c).
303 * Note: this is not what you want for codepage conversions. See
306 * @param __lo Pointer to start of range.
307 * @param __hi Pointer to end of range.
308 * @param __to Pointer to the destination array.
312 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
313 { return this->do_widen(__lo
, __hi
, __to
); }
316 * @brief Narrow char_type to char
318 * This function converts the char_type to char using the simplest
319 * reasonable transformation. If the conversion fails, dfault is
320 * returned instead. It does so by returning
321 * ctype<char_type>::do_narrow(__c).
323 * Note: this is not what you want for codepage conversions. See
326 * @param __c The char_type to convert.
327 * @param __dfault Char to return if conversion fails.
328 * @return The converted char.
331 narrow(char_type __c
, char __dfault
) const
332 { return this->do_narrow(__c
, __dfault
); }
335 * @brief Narrow array to char array
337 * This function converts each char_type in the input to char using the
338 * simplest reasonable transformation and writes the results to the
339 * destination array. For any char_type in the input that cannot be
340 * converted, @a dfault is used instead. It does so by returning
341 * ctype<char_type>::do_narrow(__lo, __hi, __dfault, __to).
343 * Note: this is not what you want for codepage conversions. See
346 * @param __lo Pointer to start of range.
347 * @param __hi Pointer to end of range.
348 * @param __dfault Char to use if conversion fails.
349 * @param __to Pointer to the destination array.
353 narrow(const char_type
* __lo
, const char_type
* __hi
,
354 char __dfault
, char* __to
) const
355 { return this->do_narrow(__lo
, __hi
, __dfault
, __to
); }
359 __ctype_abstract_base(size_t __refs
= 0): facet(__refs
) { }
362 ~__ctype_abstract_base() { }
365 * @brief Test char_type classification.
367 * This function finds a mask M for @a c and compares it to mask @a m.
369 * do_is() is a hook for a derived facet to change the behavior of
370 * classifying. do_is() must always return the same result for the
373 * @param __c The char_type to find the mask of.
374 * @param __m The mask to compare against.
375 * @return (M & __m) != 0.
378 do_is(mask __m
, char_type __c
) const = 0;
381 * @brief Return a mask array.
383 * This function finds the mask for each char_type in the range [lo,hi)
384 * and successively writes it to vec. vec must have as many elements
387 * do_is() is a hook for a derived facet to change the behavior of
388 * classifying. do_is() must always return the same result for the
391 * @param __lo Pointer to start of range.
392 * @param __hi Pointer to end of range.
393 * @param __vec Pointer to an array of mask storage.
396 virtual const char_type
*
397 do_is(const char_type
* __lo
, const char_type
* __hi
,
398 mask
* __vec
) const = 0;
401 * @brief Find char_type matching mask
403 * This function searches for and returns the first char_type c in
404 * [__lo,__hi) for which is(__m,c) is true.
406 * do_scan_is() is a hook for a derived facet to change the behavior of
407 * match searching. do_is() must always return the same result for the
410 * @param __m The mask to compare against.
411 * @param __lo Pointer to start of range.
412 * @param __hi Pointer to end of range.
413 * @return Pointer to a matching char_type if found, else @a __hi.
415 virtual const char_type
*
416 do_scan_is(mask __m
, const char_type
* __lo
,
417 const char_type
* __hi
) const = 0;
420 * @brief Find char_type not matching mask
422 * This function searches for and returns a pointer to the first
423 * char_type c of [lo,hi) for which is(m,c) is false.
425 * do_scan_is() is a hook for a derived facet to change the behavior of
426 * match searching. do_is() must always return the same result for the
429 * @param __m The mask to compare against.
430 * @param __lo Pointer to start of range.
431 * @param __hi Pointer to end of range.
432 * @return Pointer to a non-matching char_type if found, else @a __hi.
434 virtual const char_type
*
435 do_scan_not(mask __m
, const char_type
* __lo
,
436 const char_type
* __hi
) const = 0;
439 * @brief Convert to uppercase.
441 * This virtual function converts the char_type argument to uppercase
442 * if possible. If not possible (for example, '2'), returns the
445 * do_toupper() is a hook for a derived facet to change the behavior of
446 * uppercasing. do_toupper() must always return the same result for
449 * @param __c The char_type to convert.
450 * @return The uppercase char_type if convertible, else @a __c.
453 do_toupper(char_type __c
) const = 0;
456 * @brief Convert array to uppercase.
458 * This virtual function converts each char_type in the range [__lo,__hi)
459 * to uppercase if possible. Other elements remain untouched.
461 * do_toupper() is a hook for a derived facet to change the behavior of
462 * uppercasing. do_toupper() must always return the same result for
465 * @param __lo Pointer to start of range.
466 * @param __hi Pointer to end of range.
469 virtual const char_type
*
470 do_toupper(char_type
* __lo
, const char_type
* __hi
) const = 0;
473 * @brief Convert to lowercase.
475 * This virtual function converts the argument to lowercase if
476 * possible. If not possible (for example, '2'), returns the argument.
478 * do_tolower() is a hook for a derived facet to change the behavior of
479 * lowercasing. do_tolower() must always return the same result for
482 * @param __c The char_type to convert.
483 * @return The lowercase char_type if convertible, else @a __c.
486 do_tolower(char_type __c
) const = 0;
489 * @brief Convert array to lowercase.
491 * This virtual function converts each char_type in the range [__lo,__hi)
492 * to lowercase if possible. Other elements remain untouched.
494 * do_tolower() is a hook for a derived facet to change the behavior of
495 * lowercasing. do_tolower() must always return the same result for
498 * @param __lo Pointer to start of range.
499 * @param __hi Pointer to end of range.
502 virtual const char_type
*
503 do_tolower(char_type
* __lo
, const char_type
* __hi
) const = 0;
508 * This virtual function converts the char to char_type using the
509 * simplest reasonable transformation.
511 * do_widen() is a hook for a derived facet to change the behavior of
512 * widening. do_widen() must always return the same result for the
515 * Note: this is not what you want for codepage conversions. See
518 * @param __c The char to convert.
519 * @return The converted char_type
522 do_widen(char __c
) const = 0;
525 * @brief Widen char array
527 * This function converts each char in the input to char_type using the
528 * simplest reasonable transformation.
530 * do_widen() is a hook for a derived facet to change the behavior of
531 * widening. do_widen() must always return the same result for the
534 * Note: this is not what you want for codepage conversions. See
537 * @param __lo Pointer to start range.
538 * @param __hi Pointer to end of range.
539 * @param __to Pointer to the destination array.
543 do_widen(const char* __lo
, const char* __hi
, char_type
* __to
) 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 __c
, char __dfault
) const = 0;
567 * @brief Narrow char_type array to char
569 * This virtual function converts each char_type in the range
570 * [__lo,__hi) to char using the simplest reasonable
571 * transformation and writes the results to the destination
572 * array. For any element in the input that cannot be
573 * converted, @a __dfault is used instead.
575 * do_narrow() is a hook for a derived facet to change the behavior of
576 * narrowing. do_narrow() must always return the same result for the
579 * Note: this is not what you want for codepage conversions. See
582 * @param __lo Pointer to start of range.
583 * @param __hi Pointer to end of range.
584 * @param __dfault Char to use if conversion fails.
585 * @param __to Pointer to the destination array.
588 virtual const char_type
*
589 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
590 char __dfault
, char* __to
) const = 0;
594 * @brief Primary class template ctype facet.
597 * This template class defines classification and conversion functions for
598 * character sets. It wraps cctype functionality. Ctype gets used by
599 * streams for many I/O operations.
601 * This template provides the protected virtual functions the developer
602 * will have to replace in a derived class or specialization to make a
603 * working facet. The public functions that access them are defined in
604 * __ctype_abstract_base, to allow for implementation flexibility. See
605 * ctype<wchar_t> for an example. The functions are documented in
606 * __ctype_abstract_base.
608 * Note: implementations are provided for all the protected virtual
609 * functions, but will likely not be useful.
611 template<typename _CharT
>
612 class ctype
: public __ctype_abstract_base
<_CharT
>
616 typedef _CharT char_type
;
617 typedef typename __ctype_abstract_base
<_CharT
>::mask mask
;
619 /// The facet id for ctype<char_type>
620 static locale::id id
;
623 ctype(size_t __refs
= 0) : __ctype_abstract_base
<_CharT
>(__refs
) { }
630 do_is(mask __m
, char_type __c
) const;
632 virtual const char_type
*
633 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
635 virtual const char_type
*
636 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
638 virtual const char_type
*
639 do_scan_not(mask __m
, const char_type
* __lo
,
640 const char_type
* __hi
) const;
643 do_toupper(char_type __c
) const;
645 virtual const char_type
*
646 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
649 do_tolower(char_type __c
) const;
651 virtual const char_type
*
652 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
655 do_widen(char __c
) const;
658 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
661 do_narrow(char_type
, char __dfault
) const;
663 virtual const char_type
*
664 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
665 char __dfault
, char* __to
) const;
668 template<typename _CharT
>
669 locale::id ctype
<_CharT
>::id
;
672 * @brief The ctype<char> specialization.
675 * This class defines classification and conversion functions for
676 * the char type. It gets used by char streams for many I/O
677 * operations. The char specialization provides a number of
678 * optimizations as well.
681 class ctype
<char> : public locale::facet
, public ctype_base
685 /// Typedef for the template parameter char.
686 typedef char char_type
;
690 __c_locale _M_c_locale_ctype
;
692 __to_type _M_toupper
;
693 __to_type _M_tolower
;
694 const mask
* _M_table
;
695 mutable char _M_widen_ok
;
696 mutable char _M_widen
[1 + static_cast<unsigned char>(-1)];
697 mutable char _M_narrow
[1 + static_cast<unsigned char>(-1)];
698 mutable char _M_narrow_ok
; // 0 uninitialized, 1 init,
699 // 2 memcpy can't be used
702 /// The facet id for ctype<char>
703 static locale::id id
;
704 /// The size of the mask table. It is SCHAR_MAX + 1.
705 static const size_t table_size
= 1 + static_cast<unsigned char>(-1);
708 * @brief Constructor performs initialization.
710 * This is the constructor provided by the standard.
712 * @param __table If non-zero, table is used as the per-char mask.
713 * Else classic_table() is used.
714 * @param __del If true, passes ownership of table to this facet.
715 * @param __refs Passed to the base facet class.
718 ctype(const mask
* __table
= 0, bool __del
= false, size_t __refs
= 0);
721 * @brief Constructor performs static initialization.
723 * This constructor is used to construct the initial C locale facet.
725 * @param __cloc Handle to C locale data.
726 * @param __table If non-zero, table is used as the per-char mask.
727 * @param __del If true, passes ownership of table to this facet.
728 * @param __refs Passed to the base facet class.
731 ctype(__c_locale __cloc
, const mask
* __table
= 0, bool __del
= false,
735 * @brief Test char classification.
737 * This function compares the mask table[c] to @a __m.
739 * @param __c The char to compare the mask of.
740 * @param __m The mask to compare against.
741 * @return True if __m & table[__c] is true, false otherwise.
744 is(mask __m
, char __c
) const;
747 * @brief Return a mask array.
749 * This function finds the mask for each char in the range [lo, hi) and
750 * successively writes it to vec. vec must have as many elements as
753 * @param __lo Pointer to start of range.
754 * @param __hi Pointer to end of range.
755 * @param __vec Pointer to an array of mask storage.
759 is(const char* __lo
, const char* __hi
, mask
* __vec
) const;
762 * @brief Find char matching a mask
764 * This function searches for and returns the first char in [lo,hi) for
765 * which is(m,char) is true.
767 * @param __m The mask to compare against.
768 * @param __lo Pointer to start of range.
769 * @param __hi Pointer to end of range.
770 * @return Pointer to a matching char if found, else @a __hi.
773 scan_is(mask __m
, const char* __lo
, const char* __hi
) const;
776 * @brief Find char not matching a mask
778 * This function searches for and returns a pointer to the first char
779 * in [__lo,__hi) for which is(m,char) is false.
781 * @param __m The mask to compare against.
782 * @param __lo Pointer to start of range.
783 * @param __hi Pointer to end of range.
784 * @return Pointer to a non-matching char if found, else @a __hi.
787 scan_not(mask __m
, const char* __lo
, const char* __hi
) const;
790 * @brief Convert to uppercase.
792 * This function converts the char argument to uppercase if possible.
793 * If not possible (for example, '2'), returns the argument.
795 * toupper() acts as if it returns ctype<char>::do_toupper(c).
796 * do_toupper() must always return the same result for the same input.
798 * @param __c The char to convert.
799 * @return The uppercase char if convertible, else @a __c.
802 toupper(char_type __c
) const
803 { return this->do_toupper(__c
); }
806 * @brief Convert array to uppercase.
808 * This function converts each char in the range [__lo,__hi) to uppercase
809 * if possible. Other chars remain untouched.
811 * toupper() acts as if it returns ctype<char>:: do_toupper(__lo, __hi).
812 * do_toupper() must always return the same result for the same input.
814 * @param __lo Pointer to first char in range.
815 * @param __hi Pointer to end of range.
819 toupper(char_type
*__lo
, const char_type
* __hi
) const
820 { return this->do_toupper(__lo
, __hi
); }
823 * @brief Convert to lowercase.
825 * This function converts the char argument to lowercase if possible.
826 * If not possible (for example, '2'), returns the argument.
828 * tolower() acts as if it returns ctype<char>::do_tolower(__c).
829 * do_tolower() must always return the same result for the same input.
831 * @param __c The char to convert.
832 * @return The lowercase char if convertible, else @a __c.
835 tolower(char_type __c
) const
836 { return this->do_tolower(__c
); }
839 * @brief Convert array to lowercase.
841 * This function converts each char in the range [lo,hi) to lowercase
842 * if possible. Other chars remain untouched.
844 * tolower() acts as if it returns ctype<char>:: do_tolower(__lo, __hi).
845 * do_tolower() must always return the same result for the same input.
847 * @param __lo Pointer to first char in range.
848 * @param __hi Pointer to end of range.
852 tolower(char_type
* __lo
, const char_type
* __hi
) const
853 { return this->do_tolower(__lo
, __hi
); }
858 * This function converts the char to char_type using the simplest
859 * reasonable transformation. For an underived ctype<char> facet, the
860 * argument will be returned unchanged.
862 * This function works as if it returns ctype<char>::do_widen(c).
863 * do_widen() must always return the same result for the same input.
865 * Note: this is not what you want for codepage conversions. See
868 * @param __c The char to convert.
869 * @return The converted character.
872 widen(char __c
) const
875 return _M_widen
[static_cast<unsigned char>(__c
)];
876 this->_M_widen_init();
877 return this->do_widen(__c
);
881 * @brief Widen char array
883 * This function converts each char in the input to char using the
884 * simplest reasonable transformation. For an underived ctype<char>
885 * facet, the argument will be copied unchanged.
887 * This function works as if it returns ctype<char>::do_widen(c).
888 * do_widen() must always return the same result for the same input.
890 * Note: this is not what you want for codepage conversions. See
893 * @param __lo Pointer to first char in range.
894 * @param __hi Pointer to end of range.
895 * @param __to Pointer to the destination array.
899 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
901 if (_M_widen_ok
== 1)
903 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
908 return this->do_widen(__lo
, __hi
, __to
);
914 * This function converts the char to char using the simplest
915 * reasonable transformation. If the conversion fails, dfault is
916 * returned instead. For an underived ctype<char> facet, @a c
917 * will be returned unchanged.
919 * This function works as if it returns ctype<char>::do_narrow(c).
920 * do_narrow() must always return the same result for the same input.
922 * Note: this is not what you want for codepage conversions. See
925 * @param __c The char to convert.
926 * @param __dfault Char to return if conversion fails.
927 * @return The converted character.
930 narrow(char_type __c
, char __dfault
) const
932 if (_M_narrow
[static_cast<unsigned char>(__c
)])
933 return _M_narrow
[static_cast<unsigned char>(__c
)];
934 const char __t
= do_narrow(__c
, __dfault
);
936 _M_narrow
[static_cast<unsigned char>(__c
)] = __t
;
941 * @brief Narrow char array
943 * This function converts each char in the input to char using the
944 * simplest reasonable transformation and writes the results to the
945 * destination array. For any char in the input that cannot be
946 * converted, @a dfault is used instead. For an underived ctype<char>
947 * facet, the argument will be copied unchanged.
949 * This function works as if it returns ctype<char>::do_narrow(lo, hi,
950 * dfault, to). do_narrow() must always return the same result for the
953 * Note: this is not what you want for codepage conversions. See
956 * @param __lo Pointer to start of range.
957 * @param __hi Pointer to end of range.
958 * @param __dfault Char to use if conversion fails.
959 * @param __to Pointer to the destination array.
963 narrow(const char_type
* __lo
, const char_type
* __hi
,
964 char __dfault
, char* __to
) const
966 if (__builtin_expect(_M_narrow_ok
== 1, true))
968 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
973 return this->do_narrow(__lo
, __hi
, __dfault
, __to
);
976 // _GLIBCXX_RESOLVE_LIB_DEFECTS
977 // DR 695. ctype<char>::classic_table() not accessible.
978 /// Returns a pointer to the mask table provided to the constructor, or
979 /// the default from classic_table() if none was provided.
981 table() const throw()
984 /// Returns a pointer to the C locale mask table.
986 classic_table() throw();
992 * This function deletes table() if @a del was true in the
999 * @brief Convert to uppercase.
1001 * This virtual function converts the char argument to uppercase if
1002 * possible. If not possible (for example, '2'), returns the argument.
1004 * do_toupper() is a hook for a derived facet to change the behavior of
1005 * uppercasing. do_toupper() must always return the same result for
1008 * @param __c The char to convert.
1009 * @return The uppercase char if convertible, else @a __c.
1012 do_toupper(char_type __c
) const;
1015 * @brief Convert array to uppercase.
1017 * This virtual function converts each char in the range [lo,hi) to
1018 * uppercase if possible. Other chars remain untouched.
1020 * do_toupper() is a hook for a derived facet to change the behavior of
1021 * uppercasing. do_toupper() must always return the same result for
1024 * @param __lo Pointer to start of range.
1025 * @param __hi Pointer to end of range.
1028 virtual const char_type
*
1029 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
1032 * @brief Convert to lowercase.
1034 * This virtual function converts the char argument to lowercase if
1035 * possible. If not possible (for example, '2'), returns the argument.
1037 * do_tolower() is a hook for a derived facet to change the behavior of
1038 * lowercasing. do_tolower() must always return the same result for
1041 * @param __c The char to convert.
1042 * @return The lowercase char if convertible, else @a __c.
1045 do_tolower(char_type __c
) const;
1048 * @brief Convert array to lowercase.
1050 * This virtual function converts each char in the range [lo,hi) to
1051 * lowercase if possible. Other chars remain untouched.
1053 * do_tolower() is a hook for a derived facet to change the behavior of
1054 * lowercasing. do_tolower() must always return the same result for
1057 * @param __lo Pointer to first char in range.
1058 * @param __hi Pointer to end of range.
1061 virtual const char_type
*
1062 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
1067 * This virtual function converts the char to char using the simplest
1068 * reasonable transformation. For an underived ctype<char> facet, the
1069 * argument will be returned unchanged.
1071 * do_widen() is a hook for a derived facet to change the behavior of
1072 * widening. do_widen() must always return the same result for the
1075 * Note: this is not what you want for codepage conversions. See
1078 * @param __c The char to convert.
1079 * @return The converted character.
1082 do_widen(char __c
) const
1086 * @brief Widen char array
1088 * This function converts each char in the range [lo,hi) to char using
1089 * the simplest reasonable transformation. For an underived
1090 * ctype<char> facet, the argument will be copied unchanged.
1092 * do_widen() is a hook for a derived facet to change the behavior of
1093 * widening. do_widen() must always return the same result for the
1096 * Note: this is not what you want for codepage conversions. See
1099 * @param __lo Pointer to start of range.
1100 * @param __hi Pointer to end of range.
1101 * @param __to Pointer to the destination array.
1105 do_widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
1107 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
1112 * @brief Narrow char
1114 * This virtual function converts the char to char using the simplest
1115 * reasonable transformation. If the conversion fails, dfault is
1116 * returned instead. For an underived ctype<char> facet, @a c will be
1117 * returned unchanged.
1119 * do_narrow() is a hook for a derived facet to change the behavior of
1120 * narrowing. do_narrow() must always return the same result for the
1123 * Note: this is not what you want for codepage conversions. See
1126 * @param __c The char to convert.
1127 * @param __dfault Char to return if conversion fails.
1128 * @return The converted char.
1131 do_narrow(char_type __c
, char __dfault
__attribute__((__unused__
))) const
1135 * @brief Narrow char array to char array
1137 * This virtual function converts each char in the range [lo,hi) to
1138 * char using the simplest reasonable transformation and writes the
1139 * results to the destination array. For any char in the input that
1140 * cannot be converted, @a dfault is used instead. For an underived
1141 * ctype<char> facet, the argument will be copied unchanged.
1143 * do_narrow() is a hook for a derived facet to change the behavior of
1144 * narrowing. do_narrow() must always return the same result for the
1147 * Note: this is not what you want for codepage conversions. See
1150 * @param __lo Pointer to start of range.
1151 * @param __hi Pointer to end of range.
1152 * @param __dfault Char to use if conversion fails.
1153 * @param __to Pointer to the destination array.
1156 virtual const char_type
*
1157 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
1158 char __dfault
__attribute__((__unused__
)), char* __to
) const
1160 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
1165 void _M_narrow_init() const;
1166 void _M_widen_init() const;
1169 #ifdef _GLIBCXX_USE_WCHAR_T
1171 * @brief The ctype<wchar_t> specialization.
1174 * This class defines classification and conversion functions for the
1175 * wchar_t type. It gets used by wchar_t streams for many I/O operations.
1176 * The wchar_t specialization provides a number of optimizations as well.
1178 * ctype<wchar_t> inherits its public methods from
1179 * __ctype_abstract_base<wchar_t>.
1182 class ctype
<wchar_t> : public __ctype_abstract_base
<wchar_t>
1186 /// Typedef for the template parameter wchar_t.
1187 typedef wchar_t char_type
;
1188 typedef wctype_t __wmask_type
;
1191 __c_locale _M_c_locale_ctype
;
1193 // Pre-computed narrowed and widened chars.
1195 char _M_narrow
[128];
1196 wint_t _M_widen
[1 + static_cast<unsigned char>(-1)];
1198 // Pre-computed elements for do_is.
1200 __wmask_type _M_wmask
[16];
1204 /// The facet id for ctype<wchar_t>
1205 static locale::id id
;
1208 * @brief Constructor performs initialization.
1210 * This is the constructor provided by the standard.
1212 * @param __refs Passed to the base facet class.
1215 ctype(size_t __refs
= 0);
1218 * @brief Constructor performs static initialization.
1220 * This constructor is used to construct the initial C locale facet.
1222 * @param __cloc Handle to C locale data.
1223 * @param __refs Passed to the base facet class.
1226 ctype(__c_locale __cloc
, size_t __refs
= 0);
1230 _M_convert_to_wmask(const mask __m
) const throw();
1237 * @brief Test wchar_t classification.
1239 * This function finds a mask M for @a c and compares it to mask @a m.
1241 * do_is() is a hook for a derived facet to change the behavior of
1242 * classifying. do_is() must always return the same result for the
1245 * @param __c The wchar_t to find the mask of.
1246 * @param __m The mask to compare against.
1247 * @return (M & __m) != 0.
1250 do_is(mask __m
, char_type __c
) const;
1253 * @brief Return a mask array.
1255 * This function finds the mask for each wchar_t in the range [lo,hi)
1256 * and successively writes it to vec. vec must have as many elements
1259 * do_is() is a hook for a derived facet to change the behavior of
1260 * classifying. do_is() must always return the same result for the
1263 * @param __lo Pointer to start of range.
1264 * @param __hi Pointer to end of range.
1265 * @param __vec Pointer to an array of mask storage.
1268 virtual const char_type
*
1269 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
1272 * @brief Find wchar_t matching mask
1274 * This function searches for and returns the first wchar_t c in
1275 * [__lo,__hi) for which is(__m,c) is true.
1277 * do_scan_is() is a hook for a derived facet to change the behavior of
1278 * match searching. do_is() must always return the same result for the
1281 * @param __m The mask to compare against.
1282 * @param __lo Pointer to start of range.
1283 * @param __hi Pointer to end of range.
1284 * @return Pointer to a matching wchar_t if found, else @a __hi.
1286 virtual const char_type
*
1287 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
1290 * @brief Find wchar_t not matching mask
1292 * This function searches for and returns a pointer to the first
1293 * wchar_t c of [__lo,__hi) for which is(__m,c) is false.
1295 * do_scan_is() is a hook for a derived facet to change the behavior of
1296 * match searching. do_is() must always return the same result for the
1299 * @param __m The mask to compare against.
1300 * @param __lo Pointer to start of range.
1301 * @param __hi Pointer to end of range.
1302 * @return Pointer to a non-matching wchar_t if found, else @a __hi.
1304 virtual const char_type
*
1305 do_scan_not(mask __m
, const char_type
* __lo
,
1306 const char_type
* __hi
) const;
1309 * @brief Convert to uppercase.
1311 * This virtual function converts the wchar_t argument to uppercase if
1312 * possible. If not possible (for example, '2'), returns the argument.
1314 * do_toupper() is a hook for a derived facet to change the behavior of
1315 * uppercasing. do_toupper() must always return the same result for
1318 * @param __c The wchar_t to convert.
1319 * @return The uppercase wchar_t if convertible, else @a __c.
1322 do_toupper(char_type __c
) const;
1325 * @brief Convert array to uppercase.
1327 * This virtual function converts each wchar_t in the range [lo,hi) to
1328 * uppercase if possible. Other elements remain untouched.
1330 * do_toupper() is a hook for a derived facet to change the behavior of
1331 * uppercasing. do_toupper() must always return the same result for
1334 * @param __lo Pointer to start of range.
1335 * @param __hi Pointer to end of range.
1338 virtual const char_type
*
1339 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
1342 * @brief Convert to lowercase.
1344 * This virtual function converts the argument to lowercase if
1345 * possible. If not possible (for example, '2'), returns the argument.
1347 * do_tolower() is a hook for a derived facet to change the behavior of
1348 * lowercasing. do_tolower() must always return the same result for
1351 * @param __c The wchar_t to convert.
1352 * @return The lowercase wchar_t if convertible, else @a __c.
1355 do_tolower(char_type __c
) const;
1358 * @brief Convert array to lowercase.
1360 * This virtual function converts each wchar_t in the range [lo,hi) to
1361 * lowercase if possible. Other elements remain untouched.
1363 * do_tolower() is a hook for a derived facet to change the behavior of
1364 * lowercasing. do_tolower() must always return the same result for
1367 * @param __lo Pointer to start of range.
1368 * @param __hi Pointer to end of range.
1371 virtual const char_type
*
1372 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
1375 * @brief Widen char to wchar_t
1377 * This virtual function converts the char to wchar_t using the
1378 * simplest reasonable transformation. For an underived ctype<wchar_t>
1379 * facet, the argument will be cast to wchar_t.
1381 * do_widen() is a hook for a derived facet to change the behavior of
1382 * widening. do_widen() must always return the same result for the
1385 * Note: this is not what you want for codepage conversions. See
1388 * @param __c The char to convert.
1389 * @return The converted wchar_t.
1392 do_widen(char __c
) const;
1395 * @brief Widen char array to wchar_t array
1397 * This function converts each char in the input to wchar_t using the
1398 * simplest reasonable transformation. For an underived ctype<wchar_t>
1399 * facet, the argument will be copied, casting each element to wchar_t.
1401 * do_widen() is a hook for a derived facet to change the behavior of
1402 * widening. do_widen() must always return the same result for the
1405 * Note: this is not what you want for codepage conversions. See
1408 * @param __lo Pointer to start range.
1409 * @param __hi Pointer to end of range.
1410 * @param __to Pointer to the destination array.
1414 do_widen(const char* __lo
, const char* __hi
, char_type
* __to
) const;
1417 * @brief Narrow wchar_t to char
1419 * This virtual function converts the argument to char using
1420 * the simplest reasonable transformation. If the conversion
1421 * fails, dfault is returned instead. For an underived
1422 * ctype<wchar_t> facet, @a c will be cast to char and
1425 * do_narrow() is a hook for a derived facet to change the
1426 * behavior of narrowing. do_narrow() must always return the
1427 * same result for the same input.
1429 * Note: this is not what you want for codepage conversions. See
1432 * @param __c The wchar_t to convert.
1433 * @param __dfault Char to return if conversion fails.
1434 * @return The converted char.
1437 do_narrow(char_type __c
, char __dfault
) const;
1440 * @brief Narrow wchar_t array to char array
1442 * This virtual function converts each wchar_t in the range [lo,hi) to
1443 * char using the simplest reasonable transformation and writes the
1444 * results to the destination array. For any wchar_t in the input that
1445 * cannot be converted, @a dfault is used instead. For an underived
1446 * ctype<wchar_t> facet, the argument will be copied, casting each
1449 * do_narrow() is a hook for a derived facet to change the behavior of
1450 * narrowing. do_narrow() must always return the same result for the
1453 * Note: this is not what you want for codepage conversions. See
1456 * @param __lo Pointer to start of range.
1457 * @param __hi Pointer to end of range.
1458 * @param __dfault Char to use if conversion fails.
1459 * @param __to Pointer to the destination array.
1462 virtual const char_type
*
1463 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
1464 char __dfault
, char* __to
) const;
1466 // For use at construction time only.
1468 _M_initialize_ctype() throw();
1470 #endif //_GLIBCXX_USE_WCHAR_T
1472 /// class ctype_byname [22.2.1.2].
1473 template<typename _CharT
>
1474 class ctype_byname
: public ctype
<_CharT
>
1477 typedef typename ctype
<_CharT
>::mask mask
;
1480 ctype_byname(const char* __s
, size_t __refs
= 0);
1482 #if __cplusplus >= 201103L
1484 ctype_byname(const string
& __s
, size_t __refs
= 0)
1485 : ctype_byname(__s
.c_str(), __refs
) { }
1493 /// 22.2.1.4 Class ctype_byname specializations.
1495 class ctype_byname
<char> : public ctype
<char>
1499 ctype_byname(const char* __s
, size_t __refs
= 0);
1501 #if __cplusplus >= 201103L
1503 ctype_byname(const string
& __s
, size_t __refs
= 0);
1511 #ifdef _GLIBCXX_USE_WCHAR_T
1513 class ctype_byname
<wchar_t> : public ctype
<wchar_t>
1517 ctype_byname(const char* __s
, size_t __refs
= 0);
1519 #if __cplusplus >= 201103L
1521 ctype_byname(const string
& __s
, size_t __refs
= 0);
1530 _GLIBCXX_END_NAMESPACE_VERSION
1533 // Include host and configuration specific ctype inlines.
1534 #include <bits/ctype_inline.h>
1536 namespace std
_GLIBCXX_VISIBILITY(default)
1538 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1540 // 22.2.2 The numeric category.
1544 // NB: Code depends on the order of _S_atoms_out elements.
1545 // Below are the indices into _S_atoms_out.
1553 _S_odigits_end
= _S_odigits
+ 16,
1554 _S_oudigits
= _S_odigits_end
,
1555 _S_oudigits_end
= _S_oudigits
+ 16,
1556 _S_oe
= _S_odigits
+ 14, // For scientific notation, 'e'
1557 _S_oE
= _S_oudigits
+ 14, // For scientific notation, 'E'
1558 _S_oend
= _S_oudigits_end
1561 // A list of valid numeric literals for output. This array
1562 // contains chars that will be passed through the current locale's
1563 // ctype<_CharT>.widen() and then used to render numbers.
1564 // For the standard "C" locale, this is
1565 // "-+xX0123456789abcdef0123456789ABCDEF".
1566 static const char* _S_atoms_out
;
1568 // String literal of acceptable (narrow) input, for num_get.
1569 // "-+xX0123456789abcdefABCDEF"
1570 static const char* _S_atoms_in
;
1579 _S_ie
= _S_izero
+ 14,
1580 _S_iE
= _S_izero
+ 20,
1585 // Construct and return valid scanf format for floating point types.
1587 _S_format_float(const ios_base
& __io
, char* __fptr
, char __mod
) throw();
1590 template<typename _CharT
>
1591 struct __numpunct_cache
: public locale::facet
1593 const char* _M_grouping
;
1594 size_t _M_grouping_size
;
1595 bool _M_use_grouping
;
1596 const _CharT
* _M_truename
;
1597 size_t _M_truename_size
;
1598 const _CharT
* _M_falsename
;
1599 size_t _M_falsename_size
;
1600 _CharT _M_decimal_point
;
1601 _CharT _M_thousands_sep
;
1603 // A list of valid numeric literals for output: in the standard
1604 // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
1605 // This array contains the chars after having been passed
1606 // through the current locale's ctype<_CharT>.widen().
1607 _CharT _M_atoms_out
[__num_base::_S_oend
];
1609 // A list of valid numeric literals for input: in the standard
1610 // "C" locale, this is "-+xX0123456789abcdefABCDEF"
1611 // This array contains the chars after having been passed
1612 // through the current locale's ctype<_CharT>.widen().
1613 _CharT _M_atoms_in
[__num_base::_S_iend
];
1617 __numpunct_cache(size_t __refs
= 0)
1618 : facet(__refs
), _M_grouping(0), _M_grouping_size(0),
1619 _M_use_grouping(false),
1620 _M_truename(0), _M_truename_size(0), _M_falsename(0),
1621 _M_falsename_size(0), _M_decimal_point(_CharT()),
1622 _M_thousands_sep(_CharT()), _M_allocated(false)
1625 ~__numpunct_cache();
1628 _M_cache(const locale
& __loc
);
1632 operator=(const __numpunct_cache
&);
1635 __numpunct_cache(const __numpunct_cache
&);
1638 template<typename _CharT
>
1639 __numpunct_cache
<_CharT
>::~__numpunct_cache()
1643 delete [] _M_grouping
;
1644 delete [] _M_truename
;
1645 delete [] _M_falsename
;
1649 _GLIBCXX_BEGIN_NAMESPACE_CXX11
1652 * @brief Primary class template numpunct.
1655 * This facet stores several pieces of information related to printing and
1656 * scanning numbers, such as the decimal point character. It takes a
1657 * template parameter specifying the char type. The numpunct facet is
1658 * used by streams for many I/O operations involving numbers.
1660 * The numpunct template uses protected virtual functions to provide the
1661 * actual results. The public accessors forward the call to the virtual
1662 * functions. These virtual functions are hooks for developers to
1663 * implement the behavior they require from a numpunct facet.
1665 template<typename _CharT
>
1666 class numpunct
: public locale::facet
1672 typedef _CharT char_type
;
1673 typedef basic_string
<_CharT
> string_type
;
1675 typedef __numpunct_cache
<_CharT
> __cache_type
;
1678 __cache_type
* _M_data
;
1681 /// Numpunct facet id.
1682 static locale::id id
;
1685 * @brief Numpunct constructor.
1687 * @param __refs Refcount to pass to the base class.
1690 numpunct(size_t __refs
= 0)
1691 : facet(__refs
), _M_data(0)
1692 { _M_initialize_numpunct(); }
1695 * @brief Internal constructor. Not for general use.
1697 * This is a constructor for use by the library itself to set up the
1698 * predefined locale facets.
1700 * @param __cache __numpunct_cache object.
1701 * @param __refs Refcount to pass to the base class.
1704 numpunct(__cache_type
* __cache
, size_t __refs
= 0)
1705 : facet(__refs
), _M_data(__cache
)
1706 { _M_initialize_numpunct(); }
1709 * @brief Internal constructor. Not for general use.
1711 * This is a constructor for use by the library itself to set up new
1714 * @param __cloc The C locale.
1715 * @param __refs Refcount to pass to the base class.
1718 numpunct(__c_locale __cloc
, size_t __refs
= 0)
1719 : facet(__refs
), _M_data(0)
1720 { _M_initialize_numpunct(__cloc
); }
1723 * @brief Return decimal point character.
1725 * This function returns a char_type to use as a decimal point. It
1726 * does so by returning returning
1727 * numpunct<char_type>::do_decimal_point().
1729 * @return @a char_type representing a decimal point.
1732 decimal_point() const
1733 { return this->do_decimal_point(); }
1736 * @brief Return thousands separator character.
1738 * This function returns a char_type to use as a thousands
1739 * separator. It does so by returning returning
1740 * numpunct<char_type>::do_thousands_sep().
1742 * @return char_type representing a thousands separator.
1745 thousands_sep() const
1746 { return this->do_thousands_sep(); }
1749 * @brief Return grouping specification.
1751 * This function returns a string representing groupings for the
1752 * integer part of a number. Groupings indicate where thousands
1753 * separators should be inserted in the integer part of a number.
1755 * Each char in the return string is interpret as an integer
1756 * rather than a character. These numbers represent the number
1757 * of digits in a group. The first char in the string
1758 * represents the number of digits in the least significant
1759 * group. If a char is negative, it indicates an unlimited
1760 * number of digits for the group. If more chars from the
1761 * string are required to group a number, the last char is used
1764 * For example, if the grouping() returns "\003\002" and is
1765 * applied to the number 123456789, this corresponds to
1766 * 12,34,56,789. Note that if the string was "32", this would
1767 * put more than 50 digits into the least significant group if
1768 * the character set is ASCII.
1770 * The string is returned by calling
1771 * numpunct<char_type>::do_grouping().
1773 * @return string representing grouping specification.
1777 { return this->do_grouping(); }
1780 * @brief Return string representation of bool true.
1782 * This function returns a string_type containing the text
1783 * representation for true bool variables. It does so by calling
1784 * numpunct<char_type>::do_truename().
1786 * @return string_type representing printed form of true.
1790 { return this->do_truename(); }
1793 * @brief Return string representation of bool false.
1795 * This function returns a string_type containing the text
1796 * representation for false bool variables. It does so by calling
1797 * numpunct<char_type>::do_falsename().
1799 * @return string_type representing printed form of false.
1803 { return this->do_falsename(); }
1811 * @brief Return decimal point character.
1813 * Returns a char_type to use as a decimal point. This function is a
1814 * hook for derived classes to change the value returned.
1816 * @return @a char_type representing a decimal point.
1819 do_decimal_point() const
1820 { return _M_data
->_M_decimal_point
; }
1823 * @brief Return thousands separator character.
1825 * Returns a char_type to use as a thousands separator. This function
1826 * is a hook for derived classes to change the value returned.
1828 * @return @a char_type representing a thousands separator.
1831 do_thousands_sep() const
1832 { return _M_data
->_M_thousands_sep
; }
1835 * @brief Return grouping specification.
1837 * Returns a string representing groupings for the integer part of a
1838 * number. This function is a hook for derived classes to change the
1839 * value returned. @see grouping() for details.
1841 * @return String representing grouping specification.
1845 { return _M_data
->_M_grouping
; }
1848 * @brief Return string representation of bool true.
1850 * Returns a string_type containing the text representation for true
1851 * bool variables. This function is a hook for derived classes to
1852 * change the value returned.
1854 * @return string_type representing printed form of true.
1858 { return _M_data
->_M_truename
; }
1861 * @brief Return string representation of bool false.
1863 * Returns a string_type containing the text representation for false
1864 * bool variables. This function is a hook for derived classes to
1865 * change the value returned.
1867 * @return string_type representing printed form of false.
1870 do_falsename() const
1871 { return _M_data
->_M_falsename
; }
1873 // For use at construction time only.
1875 _M_initialize_numpunct(__c_locale __cloc
= 0);
1878 template<typename _CharT
>
1879 locale::id numpunct
<_CharT
>::id
;
1882 numpunct
<char>::~numpunct();
1886 numpunct
<char>::_M_initialize_numpunct(__c_locale __cloc
);
1888 #ifdef _GLIBCXX_USE_WCHAR_T
1890 numpunct
<wchar_t>::~numpunct();
1894 numpunct
<wchar_t>::_M_initialize_numpunct(__c_locale __cloc
);
1897 /// class numpunct_byname [22.2.3.2].
1898 template<typename _CharT
>
1899 class numpunct_byname
: public numpunct
<_CharT
>
1902 typedef _CharT char_type
;
1903 typedef basic_string
<_CharT
> string_type
;
1906 numpunct_byname(const char* __s
, size_t __refs
= 0)
1907 : numpunct
<_CharT
>(__refs
)
1909 if (__builtin_strcmp(__s
, "C") != 0
1910 && __builtin_strcmp(__s
, "POSIX") != 0)
1913 this->_S_create_c_locale(__tmp
, __s
);
1914 this->_M_initialize_numpunct(__tmp
);
1915 this->_S_destroy_c_locale(__tmp
);
1919 #if __cplusplus >= 201103L
1921 numpunct_byname(const string
& __s
, size_t __refs
= 0)
1922 : numpunct_byname(__s
.c_str(), __refs
) { }
1927 ~numpunct_byname() { }
1930 _GLIBCXX_END_NAMESPACE_CXX11
1932 _GLIBCXX_BEGIN_NAMESPACE_LDBL
1935 * @brief Primary class template num_get.
1938 * This facet encapsulates the code to parse and return a number
1939 * from a string. It is used by the istream numeric extraction
1942 * The num_get template uses protected virtual functions to provide the
1943 * actual results. The public accessors forward the call to the virtual
1944 * functions. These virtual functions are hooks for developers to
1945 * implement the behavior they require from the num_get facet.
1947 template<typename _CharT
, typename _InIter
>
1948 class num_get
: public locale::facet
1954 typedef _CharT char_type
;
1955 typedef _InIter iter_type
;
1958 /// Numpunct facet id.
1959 static locale::id id
;
1962 * @brief Constructor performs initialization.
1964 * This is the constructor provided by the standard.
1966 * @param __refs Passed to the base facet class.
1969 num_get(size_t __refs
= 0) : facet(__refs
) { }
1972 * @brief Numeric parsing.
1974 * Parses the input stream into the bool @a v. It does so by calling
1975 * num_get::do_get().
1977 * If ios_base::boolalpha is set, attempts to read
1978 * ctype<CharT>::truename() or ctype<CharT>::falsename(). Sets
1979 * @a v to true or false if successful. Sets err to
1980 * ios_base::failbit if reading the string fails. Sets err to
1981 * ios_base::eofbit if the stream is emptied.
1983 * If ios_base::boolalpha is not set, proceeds as with reading a long,
1984 * except if the value is 1, sets @a v to true, if the value is 0, sets
1985 * @a v to false, and otherwise set err to ios_base::failbit.
1987 * @param __in Start of input stream.
1988 * @param __end End of input stream.
1989 * @param __io Source of locale and flags.
1990 * @param __err Error flags to set.
1991 * @param __v Value to format and insert.
1992 * @return Iterator after reading.
1995 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
1996 ios_base::iostate
& __err
, bool& __v
) const
1997 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2001 * @brief Numeric parsing.
2003 * Parses the input stream into the integral variable @a v. It does so
2004 * by calling num_get::do_get().
2006 * Parsing is affected by the flag settings in @a io.
2008 * The basic parse is affected by the value of io.flags() &
2009 * ios_base::basefield. If equal to ios_base::oct, parses like the
2010 * scanf %o specifier. Else if equal to ios_base::hex, parses like %X
2011 * specifier. Else if basefield equal to 0, parses like the %i
2012 * specifier. Otherwise, parses like %d for signed and %u for unsigned
2013 * types. The matching type length modifier is also used.
2015 * Digit grouping is interpreted according to
2016 * numpunct::grouping() and numpunct::thousands_sep(). If the
2017 * pattern of digit groups isn't consistent, sets err to
2018 * ios_base::failbit.
2020 * If parsing the string yields a valid value for @a v, @a v is set.
2021 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2022 * Sets err to ios_base::eofbit if the stream is emptied.
2024 * @param __in Start of input stream.
2025 * @param __end End of input stream.
2026 * @param __io Source of locale and flags.
2027 * @param __err Error flags to set.
2028 * @param __v Value to format and insert.
2029 * @return Iterator after reading.
2032 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2033 ios_base::iostate
& __err
, long& __v
) const
2034 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2037 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2038 ios_base::iostate
& __err
, unsigned short& __v
) const
2039 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2042 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2043 ios_base::iostate
& __err
, unsigned int& __v
) const
2044 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2047 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2048 ios_base::iostate
& __err
, unsigned long& __v
) const
2049 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2051 #ifdef _GLIBCXX_USE_LONG_LONG
2053 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2054 ios_base::iostate
& __err
, long long& __v
) const
2055 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2058 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2059 ios_base::iostate
& __err
, unsigned long long& __v
) const
2060 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2066 * @brief Numeric parsing.
2068 * Parses the input stream into the integral variable @a v. It does so
2069 * by calling num_get::do_get().
2071 * The input characters are parsed like the scanf %g specifier. The
2072 * matching type length modifier is also used.
2074 * The decimal point character used is numpunct::decimal_point().
2075 * Digit grouping is interpreted according to
2076 * numpunct::grouping() and numpunct::thousands_sep(). If the
2077 * pattern of digit groups isn't consistent, sets err to
2078 * ios_base::failbit.
2080 * If parsing the string yields a valid value for @a v, @a v is set.
2081 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2082 * Sets err to ios_base::eofbit if the stream is emptied.
2084 * @param __in Start of input stream.
2085 * @param __end End of input stream.
2086 * @param __io Source of locale and flags.
2087 * @param __err Error flags to set.
2088 * @param __v Value to format and insert.
2089 * @return Iterator after reading.
2092 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2093 ios_base::iostate
& __err
, float& __v
) const
2094 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2097 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2098 ios_base::iostate
& __err
, double& __v
) const
2099 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2102 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2103 ios_base::iostate
& __err
, long double& __v
) const
2104 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2108 * @brief Numeric parsing.
2110 * Parses the input stream into the pointer variable @a v. It does so
2111 * by calling num_get::do_get().
2113 * The input characters are parsed like the scanf %p specifier.
2115 * Digit grouping is interpreted according to
2116 * numpunct::grouping() and numpunct::thousands_sep(). If the
2117 * pattern of digit groups isn't consistent, sets err to
2118 * ios_base::failbit.
2120 * Note that the digit grouping effect for pointers is a bit ambiguous
2121 * in the standard and shouldn't be relied on. See DR 344.
2123 * If parsing the string yields a valid value for @a v, @a v is set.
2124 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2125 * Sets err to ios_base::eofbit if the stream is emptied.
2127 * @param __in Start of input stream.
2128 * @param __end End of input stream.
2129 * @param __io Source of locale and flags.
2130 * @param __err Error flags to set.
2131 * @param __v Value to format and insert.
2132 * @return Iterator after reading.
2135 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2136 ios_base::iostate
& __err
, void*& __v
) const
2137 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2141 virtual ~num_get() { }
2143 _GLIBCXX_DEFAULT_ABI_TAG
2145 _M_extract_float(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2148 template<typename _ValueT
>
2149 _GLIBCXX_DEFAULT_ABI_TAG
2151 _M_extract_int(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2154 template<typename _CharT2
>
2155 typename
__gnu_cxx::__enable_if
<__is_char
<_CharT2
>::__value
, int>::__type
2156 _M_find(const _CharT2
*, size_t __len
, _CharT2 __c
) const
2161 if (__c
>= _CharT2('0') && __c
< _CharT2(_CharT2('0') + __len
))
2162 __ret
= __c
- _CharT2('0');
2166 if (__c
>= _CharT2('0') && __c
<= _CharT2('9'))
2167 __ret
= __c
- _CharT2('0');
2168 else if (__c
>= _CharT2('a') && __c
<= _CharT2('f'))
2169 __ret
= 10 + (__c
- _CharT2('a'));
2170 else if (__c
>= _CharT2('A') && __c
<= _CharT2('F'))
2171 __ret
= 10 + (__c
- _CharT2('A'));
2176 template<typename _CharT2
>
2177 typename
__gnu_cxx::__enable_if
<!__is_char
<_CharT2
>::__value
,
2179 _M_find(const _CharT2
* __zero
, size_t __len
, _CharT2 __c
) const
2182 const char_type
* __q
= char_traits
<_CharT2
>::find(__zero
, __len
, __c
);
2185 __ret
= __q
- __zero
;
2194 * @brief Numeric parsing.
2196 * Parses the input stream into the variable @a v. This function is a
2197 * hook for derived classes to change the value returned. @see get()
2200 * @param __beg Start of input stream.
2201 * @param __end End of input stream.
2202 * @param __io Source of locale and flags.
2203 * @param __err Error flags to set.
2204 * @param __v Value to format and insert.
2205 * @return Iterator after reading.
2208 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, bool&) const;
2211 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2212 ios_base::iostate
& __err
, long& __v
) const
2213 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2216 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2217 ios_base::iostate
& __err
, unsigned short& __v
) const
2218 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2221 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2222 ios_base::iostate
& __err
, unsigned int& __v
) const
2223 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2226 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2227 ios_base::iostate
& __err
, unsigned long& __v
) const
2228 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2230 #ifdef _GLIBCXX_USE_LONG_LONG
2232 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2233 ios_base::iostate
& __err
, long long& __v
) const
2234 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2237 do_get(iter_type __beg
, iter_type __end
, ios_base
& __io
,
2238 ios_base::iostate
& __err
, unsigned long long& __v
) const
2239 { return _M_extract_int(__beg
, __end
, __io
, __err
, __v
); }
2243 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, float&) const;
2246 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2249 // XXX GLIBCXX_ABI Deprecated
2250 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2252 __do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2256 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2257 long double&) const;
2261 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, void*&) const;
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
&,
2267 long double&) const;
2272 template<typename _CharT
, typename _InIter
>
2273 locale::id num_get
<_CharT
, _InIter
>::id
;
2277 * @brief Primary class template num_put.
2280 * This facet encapsulates the code to convert a number to a string. It is
2281 * used by the ostream numeric insertion operators.
2283 * The num_put template uses protected virtual functions to provide the
2284 * actual results. The public accessors forward the call to the virtual
2285 * functions. These virtual functions are hooks for developers to
2286 * implement the behavior they require from the num_put facet.
2288 template<typename _CharT
, typename _OutIter
>
2289 class num_put
: public locale::facet
2295 typedef _CharT char_type
;
2296 typedef _OutIter iter_type
;
2299 /// Numpunct facet id.
2300 static locale::id id
;
2303 * @brief Constructor performs initialization.
2305 * This is the constructor provided by the standard.
2307 * @param __refs Passed to the base facet class.
2310 num_put(size_t __refs
= 0) : facet(__refs
) { }
2313 * @brief Numeric formatting.
2315 * Formats the boolean @a v and inserts it into a stream. It does so
2316 * by calling num_put::do_put().
2318 * If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
2319 * ctype<CharT>::falsename(). Otherwise formats @a v as an int.
2321 * @param __s Stream to write to.
2322 * @param __io Source of locale and flags.
2323 * @param __fill Char_type to use for filling.
2324 * @param __v Value to format and insert.
2325 * @return Iterator after writing.
2328 put(iter_type __s
, ios_base
& __io
, char_type __fill
, bool __v
) const
2329 { return this->do_put(__s
, __io
, __fill
, __v
); }
2333 * @brief Numeric formatting.
2335 * Formats the integral value @a v and inserts it into a
2336 * stream. It does so by calling num_put::do_put().
2338 * Formatting is affected by the flag settings in @a io.
2340 * The basic format is affected by the value of io.flags() &
2341 * ios_base::basefield. If equal to ios_base::oct, formats like the
2342 * printf %o specifier. Else if equal to ios_base::hex, formats like
2343 * %x or %X with ios_base::uppercase unset or set respectively.
2344 * Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
2345 * for unsigned values. Note that if both oct and hex are set, neither
2348 * If ios_base::showpos is set, '+' is output before positive values.
2349 * If ios_base::showbase is set, '0' precedes octal values (except 0)
2350 * and '0[xX]' precedes hex values.
2352 * The decimal point character used is numpunct::decimal_point().
2353 * Thousands separators are inserted according to
2354 * numpunct::grouping() and numpunct::thousands_sep().
2356 * If io.width() is non-zero, enough @a fill characters are inserted to
2357 * make the result at least that wide. If
2358 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2359 * padded at the end. If ios_base::internal, then padding occurs
2360 * immediately after either a '+' or '-' or after '0x' or '0X'.
2361 * Otherwise, padding occurs at the beginning.
2363 * @param __s Stream to write to.
2364 * @param __io Source of locale and flags.
2365 * @param __fill Char_type to use for filling.
2366 * @param __v Value to format and insert.
2367 * @return Iterator after writing.
2370 put(iter_type __s
, ios_base
& __io
, char_type __fill
, long __v
) const
2371 { return this->do_put(__s
, __io
, __fill
, __v
); }
2374 put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2375 unsigned long __v
) const
2376 { return this->do_put(__s
, __io
, __fill
, __v
); }
2378 #ifdef _GLIBCXX_USE_LONG_LONG
2380 put(iter_type __s
, ios_base
& __io
, char_type __fill
, long long __v
) const
2381 { return this->do_put(__s
, __io
, __fill
, __v
); }
2384 put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2385 unsigned long long __v
) const
2386 { return this->do_put(__s
, __io
, __fill
, __v
); }
2392 * @brief Numeric formatting.
2394 * Formats the floating point value @a v and inserts it into a stream.
2395 * It does so by calling num_put::do_put().
2397 * Formatting is affected by the flag settings in @a io.
2399 * The basic format is affected by the value of io.flags() &
2400 * ios_base::floatfield. If equal to ios_base::fixed, formats like the
2401 * printf %f specifier. Else if equal to ios_base::scientific, formats
2402 * like %e or %E with ios_base::uppercase unset or set respectively.
2403 * Otherwise, formats like %g or %G depending on uppercase. Note that
2404 * if both fixed and scientific are set, the effect will also be like
2407 * The output precision is given by io.precision(). This precision is
2408 * capped at numeric_limits::digits10 + 2 (different for double and
2409 * long double). The default precision is 6.
2411 * If ios_base::showpos is set, '+' is output before positive values.
2412 * If ios_base::showpoint is set, a decimal point will always be
2415 * The decimal point character used is numpunct::decimal_point().
2416 * Thousands separators are inserted according to
2417 * numpunct::grouping() and numpunct::thousands_sep().
2419 * If io.width() is non-zero, enough @a fill characters are inserted to
2420 * make the result at least that wide. If
2421 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2422 * padded at the end. If ios_base::internal, then padding occurs
2423 * immediately after either a '+' or '-' or after '0x' or '0X'.
2424 * Otherwise, padding occurs at the beginning.
2426 * @param __s Stream to write to.
2427 * @param __io Source of locale and flags.
2428 * @param __fill Char_type to use for filling.
2429 * @param __v Value to format and insert.
2430 * @return Iterator after writing.
2433 put(iter_type __s
, ios_base
& __io
, char_type __fill
, double __v
) const
2434 { return this->do_put(__s
, __io
, __fill
, __v
); }
2437 put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2438 long double __v
) const
2439 { return this->do_put(__s
, __io
, __fill
, __v
); }
2443 * @brief Numeric formatting.
2445 * Formats the pointer value @a v and inserts it into a stream. It
2446 * does so by calling num_put::do_put().
2448 * This function formats @a v as an unsigned long with ios_base::hex
2449 * and ios_base::showbase set.
2451 * @param __s Stream to write to.
2452 * @param __io Source of locale and flags.
2453 * @param __fill Char_type to use for filling.
2454 * @param __v Value to format and insert.
2455 * @return Iterator after writing.
2458 put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2459 const void* __v
) const
2460 { return this->do_put(__s
, __io
, __fill
, __v
); }
2463 template<typename _ValueT
>
2465 _M_insert_float(iter_type
, ios_base
& __io
, char_type __fill
,
2466 char __mod
, _ValueT __v
) const;
2469 _M_group_float(const char* __grouping
, size_t __grouping_size
,
2470 char_type __sep
, const char_type
* __p
, char_type
* __new
,
2471 char_type
* __cs
, int& __len
) const;
2473 template<typename _ValueT
>
2475 _M_insert_int(iter_type
, ios_base
& __io
, char_type __fill
,
2479 _M_group_int(const char* __grouping
, size_t __grouping_size
,
2480 char_type __sep
, ios_base
& __io
, char_type
* __new
,
2481 char_type
* __cs
, int& __len
) const;
2484 _M_pad(char_type __fill
, streamsize __w
, ios_base
& __io
,
2485 char_type
* __new
, const char_type
* __cs
, int& __len
) const;
2493 * @brief Numeric formatting.
2495 * These functions do the work of formatting numeric values and
2496 * inserting them into a stream. This function is a hook for derived
2497 * classes to change the value returned.
2499 * @param __s Stream to write to.
2500 * @param __io Source of locale and flags.
2501 * @param __fill Char_type to use for filling.
2502 * @param __v Value to format and insert.
2503 * @return Iterator after writing.
2506 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
, bool __v
) const;
2509 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
, long __v
) const
2510 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2513 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2514 unsigned long __v
) const
2515 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2517 #ifdef _GLIBCXX_USE_LONG_LONG
2519 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2520 long long __v
) const
2521 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2524 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
,
2525 unsigned long long __v
) const
2526 { return _M_insert_int(__s
, __io
, __fill
, __v
); }
2530 do_put(iter_type
, ios_base
&, char_type
, double) const;
2532 // XXX GLIBCXX_ABI Deprecated
2533 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2535 __do_put(iter_type
, ios_base
&, char_type
, double) const;
2538 do_put(iter_type
, ios_base
&, char_type
, long double) const;
2542 do_put(iter_type
, ios_base
&, char_type
, const void*) const;
2544 // XXX GLIBCXX_ABI Deprecated
2545 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2547 do_put(iter_type
, ios_base
&, char_type
, long double) const;
2552 template <typename _CharT
, typename _OutIter
>
2553 locale::id num_put
<_CharT
, _OutIter
>::id
;
2555 _GLIBCXX_END_NAMESPACE_LDBL
2557 // Subclause convenience interfaces, inlines.
2558 // NB: These are inline because, when used in a loop, some compilers
2559 // can hoist the body out of the loop; then it's just as fast as the
2560 // C is*() function.
2562 /// Convenience interface to ctype.is(ctype_base::space, __c).
2563 template<typename _CharT
>
2565 isspace(_CharT __c
, const locale
& __loc
)
2566 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::space
, __c
); }
2568 /// Convenience interface to ctype.is(ctype_base::print, __c).
2569 template<typename _CharT
>
2571 isprint(_CharT __c
, const locale
& __loc
)
2572 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::print
, __c
); }
2574 /// Convenience interface to ctype.is(ctype_base::cntrl, __c).
2575 template<typename _CharT
>
2577 iscntrl(_CharT __c
, const locale
& __loc
)
2578 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::cntrl
, __c
); }
2580 /// Convenience interface to ctype.is(ctype_base::upper, __c).
2581 template<typename _CharT
>
2583 isupper(_CharT __c
, const locale
& __loc
)
2584 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::upper
, __c
); }
2586 /// Convenience interface to ctype.is(ctype_base::lower, __c).
2587 template<typename _CharT
>
2589 islower(_CharT __c
, const locale
& __loc
)
2590 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::lower
, __c
); }
2592 /// Convenience interface to ctype.is(ctype_base::alpha, __c).
2593 template<typename _CharT
>
2595 isalpha(_CharT __c
, const locale
& __loc
)
2596 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alpha
, __c
); }
2598 /// Convenience interface to ctype.is(ctype_base::digit, __c).
2599 template<typename _CharT
>
2601 isdigit(_CharT __c
, const locale
& __loc
)
2602 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::digit
, __c
); }
2604 /// Convenience interface to ctype.is(ctype_base::punct, __c).
2605 template<typename _CharT
>
2607 ispunct(_CharT __c
, const locale
& __loc
)
2608 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::punct
, __c
); }
2610 /// Convenience interface to ctype.is(ctype_base::xdigit, __c).
2611 template<typename _CharT
>
2613 isxdigit(_CharT __c
, const locale
& __loc
)
2614 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::xdigit
, __c
); }
2616 /// Convenience interface to ctype.is(ctype_base::alnum, __c).
2617 template<typename _CharT
>
2619 isalnum(_CharT __c
, const locale
& __loc
)
2620 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alnum
, __c
); }
2622 /// Convenience interface to ctype.is(ctype_base::graph, __c).
2623 template<typename _CharT
>
2625 isgraph(_CharT __c
, const locale
& __loc
)
2626 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::graph
, __c
); }
2628 #if __cplusplus >= 201103L
2629 /// Convenience interface to ctype.is(ctype_base::blank, __c).
2630 template<typename _CharT
>
2632 isblank(_CharT __c
, const locale
& __loc
)
2633 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::blank
, __c
); }
2636 /// Convenience interface to ctype.toupper(__c).
2637 template<typename _CharT
>
2639 toupper(_CharT __c
, const locale
& __loc
)
2640 { return use_facet
<ctype
<_CharT
> >(__loc
).toupper(__c
); }
2642 /// Convenience interface to ctype.tolower(__c).
2643 template<typename _CharT
>
2645 tolower(_CharT __c
, const locale
& __loc
)
2646 { return use_facet
<ctype
<_CharT
> >(__loc
).tolower(__c
); }
2648 _GLIBCXX_END_NAMESPACE_VERSION
2651 # include <bits/locale_facets.tcc>