1 // Locale support -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5 // Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 2, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING. If not, write to the Free
20 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 // As a special exception, you may use this file as part of a free software
24 // library without restriction. Specifically, if other files instantiate
25 // templates or use macros or inline functions from this file, or you compile
26 // this file and link it with other files to produce an executable, this
27 // file does not by itself cause the resulting executable to be covered by
28 // the GNU General Public License. This exception does not however
29 // invalidate any other reasons why the executable file might be covered by
30 // the GNU General Public License.
32 /** @file locale_facets.h
33 * This is an internal header file, included by other library headers.
34 * You should not attempt to use it directly.
38 // ISO C++ 14882: 22.1 Locales
41 #ifndef _LOCALE_FACETS_H
42 #define _LOCALE_FACETS_H 1
44 #pragma GCC system_header
46 #include <cwctype> // For wctype_t
48 #include <bits/ctype_base.h>
50 #include <bits/ios_base.h> // For ios_base, ios_base::iostate
52 #include <bits/cpp_type_traits.h>
53 #include <ext/type_traits.h>
54 #include <ext/numeric_traits.h>
55 #include <bits/streambuf_iterator.h>
57 _GLIBCXX_BEGIN_NAMESPACE(std
)
59 // NB: Don't instantiate required wchar_t facets if no wchar_t support.
60 #ifdef _GLIBCXX_USE_WCHAR_T
61 # define _GLIBCXX_NUM_FACETS 28
63 # define _GLIBCXX_NUM_FACETS 14
66 // Convert string to numeric value of type _Tv and store results.
67 // NB: This is specialized for all required types, there is no
68 // generic definition.
69 template<typename _Tv
>
71 __convert_to_v(const char* __in
, _Tv
& __out
, ios_base::iostate
& __err
,
72 const __c_locale
& __cloc
);
74 // Explicit specializations for required types.
77 __convert_to_v(const char*, float&, ios_base::iostate
&,
82 __convert_to_v(const char*, double&, ios_base::iostate
&,
87 __convert_to_v(const char*, long double&, ios_base::iostate
&,
90 // NB: __pad is a struct, rather than a function, so it can be
91 // partially-specialized.
92 template<typename _CharT
, typename _Traits
>
96 _S_pad(ios_base
& __io
, _CharT __fill
, _CharT
* __news
,
97 const _CharT
* __olds
, streamsize __newlen
, streamsize __oldlen
);
100 // Used by both numeric and monetary facets.
101 // Inserts "group separator" characters into an array of characters.
102 // It's recursive, one iteration per group. It moves the characters
103 // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
104 // only with __gsize != 0.
105 template<typename _CharT
>
107 __add_grouping(_CharT
* __s
, _CharT __sep
,
108 const char* __gbeg
, size_t __gsize
,
109 const _CharT
* __first
, const _CharT
* __last
);
111 // This template permits specializing facet output code for
112 // ostreambuf_iterator. For ostreambuf_iterator, sputn is
113 // significantly more efficient than incrementing iterators.
114 template<typename _CharT
>
116 ostreambuf_iterator
<_CharT
>
117 __write(ostreambuf_iterator
<_CharT
> __s
, const _CharT
* __ws
, int __len
)
119 __s
._M_put(__ws
, __len
);
123 // This is the unspecialized form of the template.
124 template<typename _CharT
, typename _OutIter
>
127 __write(_OutIter __s
, const _CharT
* __ws
, int __len
)
129 for (int __j
= 0; __j
< __len
; __j
++, ++__s
)
135 // 22.2.1.1 Template class ctype
136 // Include host and configuration specific ctype enums for ctype_base.
138 // Common base for ctype<_CharT>.
140 * @brief Common base for ctype facet
142 * This template class provides implementations of the public functions
143 * that forward to the protected virtual functions.
145 * This template also provides abstract stubs for the protected virtual
148 template<typename _CharT
>
149 class __ctype_abstract_base
: public locale::facet
, public ctype_base
153 /// Typedef for the template parameter
154 typedef _CharT char_type
;
157 * @brief Test char_type classification.
159 * This function finds a mask M for @a c and compares it to mask @a m.
160 * It does so by returning the value of ctype<char_type>::do_is().
162 * @param c The char_type to compare the mask of.
163 * @param m The mask to compare against.
164 * @return (M & m) != 0.
167 is(mask __m
, char_type __c
) const
168 { return this->do_is(__m
, __c
); }
171 * @brief Return a mask array.
173 * This function finds the mask for each char_type in the range [lo,hi)
174 * and successively writes it to vec. vec must have as many elements
175 * as the char array. It does so by returning the value of
176 * ctype<char_type>::do_is().
178 * @param lo Pointer to start of range.
179 * @param hi Pointer to end of range.
180 * @param vec Pointer to an array of mask storage.
184 is(const char_type
*__lo
, const char_type
*__hi
, mask
*__vec
) const
185 { return this->do_is(__lo
, __hi
, __vec
); }
188 * @brief Find char_type matching a mask
190 * This function searches for and returns the first char_type c in
191 * [lo,hi) for which is(m,c) is true. It does so by returning
192 * ctype<char_type>::do_scan_is().
194 * @param m The mask to compare against.
195 * @param lo Pointer to start of range.
196 * @param hi Pointer to end of range.
197 * @return Pointer to matching char_type if found, else @a hi.
200 scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
201 { return this->do_scan_is(__m
, __lo
, __hi
); }
204 * @brief Find char_type not matching a mask
206 * This function searches for and returns the first char_type c in
207 * [lo,hi) for which is(m,c) is false. It does so by returning
208 * ctype<char_type>::do_scan_not().
210 * @param m The mask to compare against.
211 * @param lo Pointer to first char in range.
212 * @param hi Pointer to end of range.
213 * @return Pointer to non-matching char if found, else @a hi.
216 scan_not(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
217 { return this->do_scan_not(__m
, __lo
, __hi
); }
220 * @brief Convert to uppercase.
222 * This function converts the argument to uppercase if possible.
223 * If not possible (for example, '2'), returns the argument. It does
224 * so by returning ctype<char_type>::do_toupper().
226 * @param c The char_type to convert.
227 * @return The uppercase char_type if convertible, else @a c.
230 toupper(char_type __c
) const
231 { return this->do_toupper(__c
); }
234 * @brief Convert array to uppercase.
236 * This function converts each char_type in the range [lo,hi) to
237 * uppercase if possible. Other elements remain untouched. It does so
238 * by returning ctype<char_type>:: do_toupper(lo, hi).
240 * @param lo Pointer to start of range.
241 * @param hi Pointer to end of range.
245 toupper(char_type
*__lo
, const char_type
* __hi
) const
246 { return this->do_toupper(__lo
, __hi
); }
249 * @brief Convert to lowercase.
251 * This function converts the argument to lowercase if possible. If
252 * not possible (for example, '2'), returns the argument. It does so
253 * by returning ctype<char_type>::do_tolower(c).
255 * @param c The char_type to convert.
256 * @return The lowercase char_type if convertible, else @a c.
259 tolower(char_type __c
) const
260 { return this->do_tolower(__c
); }
263 * @brief Convert array to lowercase.
265 * This function converts each char_type in the range [lo,hi) to
266 * lowercase if possible. Other elements remain untouched. It does so
267 * by returning ctype<char_type>:: do_tolower(lo, hi).
269 * @param lo Pointer to start of range.
270 * @param hi Pointer to end of range.
274 tolower(char_type
* __lo
, const char_type
* __hi
) const
275 { return this->do_tolower(__lo
, __hi
); }
278 * @brief Widen char to char_type
280 * This function converts the char argument to char_type using the
281 * simplest reasonable transformation. It does so by returning
282 * ctype<char_type>::do_widen(c).
284 * Note: this is not what you want for codepage conversions. See
287 * @param c The char to convert.
288 * @return The converted char_type.
291 widen(char __c
) const
292 { return this->do_widen(__c
); }
295 * @brief Widen array to char_type
297 * This function converts each char in the input to char_type using the
298 * simplest reasonable transformation. It does so by returning
299 * ctype<char_type>::do_widen(c).
301 * Note: this is not what you want for codepage conversions. See
304 * @param lo Pointer to start of range.
305 * @param hi Pointer to end of range.
306 * @param to Pointer to the destination array.
310 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
311 { return this->do_widen(__lo
, __hi
, __to
); }
314 * @brief Narrow char_type to char
316 * This function converts the char_type to char using the simplest
317 * reasonable transformation. If the conversion fails, dfault is
318 * returned instead. It does so by returning
319 * ctype<char_type>::do_narrow(c).
321 * Note: this is not what you want for codepage conversions. See
324 * @param c The char_type to convert.
325 * @param dfault Char to return if conversion fails.
326 * @return The converted char.
329 narrow(char_type __c
, char __dfault
) const
330 { return this->do_narrow(__c
, __dfault
); }
333 * @brief Narrow array to char array
335 * This function converts each char_type in the input to char using the
336 * simplest reasonable transformation and writes the results to the
337 * destination array. For any char_type in the input that cannot be
338 * converted, @a dfault is used instead. It does so by returning
339 * ctype<char_type>::do_narrow(lo, hi, dfault, to).
341 * Note: this is not what you want for codepage conversions. See
344 * @param lo Pointer to start of range.
345 * @param hi Pointer to end of range.
346 * @param dfault Char to use if conversion fails.
347 * @param to Pointer to the destination array.
351 narrow(const char_type
* __lo
, const char_type
* __hi
,
352 char __dfault
, char *__to
) const
353 { return this->do_narrow(__lo
, __hi
, __dfault
, __to
); }
357 __ctype_abstract_base(size_t __refs
= 0): facet(__refs
) { }
360 ~__ctype_abstract_base() { }
363 * @brief Test char_type classification.
365 * This function finds a mask M for @a c and compares it to mask @a m.
367 * do_is() is a hook for a derived facet to change the behavior of
368 * classifying. do_is() must always return the same result for the
371 * @param c The char_type to find the mask of.
372 * @param m The mask to compare against.
373 * @return (M & m) != 0.
376 do_is(mask __m
, char_type __c
) const = 0;
379 * @brief Return a mask array.
381 * This function finds the mask for each char_type in the range [lo,hi)
382 * and successively writes it to vec. vec must have as many elements
385 * do_is() is a hook for a derived facet to change the behavior of
386 * classifying. do_is() must always return the same result for the
389 * @param lo Pointer to start of range.
390 * @param hi Pointer to end of range.
391 * @param vec Pointer to an array of mask storage.
394 virtual const char_type
*
395 do_is(const char_type
* __lo
, const char_type
* __hi
,
396 mask
* __vec
) const = 0;
399 * @brief Find char_type matching mask
401 * This function searches for and returns the first char_type c in
402 * [lo,hi) for which is(m,c) is true.
404 * do_scan_is() is a hook for a derived facet to change the behavior of
405 * match searching. do_is() must always return the same result for the
408 * @param m The mask to compare against.
409 * @param lo Pointer to start of range.
410 * @param hi Pointer to end of range.
411 * @return Pointer to a matching char_type if found, else @a hi.
413 virtual const char_type
*
414 do_scan_is(mask __m
, const char_type
* __lo
,
415 const char_type
* __hi
) const = 0;
418 * @brief Find char_type not matching mask
420 * This function searches for and returns a pointer to the first
421 * char_type c of [lo,hi) for which is(m,c) is false.
423 * do_scan_is() is a hook for a derived facet to change the behavior of
424 * match searching. do_is() must always return the same result for the
427 * @param m The mask to compare against.
428 * @param lo Pointer to start of range.
429 * @param hi Pointer to end of range.
430 * @return Pointer to a non-matching char_type if found, else @a hi.
432 virtual const char_type
*
433 do_scan_not(mask __m
, const char_type
* __lo
,
434 const char_type
* __hi
) const = 0;
437 * @brief Convert to uppercase.
439 * This virtual function converts the char_type argument to uppercase
440 * if possible. If not possible (for example, '2'), returns the
443 * do_toupper() is a hook for a derived facet to change the behavior of
444 * uppercasing. do_toupper() must always return the same result for
447 * @param c The char_type to convert.
448 * @return The uppercase char_type if convertible, else @a c.
451 do_toupper(char_type
) const = 0;
454 * @brief Convert array to uppercase.
456 * This virtual function converts each char_type in the range [lo,hi)
457 * to uppercase if possible. Other elements remain untouched.
459 * do_toupper() is a hook for a derived facet to change the behavior of
460 * uppercasing. do_toupper() must always return the same result for
463 * @param lo Pointer to start of range.
464 * @param hi Pointer to end of range.
467 virtual const char_type
*
468 do_toupper(char_type
* __lo
, const char_type
* __hi
) const = 0;
471 * @brief Convert to lowercase.
473 * This virtual function converts the argument to lowercase if
474 * possible. If not possible (for example, '2'), returns the argument.
476 * do_tolower() is a hook for a derived facet to change the behavior of
477 * lowercasing. do_tolower() must always return the same result for
480 * @param c The char_type to convert.
481 * @return The lowercase char_type if convertible, else @a c.
484 do_tolower(char_type
) const = 0;
487 * @brief Convert array to lowercase.
489 * This virtual function converts each char_type in the range [lo,hi)
490 * to lowercase if possible. Other elements remain untouched.
492 * do_tolower() is a hook for a derived facet to change the behavior of
493 * lowercasing. do_tolower() must always return the same result for
496 * @param lo Pointer to start of range.
497 * @param hi Pointer to end of range.
500 virtual const char_type
*
501 do_tolower(char_type
* __lo
, const char_type
* __hi
) const = 0;
506 * This virtual function converts the char to char_type using the
507 * simplest reasonable transformation.
509 * do_widen() is a hook for a derived facet to change the behavior of
510 * widening. do_widen() must always return the same result for the
513 * Note: this is not what you want for codepage conversions. See
516 * @param c The char to convert.
517 * @return The converted char_type
520 do_widen(char) const = 0;
523 * @brief Widen char array
525 * This function converts each char in the input to char_type using the
526 * simplest reasonable transformation.
528 * do_widen() is a hook for a derived facet to change the behavior of
529 * widening. do_widen() must always return the same result for the
532 * Note: this is not what you want for codepage conversions. See
535 * @param lo Pointer to start range.
536 * @param hi Pointer to end of range.
537 * @param to Pointer to the destination array.
541 do_widen(const char* __lo
, const char* __hi
,
542 char_type
* __dest
) const = 0;
545 * @brief Narrow char_type to char
547 * This virtual function converts the argument to char using the
548 * simplest reasonable transformation. If the conversion fails, dfault
549 * is returned instead.
551 * do_narrow() is a hook for a derived facet to change the behavior of
552 * narrowing. do_narrow() must always return the same result for the
555 * Note: this is not what you want for codepage conversions. See
558 * @param c The char_type to convert.
559 * @param dfault Char to return if conversion fails.
560 * @return The converted char.
563 do_narrow(char_type
, char __dfault
) const = 0;
566 * @brief Narrow char_type array to char
568 * This virtual function converts each char_type in the range [lo,hi) to
569 * char using the simplest reasonable transformation and writes the
570 * results to the destination array. For any element in the input that
571 * cannot be converted, @a dfault is used instead.
573 * do_narrow() is a hook for a derived facet to change the behavior of
574 * narrowing. do_narrow() must always return the same result for the
577 * Note: this is not what you want for codepage conversions. See
580 * @param lo Pointer to start of range.
581 * @param hi Pointer to end of range.
582 * @param dfault Char to use if conversion fails.
583 * @param to Pointer to the destination array.
586 virtual const char_type
*
587 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
588 char __dfault
, char* __dest
) const = 0;
591 // NB: Generic, mostly useless implementation.
593 * @brief Template ctype facet
595 * This template class defines classification and conversion functions for
596 * character sets. It wraps <cctype> functionality. Ctype gets used by
597 * streams for many I/O operations.
599 * This template provides the protected virtual functions the developer
600 * will have to replace in a derived class or specialization to make a
601 * working facet. The public functions that access them are defined in
602 * __ctype_abstract_base, to allow for implementation flexibility. See
603 * ctype<wchar_t> for an example. The functions are documented in
604 * __ctype_abstract_base.
606 * Note: implementations are provided for all the protected virtual
607 * functions, but will likely not be useful.
609 template<typename _CharT
>
610 class ctype
: public __ctype_abstract_base
<_CharT
>
614 typedef _CharT char_type
;
615 typedef typename __ctype_abstract_base
<_CharT
>::mask mask
;
617 /// The facet id for ctype<char_type>
618 static locale::id id
;
621 ctype(size_t __refs
= 0) : __ctype_abstract_base
<_CharT
>(__refs
) { }
628 do_is(mask __m
, char_type __c
) const;
630 virtual const char_type
*
631 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
633 virtual const char_type
*
634 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
636 virtual const char_type
*
637 do_scan_not(mask __m
, const char_type
* __lo
,
638 const char_type
* __hi
) const;
641 do_toupper(char_type __c
) const;
643 virtual const char_type
*
644 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
647 do_tolower(char_type __c
) const;
649 virtual const char_type
*
650 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
653 do_widen(char __c
) const;
656 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
659 do_narrow(char_type
, char __dfault
) const;
661 virtual const char_type
*
662 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
663 char __dfault
, char* __dest
) const;
666 template<typename _CharT
>
667 locale::id ctype
<_CharT
>::id
;
669 // 22.2.1.3 ctype<char> specialization.
671 * @brief The ctype<char> specialization.
673 * This class defines classification and conversion functions for
674 * the char type. It gets used by char streams for many I/O
675 * operations. The char specialization provides a number of
676 * optimizations as well.
679 class ctype
<char> : public locale::facet
, public ctype_base
683 /// Typedef for the template parameter char.
684 typedef char char_type
;
688 __c_locale _M_c_locale_ctype
;
690 __to_type _M_toupper
;
691 __to_type _M_tolower
;
692 const mask
* _M_table
;
693 mutable char _M_widen_ok
;
694 mutable char _M_widen
[1 + static_cast<unsigned char>(-1)];
695 mutable char _M_narrow
[1 + static_cast<unsigned char>(-1)];
696 mutable char _M_narrow_ok
; // 0 uninitialized, 1 init,
697 // 2 memcpy can't be used
700 /// The facet id for ctype<char>
701 static locale::id id
;
702 /// The size of the mask table. It is SCHAR_MAX + 1.
703 static const size_t table_size
= 1 + static_cast<unsigned char>(-1);
706 * @brief Constructor performs initialization.
708 * This is the constructor provided by the standard.
710 * @param table If non-zero, table is used as the per-char mask.
711 * Else classic_table() is used.
712 * @param del If true, passes ownership of table to this facet.
713 * @param refs Passed to the base facet class.
716 ctype(const mask
* __table
= 0, bool __del
= false, size_t __refs
= 0);
719 * @brief Constructor performs static initialization.
721 * This constructor is used to construct the initial C locale facet.
723 * @param cloc Handle to C locale data.
724 * @param table If non-zero, table is used as the per-char mask.
725 * @param del If true, passes ownership of table to this facet.
726 * @param refs Passed to the base facet class.
729 ctype(__c_locale __cloc
, const mask
* __table
= 0, bool __del
= false,
733 * @brief Test char classification.
735 * This function compares the mask table[c] to @a m.
737 * @param c The char to compare the mask of.
738 * @param m The mask to compare against.
739 * @return True if m & table[c] is true, false otherwise.
742 is(mask __m
, char __c
) const;
745 * @brief Return a mask array.
747 * This function finds the mask for each char in the range [lo, hi) and
748 * successively writes it to vec. vec must have as many elements as
751 * @param lo Pointer to start of range.
752 * @param hi Pointer to end of range.
753 * @param vec Pointer to an array of mask storage.
757 is(const char* __lo
, const char* __hi
, mask
* __vec
) const;
760 * @brief Find char matching a mask
762 * This function searches for and returns the first char in [lo,hi) for
763 * which is(m,char) is true.
765 * @param m The mask to compare against.
766 * @param lo Pointer to start of range.
767 * @param hi Pointer to end of range.
768 * @return Pointer to a matching char if found, else @a hi.
771 scan_is(mask __m
, const char* __lo
, const char* __hi
) const;
774 * @brief Find char not matching a mask
776 * This function searches for and returns a pointer to the first char
777 * in [lo,hi) for which is(m,char) is false.
779 * @param m The mask to compare against.
780 * @param lo Pointer to start of range.
781 * @param hi Pointer to end of range.
782 * @return Pointer to a non-matching char if found, else @a hi.
785 scan_not(mask __m
, const char* __lo
, const char* __hi
) const;
788 * @brief Convert to uppercase.
790 * This function converts the char argument to uppercase if possible.
791 * If not possible (for example, '2'), returns the argument.
793 * toupper() acts as if it returns ctype<char>::do_toupper(c).
794 * do_toupper() must always return the same result for the same input.
796 * @param c The char to convert.
797 * @return The uppercase char if convertible, else @a c.
800 toupper(char_type __c
) const
801 { return this->do_toupper(__c
); }
804 * @brief Convert array to uppercase.
806 * This function converts each char in the range [lo,hi) to uppercase
807 * if possible. Other chars remain untouched.
809 * toupper() acts as if it returns ctype<char>:: do_toupper(lo, hi).
810 * do_toupper() must always return the same result for the same input.
812 * @param lo Pointer to first char in range.
813 * @param hi Pointer to end of range.
817 toupper(char_type
*__lo
, const char_type
* __hi
) const
818 { return this->do_toupper(__lo
, __hi
); }
821 * @brief Convert to lowercase.
823 * This function converts the char argument to lowercase if possible.
824 * If not possible (for example, '2'), returns the argument.
826 * tolower() acts as if it returns ctype<char>::do_tolower(c).
827 * do_tolower() must always return the same result for the same input.
829 * @param c The char to convert.
830 * @return The lowercase char if convertible, else @a c.
833 tolower(char_type __c
) const
834 { return this->do_tolower(__c
); }
837 * @brief Convert array to lowercase.
839 * This function converts each char in the range [lo,hi) to lowercase
840 * if possible. Other chars remain untouched.
842 * tolower() acts as if it returns ctype<char>:: do_tolower(lo, hi).
843 * do_tolower() must always return the same result for the same input.
845 * @param lo Pointer to first char in range.
846 * @param hi Pointer to end of range.
850 tolower(char_type
* __lo
, const char_type
* __hi
) const
851 { return this->do_tolower(__lo
, __hi
); }
856 * This function converts the char to char_type using the simplest
857 * reasonable transformation. For an underived ctype<char> facet, the
858 * argument will be returned unchanged.
860 * This function works as if it returns ctype<char>::do_widen(c).
861 * do_widen() must always return the same result for the same input.
863 * Note: this is not what you want for codepage conversions. See
866 * @param c The char to convert.
867 * @return The converted character.
870 widen(char __c
) const
873 return _M_widen
[static_cast<unsigned char>(__c
)];
874 this->_M_widen_init();
875 return this->do_widen(__c
);
879 * @brief Widen char array
881 * This function converts each char in the input to char using the
882 * simplest reasonable transformation. For an underived ctype<char>
883 * facet, the argument will be copied unchanged.
885 * This function works as if it returns ctype<char>::do_widen(c).
886 * do_widen() must always return the same result for the same input.
888 * Note: this is not what you want for codepage conversions. See
891 * @param lo Pointer to first char in range.
892 * @param hi Pointer to end of range.
893 * @param to Pointer to the destination array.
897 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
899 if (_M_widen_ok
== 1)
901 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
906 return this->do_widen(__lo
, __hi
, __to
);
912 * This function converts the char to char using the simplest
913 * reasonable transformation. If the conversion fails, dfault is
914 * returned instead. For an underived ctype<char> facet, @a c
915 * will be returned unchanged.
917 * This function works as if it returns ctype<char>::do_narrow(c).
918 * do_narrow() must always return the same result for the same input.
920 * Note: this is not what you want for codepage conversions. See
923 * @param c The char to convert.
924 * @param dfault Char to return if conversion fails.
925 * @return The converted character.
928 narrow(char_type __c
, char __dfault
) const
930 if (_M_narrow
[static_cast<unsigned char>(__c
)])
931 return _M_narrow
[static_cast<unsigned char>(__c
)];
932 const char __t
= do_narrow(__c
, __dfault
);
934 _M_narrow
[static_cast<unsigned char>(__c
)] = __t
;
939 * @brief Narrow char array
941 * This function converts each char in the input to char using the
942 * simplest reasonable transformation and writes the results to the
943 * destination array. For any char in the input that cannot be
944 * converted, @a dfault is used instead. For an underived ctype<char>
945 * facet, the argument will be copied unchanged.
947 * This function works as if it returns ctype<char>::do_narrow(lo, hi,
948 * dfault, to). do_narrow() must always return the same result for the
951 * Note: this is not what you want for codepage conversions. See
954 * @param lo Pointer to start of range.
955 * @param hi Pointer to end of range.
956 * @param dfault Char to use if conversion fails.
957 * @param to Pointer to the destination array.
961 narrow(const char_type
* __lo
, const char_type
* __hi
,
962 char __dfault
, char *__to
) const
964 if (__builtin_expect(_M_narrow_ok
== 1, true))
966 __builtin_memcpy(__to
, __lo
, __hi
- __lo
);
971 return this->do_narrow(__lo
, __hi
, __dfault
, __to
);
974 // _GLIBCXX_RESOLVE_LIB_DEFECTS
975 // DR 695. ctype<char>::classic_table() not accessible.
976 /// Returns a pointer to the mask table provided to the constructor, or
977 /// the default from classic_table() if none was provided.
979 table() const throw()
982 /// Returns a pointer to the C locale mask table.
984 classic_table() throw();
990 * This function deletes table() if @a del was true in the
997 * @brief Convert to uppercase.
999 * This virtual function converts the char argument to uppercase if
1000 * possible. If not possible (for example, '2'), returns the argument.
1002 * do_toupper() is a hook for a derived facet to change the behavior of
1003 * uppercasing. do_toupper() must always return the same result for
1006 * @param c The char to convert.
1007 * @return The uppercase char if convertible, else @a c.
1010 do_toupper(char_type
) const;
1013 * @brief Convert array to uppercase.
1015 * This virtual function converts each char in the range [lo,hi) to
1016 * uppercase if possible. Other chars remain untouched.
1018 * do_toupper() is a hook for a derived facet to change the behavior of
1019 * uppercasing. do_toupper() must always return the same result for
1022 * @param lo Pointer to start of range.
1023 * @param hi Pointer to end of range.
1026 virtual const char_type
*
1027 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
1030 * @brief Convert to lowercase.
1032 * This virtual function converts the char argument to lowercase if
1033 * possible. If not possible (for example, '2'), returns the argument.
1035 * do_tolower() is a hook for a derived facet to change the behavior of
1036 * lowercasing. do_tolower() must always return the same result for
1039 * @param c The char to convert.
1040 * @return The lowercase char if convertible, else @a c.
1043 do_tolower(char_type
) const;
1046 * @brief Convert array to lowercase.
1048 * This virtual function converts each char in the range [lo,hi) to
1049 * lowercase if possible. Other chars remain untouched.
1051 * do_tolower() is a hook for a derived facet to change the behavior of
1052 * lowercasing. do_tolower() must always return the same result for
1055 * @param lo Pointer to first char in range.
1056 * @param hi Pointer to end of range.
1059 virtual const char_type
*
1060 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
1065 * This virtual function converts the char to char using the simplest
1066 * reasonable transformation. For an underived ctype<char> facet, the
1067 * argument will be returned unchanged.
1069 * do_widen() is a hook for a derived facet to change the behavior of
1070 * widening. do_widen() must always return the same result for the
1073 * Note: this is not what you want for codepage conversions. See
1076 * @param c The char to convert.
1077 * @return The converted character.
1080 do_widen(char __c
) const
1084 * @brief Widen char array
1086 * This function converts each char in the range [lo,hi) to char using
1087 * the simplest reasonable transformation. For an underived
1088 * ctype<char> facet, the argument will be copied unchanged.
1090 * do_widen() is a hook for a derived facet to change the behavior of
1091 * widening. do_widen() must always return the same result for the
1094 * Note: this is not what you want for codepage conversions. See
1097 * @param lo Pointer to start of range.
1098 * @param hi Pointer to end of range.
1099 * @param to Pointer to the destination array.
1103 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const
1105 __builtin_memcpy(__dest
, __lo
, __hi
- __lo
);
1110 * @brief Narrow char
1112 * This virtual function converts the char to char using the simplest
1113 * reasonable transformation. If the conversion fails, dfault is
1114 * returned instead. For an underived ctype<char> facet, @a c will be
1115 * returned unchanged.
1117 * do_narrow() is a hook for a derived facet to change the behavior of
1118 * narrowing. do_narrow() must always return the same result for the
1121 * Note: this is not what you want for codepage conversions. See
1124 * @param c The char to convert.
1125 * @param dfault Char to return if conversion fails.
1126 * @return The converted char.
1129 do_narrow(char_type __c
, char) const
1133 * @brief Narrow char array to char array
1135 * This virtual function converts each char in the range [lo,hi) to
1136 * char using the simplest reasonable transformation and writes the
1137 * results to the destination array. For any char in the input that
1138 * cannot be converted, @a dfault is used instead. For an underived
1139 * ctype<char> facet, the argument will be copied unchanged.
1141 * do_narrow() is a hook for a derived facet to change the behavior of
1142 * narrowing. do_narrow() must always return the same result for the
1145 * Note: this is not what you want for codepage conversions. See
1148 * @param lo Pointer to start of range.
1149 * @param hi Pointer to end of range.
1150 * @param dfault Char to use if conversion fails.
1151 * @param to Pointer to the destination array.
1154 virtual const char_type
*
1155 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
1156 char, char* __dest
) const
1158 __builtin_memcpy(__dest
, __lo
, __hi
- __lo
);
1163 void _M_narrow_init() const;
1164 void _M_widen_init() const;
1167 #ifdef _GLIBCXX_USE_WCHAR_T
1168 // 22.2.1.3 ctype<wchar_t> specialization
1170 * @brief The ctype<wchar_t> specialization.
1172 * This class defines classification and conversion functions for the
1173 * wchar_t type. It gets used by wchar_t streams for many I/O operations.
1174 * The wchar_t specialization provides a number of optimizations as well.
1176 * ctype<wchar_t> inherits its public methods from
1177 * __ctype_abstract_base<wchar_t>.
1180 class ctype
<wchar_t> : public __ctype_abstract_base
<wchar_t>
1184 /// Typedef for the template parameter wchar_t.
1185 typedef wchar_t char_type
;
1186 typedef wctype_t __wmask_type
;
1189 __c_locale _M_c_locale_ctype
;
1191 // Pre-computed narrowed and widened chars.
1193 char _M_narrow
[128];
1194 wint_t _M_widen
[1 + static_cast<unsigned char>(-1)];
1196 // Pre-computed elements for do_is.
1198 __wmask_type _M_wmask
[16];
1202 /// The facet id for ctype<wchar_t>
1203 static locale::id id
;
1206 * @brief Constructor performs initialization.
1208 * This is the constructor provided by the standard.
1210 * @param refs Passed to the base facet class.
1213 ctype(size_t __refs
= 0);
1216 * @brief Constructor performs static initialization.
1218 * This constructor is used to construct the initial C locale facet.
1220 * @param cloc Handle to C locale data.
1221 * @param refs Passed to the base facet class.
1224 ctype(__c_locale __cloc
, size_t __refs
= 0);
1228 _M_convert_to_wmask(const mask __m
) const;
1235 * @brief Test wchar_t classification.
1237 * This function finds a mask M for @a c and compares it to mask @a m.
1239 * do_is() is a hook for a derived facet to change the behavior of
1240 * classifying. do_is() must always return the same result for the
1243 * @param c The wchar_t to find the mask of.
1244 * @param m The mask to compare against.
1245 * @return (M & m) != 0.
1248 do_is(mask __m
, char_type __c
) const;
1251 * @brief Return a mask array.
1253 * This function finds the mask for each wchar_t in the range [lo,hi)
1254 * and successively writes it to vec. vec must have as many elements
1257 * do_is() is a hook for a derived facet to change the behavior of
1258 * classifying. do_is() must always return the same result for the
1261 * @param lo Pointer to start of range.
1262 * @param hi Pointer to end of range.
1263 * @param vec Pointer to an array of mask storage.
1266 virtual const char_type
*
1267 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
1270 * @brief Find wchar_t matching mask
1272 * This function searches for and returns the first wchar_t c in
1273 * [lo,hi) for which is(m,c) is true.
1275 * do_scan_is() is a hook for a derived facet to change the behavior of
1276 * match searching. do_is() must always return the same result for the
1279 * @param m The mask to compare against.
1280 * @param lo Pointer to start of range.
1281 * @param hi Pointer to end of range.
1282 * @return Pointer to a matching wchar_t if found, else @a hi.
1284 virtual const char_type
*
1285 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
1288 * @brief Find wchar_t not matching mask
1290 * This function searches for and returns a pointer to the first
1291 * wchar_t c of [lo,hi) for which is(m,c) is false.
1293 * do_scan_is() is a hook for a derived facet to change the behavior of
1294 * match searching. do_is() must always return the same result for the
1297 * @param m The mask to compare against.
1298 * @param lo Pointer to start of range.
1299 * @param hi Pointer to end of range.
1300 * @return Pointer to a non-matching wchar_t if found, else @a hi.
1302 virtual const char_type
*
1303 do_scan_not(mask __m
, const char_type
* __lo
,
1304 const char_type
* __hi
) const;
1307 * @brief Convert to uppercase.
1309 * This virtual function converts the wchar_t argument to uppercase if
1310 * possible. If not possible (for example, '2'), returns the argument.
1312 * do_toupper() is a hook for a derived facet to change the behavior of
1313 * uppercasing. do_toupper() must always return the same result for
1316 * @param c The wchar_t to convert.
1317 * @return The uppercase wchar_t if convertible, else @a c.
1320 do_toupper(char_type
) const;
1323 * @brief Convert array to uppercase.
1325 * This virtual function converts each wchar_t in the range [lo,hi) to
1326 * uppercase if possible. Other elements remain untouched.
1328 * do_toupper() is a hook for a derived facet to change the behavior of
1329 * uppercasing. do_toupper() must always return the same result for
1332 * @param lo Pointer to start of range.
1333 * @param hi Pointer to end of range.
1336 virtual const char_type
*
1337 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
1340 * @brief Convert to lowercase.
1342 * This virtual function converts the argument to lowercase if
1343 * possible. If not possible (for example, '2'), returns the argument.
1345 * do_tolower() is a hook for a derived facet to change the behavior of
1346 * lowercasing. do_tolower() must always return the same result for
1349 * @param c The wchar_t to convert.
1350 * @return The lowercase wchar_t if convertible, else @a c.
1353 do_tolower(char_type
) const;
1356 * @brief Convert array to lowercase.
1358 * This virtual function converts each wchar_t in the range [lo,hi) to
1359 * lowercase if possible. Other elements remain untouched.
1361 * do_tolower() is a hook for a derived facet to change the behavior of
1362 * lowercasing. do_tolower() must always return the same result for
1365 * @param lo Pointer to start of range.
1366 * @param hi Pointer to end of range.
1369 virtual const char_type
*
1370 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
1373 * @brief Widen char to wchar_t
1375 * This virtual function converts the char to wchar_t using the
1376 * simplest reasonable transformation. For an underived ctype<wchar_t>
1377 * facet, the argument will be cast to wchar_t.
1379 * do_widen() is a hook for a derived facet to change the behavior of
1380 * widening. do_widen() must always return the same result for the
1383 * Note: this is not what you want for codepage conversions. See
1386 * @param c The char to convert.
1387 * @return The converted wchar_t.
1390 do_widen(char) const;
1393 * @brief Widen char array to wchar_t array
1395 * This function converts each char in the input to wchar_t using the
1396 * simplest reasonable transformation. For an underived ctype<wchar_t>
1397 * facet, the argument will be copied, casting each element to wchar_t.
1399 * do_widen() is a hook for a derived facet to change the behavior of
1400 * widening. do_widen() must always return the same result for the
1403 * Note: this is not what you want for codepage conversions. See
1406 * @param lo Pointer to start range.
1407 * @param hi Pointer to end of range.
1408 * @param to Pointer to the destination array.
1412 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
1415 * @brief Narrow wchar_t to char
1417 * This virtual function converts the argument to char using
1418 * the simplest reasonable transformation. If the conversion
1419 * fails, dfault is returned instead. For an underived
1420 * ctype<wchar_t> facet, @a c will be cast to char and
1423 * do_narrow() is a hook for a derived facet to change the
1424 * behavior of narrowing. do_narrow() must always return the
1425 * same result for the same input.
1427 * Note: this is not what you want for codepage conversions. See
1430 * @param c The wchar_t to convert.
1431 * @param dfault Char to return if conversion fails.
1432 * @return The converted char.
1435 do_narrow(char_type
, char __dfault
) const;
1438 * @brief Narrow wchar_t array to char array
1440 * This virtual function converts each wchar_t in the range [lo,hi) to
1441 * char using the simplest reasonable transformation and writes the
1442 * results to the destination array. For any wchar_t in the input that
1443 * cannot be converted, @a dfault is used instead. For an underived
1444 * ctype<wchar_t> facet, the argument will be copied, casting each
1447 * do_narrow() is a hook for a derived facet to change the behavior of
1448 * narrowing. do_narrow() must always return the same result for the
1451 * Note: this is not what you want for codepage conversions. See
1454 * @param lo Pointer to start of range.
1455 * @param hi Pointer to end of range.
1456 * @param dfault Char to use if conversion fails.
1457 * @param to Pointer to the destination array.
1460 virtual const char_type
*
1461 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
1462 char __dfault
, char* __dest
) const;
1464 // For use at construction time only.
1466 _M_initialize_ctype();
1468 #endif //_GLIBCXX_USE_WCHAR_T
1470 /// class ctype_byname [22.2.1.2].
1471 template<typename _CharT
>
1472 class ctype_byname
: public ctype
<_CharT
>
1475 typedef typename ctype
<_CharT
>::mask mask
;
1478 ctype_byname(const char* __s
, size_t __refs
= 0);
1482 ~ctype_byname() { };
1485 /// 22.2.1.4 Class ctype_byname specializations.
1487 class ctype_byname
<char> : public ctype
<char>
1491 ctype_byname(const char* __s
, size_t __refs
= 0);
1498 #ifdef _GLIBCXX_USE_WCHAR_T
1500 class ctype_byname
<wchar_t> : public ctype
<wchar_t>
1504 ctype_byname(const char* __s
, size_t __refs
= 0);
1512 _GLIBCXX_END_NAMESPACE
1514 // Include host and configuration specific ctype inlines.
1515 #include <bits/ctype_inline.h>
1517 _GLIBCXX_BEGIN_NAMESPACE(std
)
1519 // 22.2.2 The numeric category.
1523 // NB: Code depends on the order of _S_atoms_out elements.
1524 // Below are the indices into _S_atoms_out.
1532 _S_odigits_end
= _S_odigits
+ 16,
1533 _S_oudigits
= _S_odigits_end
,
1534 _S_oudigits_end
= _S_oudigits
+ 16,
1535 _S_oe
= _S_odigits
+ 14, // For scientific notation, 'e'
1536 _S_oE
= _S_oudigits
+ 14, // For scientific notation, 'E'
1537 _S_oend
= _S_oudigits_end
1540 // A list of valid numeric literals for output. This array
1541 // contains chars that will be passed through the current locale's
1542 // ctype<_CharT>.widen() and then used to render numbers.
1543 // For the standard "C" locale, this is
1544 // "-+xX0123456789abcdef0123456789ABCDEF".
1545 static const char* _S_atoms_out
;
1547 // String literal of acceptable (narrow) input, for num_get.
1548 // "-+xX0123456789abcdefABCDEF"
1549 static const char* _S_atoms_in
;
1558 _S_ie
= _S_izero
+ 14,
1559 _S_iE
= _S_izero
+ 20,
1564 // Construct and return valid scanf format for floating point types.
1566 _S_format_float(const ios_base
& __io
, char* __fptr
, char __mod
);
1569 template<typename _CharT
>
1570 struct __numpunct_cache
: public locale::facet
1572 const char* _M_grouping
;
1573 size_t _M_grouping_size
;
1574 bool _M_use_grouping
;
1575 const _CharT
* _M_truename
;
1576 size_t _M_truename_size
;
1577 const _CharT
* _M_falsename
;
1578 size_t _M_falsename_size
;
1579 _CharT _M_decimal_point
;
1580 _CharT _M_thousands_sep
;
1582 // A list of valid numeric literals for output: in the standard
1583 // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
1584 // This array contains the chars after having been passed
1585 // through the current locale's ctype<_CharT>.widen().
1586 _CharT _M_atoms_out
[__num_base::_S_oend
];
1588 // A list of valid numeric literals for input: in the standard
1589 // "C" locale, this is "-+xX0123456789abcdefABCDEF"
1590 // This array contains the chars after having been passed
1591 // through the current locale's ctype<_CharT>.widen().
1592 _CharT _M_atoms_in
[__num_base::_S_iend
];
1596 __numpunct_cache(size_t __refs
= 0) : facet(__refs
),
1597 _M_grouping(NULL
), _M_grouping_size(0), _M_use_grouping(false),
1598 _M_truename(NULL
), _M_truename_size(0), _M_falsename(NULL
),
1599 _M_falsename_size(0), _M_decimal_point(_CharT()),
1600 _M_thousands_sep(_CharT()), _M_allocated(false)
1603 ~__numpunct_cache();
1606 _M_cache(const locale
& __loc
);
1610 operator=(const __numpunct_cache
&);
1613 __numpunct_cache(const __numpunct_cache
&);
1616 template<typename _CharT
>
1617 __numpunct_cache
<_CharT
>::~__numpunct_cache()
1621 delete [] _M_grouping
;
1622 delete [] _M_truename
;
1623 delete [] _M_falsename
;
1628 * @brief Numpunct facet.
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) : facet(__refs
), _M_data(NULL
)
1666 { _M_initialize_numpunct(); }
1669 * @brief Internal constructor. Not for general use.
1671 * This is a constructor for use by the library itself to set up the
1672 * predefined locale facets.
1674 * @param cache __numpunct_cache object.
1675 * @param refs Refcount to pass to the base class.
1678 numpunct(__cache_type
* __cache
, size_t __refs
= 0)
1679 : facet(__refs
), _M_data(__cache
)
1680 { _M_initialize_numpunct(); }
1683 * @brief Internal constructor. Not for general use.
1685 * This is a constructor for use by the library itself to set up new
1688 * @param cloc The "C" locale.
1689 * @param refs Refcount to pass to the base class.
1692 numpunct(__c_locale __cloc
, size_t __refs
= 0)
1693 : facet(__refs
), _M_data(NULL
)
1694 { _M_initialize_numpunct(__cloc
); }
1697 * @brief Return decimal point character.
1699 * This function returns a char_type to use as a decimal point. It
1700 * does so by returning returning
1701 * numpunct<char_type>::do_decimal_point().
1703 * @return @a char_type representing a decimal point.
1706 decimal_point() const
1707 { return this->do_decimal_point(); }
1710 * @brief Return thousands separator character.
1712 * This function returns a char_type to use as a thousands
1713 * separator. It does so by returning returning
1714 * numpunct<char_type>::do_thousands_sep().
1716 * @return char_type representing a thousands separator.
1719 thousands_sep() const
1720 { return this->do_thousands_sep(); }
1723 * @brief Return grouping specification.
1725 * This function returns a string representing groupings for the
1726 * integer part of a number. Groupings indicate where thousands
1727 * separators should be inserted in the integer part of a number.
1729 * Each char in the return string is interpret as an integer
1730 * rather than a character. These numbers represent the number
1731 * of digits in a group. The first char in the string
1732 * represents the number of digits in the least significant
1733 * group. If a char is negative, it indicates an unlimited
1734 * number of digits for the group. If more chars from the
1735 * string are required to group a number, the last char is used
1738 * For example, if the grouping() returns "\003\002" and is
1739 * applied to the number 123456789, this corresponds to
1740 * 12,34,56,789. Note that if the string was "32", this would
1741 * put more than 50 digits into the least significant group if
1742 * the character set is ASCII.
1744 * The string is returned by calling
1745 * numpunct<char_type>::do_grouping().
1747 * @return string representing grouping specification.
1751 { return this->do_grouping(); }
1754 * @brief Return string representation of bool true.
1756 * This function returns a string_type containing the text
1757 * representation for true bool variables. It does so by calling
1758 * numpunct<char_type>::do_truename().
1760 * @return string_type representing printed form of true.
1764 { return this->do_truename(); }
1767 * @brief Return string representation of bool false.
1769 * This function returns a string_type containing the text
1770 * representation for false bool variables. It does so by calling
1771 * numpunct<char_type>::do_falsename().
1773 * @return string_type representing printed form of false.
1777 { return this->do_falsename(); }
1785 * @brief Return decimal point character.
1787 * Returns a char_type to use as a decimal point. This function is a
1788 * hook for derived classes to change the value returned.
1790 * @return @a char_type representing a decimal point.
1793 do_decimal_point() const
1794 { return _M_data
->_M_decimal_point
; }
1797 * @brief Return thousands separator character.
1799 * Returns a char_type to use as a thousands separator. This function
1800 * is a hook for derived classes to change the value returned.
1802 * @return @a char_type representing a thousands separator.
1805 do_thousands_sep() const
1806 { return _M_data
->_M_thousands_sep
; }
1809 * @brief Return grouping specification.
1811 * Returns a string representing groupings for the integer part of a
1812 * number. This function is a hook for derived classes to change the
1813 * value returned. @see grouping() for details.
1815 * @return String representing grouping specification.
1819 { return _M_data
->_M_grouping
; }
1822 * @brief Return string representation of bool true.
1824 * Returns a string_type containing the text representation for true
1825 * bool variables. This function is a hook for derived classes to
1826 * change the value returned.
1828 * @return string_type representing printed form of true.
1832 { return _M_data
->_M_truename
; }
1835 * @brief Return string representation of bool false.
1837 * Returns a string_type containing the text representation for false
1838 * bool variables. This function is a hook for derived classes to
1839 * change the value returned.
1841 * @return string_type representing printed form of false.
1844 do_falsename() const
1845 { return _M_data
->_M_falsename
; }
1847 // For use at construction time only.
1849 _M_initialize_numpunct(__c_locale __cloc
= NULL
);
1852 template<typename _CharT
>
1853 locale::id numpunct
<_CharT
>::id
;
1856 numpunct
<char>::~numpunct();
1860 numpunct
<char>::_M_initialize_numpunct(__c_locale __cloc
);
1862 #ifdef _GLIBCXX_USE_WCHAR_T
1864 numpunct
<wchar_t>::~numpunct();
1868 numpunct
<wchar_t>::_M_initialize_numpunct(__c_locale __cloc
);
1871 /// class numpunct_byname [22.2.3.2].
1872 template<typename _CharT
>
1873 class numpunct_byname
: public numpunct
<_CharT
>
1876 typedef _CharT char_type
;
1877 typedef basic_string
<_CharT
> string_type
;
1880 numpunct_byname(const char* __s
, size_t __refs
= 0)
1881 : numpunct
<_CharT
>(__refs
)
1883 if (__builtin_strcmp(__s
, "C") != 0
1884 && __builtin_strcmp(__s
, "POSIX") != 0)
1887 this->_S_create_c_locale(__tmp
, __s
);
1888 this->_M_initialize_numpunct(__tmp
);
1889 this->_S_destroy_c_locale(__tmp
);
1895 ~numpunct_byname() { }
1898 _GLIBCXX_BEGIN_LDBL_NAMESPACE
1901 * @brief Facet for parsing number strings.
1903 * This facet encapsulates the code to parse and return a number
1904 * from a string. It is used by the istream numeric extraction
1907 * The num_get template uses protected virtual functions to provide the
1908 * actual results. The public accessors forward the call to the virtual
1909 * functions. These virtual functions are hooks for developers to
1910 * implement the behavior they require from the num_get facet.
1912 template<typename _CharT
, typename _InIter
>
1913 class num_get
: public locale::facet
1919 typedef _CharT char_type
;
1920 typedef _InIter iter_type
;
1923 /// Numpunct facet id.
1924 static locale::id id
;
1927 * @brief Constructor performs initialization.
1929 * This is the constructor provided by the standard.
1931 * @param refs Passed to the base facet class.
1934 num_get(size_t __refs
= 0) : facet(__refs
) { }
1937 * @brief Numeric parsing.
1939 * Parses the input stream into the bool @a v. It does so by calling
1940 * num_get::do_get().
1942 * If ios_base::boolalpha is set, attempts to read
1943 * ctype<CharT>::truename() or ctype<CharT>::falsename(). Sets
1944 * @a v to true or false if successful. Sets err to
1945 * ios_base::failbit if reading the string fails. Sets err to
1946 * ios_base::eofbit if the stream is emptied.
1948 * If ios_base::boolalpha is not set, proceeds as with reading a long,
1949 * except if the value is 1, sets @a v to true, if the value is 0, sets
1950 * @a v to false, and otherwise set err to ios_base::failbit.
1952 * @param in Start of input stream.
1953 * @param end End of input stream.
1954 * @param io Source of locale and flags.
1955 * @param err Error flags to set.
1956 * @param v Value to format and insert.
1957 * @return Iterator after reading.
1960 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
1961 ios_base::iostate
& __err
, bool& __v
) const
1962 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
1966 * @brief Numeric parsing.
1968 * Parses the input stream into the integral variable @a v. It does so
1969 * by calling num_get::do_get().
1971 * Parsing is affected by the flag settings in @a io.
1973 * The basic parse is affected by the value of io.flags() &
1974 * ios_base::basefield. If equal to ios_base::oct, parses like the
1975 * scanf %o specifier. Else if equal to ios_base::hex, parses like %X
1976 * specifier. Else if basefield equal to 0, parses like the %i
1977 * specifier. Otherwise, parses like %d for signed and %u for unsigned
1978 * types. The matching type length modifier is also used.
1980 * Digit grouping is interpreted according to numpunct::grouping() and
1981 * numpunct::thousands_sep(). If the pattern of digit groups isn't
1982 * consistent, sets err to ios_base::failbit.
1984 * If parsing the string yields a valid value for @a v, @a v is set.
1985 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
1986 * Sets err to ios_base::eofbit if the stream is emptied.
1988 * @param in Start of input stream.
1989 * @param end End of input stream.
1990 * @param io Source of locale and flags.
1991 * @param err Error flags to set.
1992 * @param v Value to format and insert.
1993 * @return Iterator after reading.
1996 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
1997 ios_base::iostate
& __err
, long& __v
) const
1998 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2001 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2002 ios_base::iostate
& __err
, unsigned short& __v
) const
2003 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2006 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2007 ios_base::iostate
& __err
, unsigned int& __v
) const
2008 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2011 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2012 ios_base::iostate
& __err
, unsigned long& __v
) const
2013 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2015 #ifdef _GLIBCXX_USE_LONG_LONG
2017 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2018 ios_base::iostate
& __err
, long long& __v
) const
2019 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2022 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2023 ios_base::iostate
& __err
, unsigned long long& __v
) const
2024 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2030 * @brief Numeric parsing.
2032 * Parses the input stream into the integral variable @a v. It does so
2033 * by calling num_get::do_get().
2035 * The input characters are parsed like the scanf %g specifier. The
2036 * matching type length modifier is also used.
2038 * The decimal point character used is numpunct::decimal_point().
2039 * Digit grouping is interpreted according to numpunct::grouping() and
2040 * numpunct::thousands_sep(). If the pattern of digit groups isn't
2041 * consistent, sets err to ios_base::failbit.
2043 * If parsing the string yields a valid value for @a v, @a v is set.
2044 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2045 * Sets err to ios_base::eofbit if the stream is emptied.
2047 * @param in Start of input stream.
2048 * @param end End of input stream.
2049 * @param io Source of locale and flags.
2050 * @param err Error flags to set.
2051 * @param v Value to format and insert.
2052 * @return Iterator after reading.
2055 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2056 ios_base::iostate
& __err
, float& __v
) const
2057 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2060 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2061 ios_base::iostate
& __err
, double& __v
) const
2062 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2065 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2066 ios_base::iostate
& __err
, long double& __v
) const
2067 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2071 * @brief Numeric parsing.
2073 * Parses the input stream into the pointer variable @a v. It does so
2074 * by calling num_get::do_get().
2076 * The input characters are parsed like the scanf %p specifier.
2078 * Digit grouping is interpreted according to numpunct::grouping() and
2079 * numpunct::thousands_sep(). If the pattern of digit groups isn't
2080 * consistent, sets err to ios_base::failbit.
2082 * Note that the digit grouping effect for pointers is a bit ambiguous
2083 * in the standard and shouldn't be relied on. See DR 344.
2085 * If parsing the string yields a valid value for @a v, @a v is set.
2086 * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2087 * Sets err to ios_base::eofbit if the stream is emptied.
2089 * @param in Start of input stream.
2090 * @param end End of input stream.
2091 * @param io Source of locale and flags.
2092 * @param err Error flags to set.
2093 * @param v Value to format and insert.
2094 * @return Iterator after reading.
2097 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
2098 ios_base::iostate
& __err
, void*& __v
) const
2099 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
2103 virtual ~num_get() { }
2106 _M_extract_float(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2107 string
& __xtrc
) const;
2109 template<typename _ValueT
>
2111 _M_extract_int(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
2112 _ValueT
& __v
) const;
2114 template<typename _CharT2
>
2115 typename
__gnu_cxx::__enable_if
<__is_char
<_CharT2
>::__value
, int>::__type
2116 _M_find(const _CharT2
*, size_t __len
, _CharT2 __c
) const
2121 if (__c
>= _CharT2('0') && __c
< _CharT2(_CharT2('0') + __len
))
2122 __ret
= __c
- _CharT2('0');
2126 if (__c
>= _CharT2('0') && __c
<= _CharT2('9'))
2127 __ret
= __c
- _CharT2('0');
2128 else if (__c
>= _CharT2('a') && __c
<= _CharT2('f'))
2129 __ret
= 10 + (__c
- _CharT2('a'));
2130 else if (__c
>= _CharT2('A') && __c
<= _CharT2('F'))
2131 __ret
= 10 + (__c
- _CharT2('A'));
2136 template<typename _CharT2
>
2137 typename
__gnu_cxx::__enable_if
<!__is_char
<_CharT2
>::__value
,
2139 _M_find(const _CharT2
* __zero
, size_t __len
, _CharT2 __c
) const
2142 const char_type
* __q
= char_traits
<_CharT2
>::find(__zero
, __len
, __c
);
2145 __ret
= __q
- __zero
;
2154 * @brief Numeric parsing.
2156 * Parses the input stream into the variable @a v. This function is a
2157 * hook for derived classes to change the value returned. @see get()
2160 * @param in Start of input stream.
2161 * @param end End of input stream.
2162 * @param io Source of locale and flags.
2163 * @param err Error flags to set.
2164 * @param v Value to format and insert.
2165 * @return Iterator after reading.
2168 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, bool&) const;
2172 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, long&) const;
2175 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2176 unsigned short&) const;
2179 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2180 unsigned int&) const;
2183 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2184 unsigned long&) const;
2186 #ifdef _GLIBCXX_USE_LONG_LONG
2188 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2192 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2193 unsigned long long&) const;
2197 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2201 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2204 // XXX GLIBCXX_ABI Deprecated
2205 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2207 __do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2211 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2212 long double&) const;
2216 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2219 // XXX GLIBCXX_ABI Deprecated
2220 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2222 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
2223 long double&) const;
2228 template<typename _CharT
, typename _InIter
>
2229 locale::id num_get
<_CharT
, _InIter
>::id
;
2233 * @brief Facet for converting numbers to strings.
2235 * This facet encapsulates the code to convert a number to a string. It is
2236 * used by the ostream numeric insertion operators.
2238 * The num_put template uses protected virtual functions to provide the
2239 * actual results. The public accessors forward the call to the virtual
2240 * functions. These virtual functions are hooks for developers to
2241 * implement the behavior they require from the num_put facet.
2243 template<typename _CharT
, typename _OutIter
>
2244 class num_put
: public locale::facet
2250 typedef _CharT char_type
;
2251 typedef _OutIter iter_type
;
2254 /// Numpunct facet id.
2255 static locale::id id
;
2258 * @brief Constructor performs initialization.
2260 * This is the constructor provided by the standard.
2262 * @param refs Passed to the base facet class.
2265 num_put(size_t __refs
= 0) : facet(__refs
) { }
2268 * @brief Numeric formatting.
2270 * Formats the boolean @a v and inserts it into a stream. It does so
2271 * by calling num_put::do_put().
2273 * If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
2274 * ctype<CharT>::falsename(). Otherwise formats @a v as an int.
2276 * @param s Stream to write to.
2277 * @param io Source of locale and flags.
2278 * @param fill Char_type to use for filling.
2279 * @param v Value to format and insert.
2280 * @return Iterator after writing.
2283 put(iter_type __s
, ios_base
& __f
, char_type __fill
, bool __v
) const
2284 { return this->do_put(__s
, __f
, __fill
, __v
); }
2288 * @brief Numeric formatting.
2290 * Formats the integral value @a v and inserts it into a
2291 * stream. It does so by calling num_put::do_put().
2293 * Formatting is affected by the flag settings in @a io.
2295 * The basic format is affected by the value of io.flags() &
2296 * ios_base::basefield. If equal to ios_base::oct, formats like the
2297 * printf %o specifier. Else if equal to ios_base::hex, formats like
2298 * %x or %X with ios_base::uppercase unset or set respectively.
2299 * Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
2300 * for unsigned values. Note that if both oct and hex are set, neither
2303 * If ios_base::showpos is set, '+' is output before positive values.
2304 * If ios_base::showbase is set, '0' precedes octal values (except 0)
2305 * and '0[xX]' precedes hex values.
2307 * Thousands separators are inserted according to numpunct::grouping()
2308 * and numpunct::thousands_sep(). The decimal point character used is
2309 * numpunct::decimal_point().
2311 * If io.width() is non-zero, enough @a fill characters are inserted to
2312 * make the result at least that wide. If
2313 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2314 * padded at the end. If ios_base::internal, then padding occurs
2315 * immediately after either a '+' or '-' or after '0x' or '0X'.
2316 * Otherwise, padding occurs at the beginning.
2318 * @param s Stream to write to.
2319 * @param io Source of locale and flags.
2320 * @param fill Char_type to use for filling.
2321 * @param v Value to format and insert.
2322 * @return Iterator after writing.
2325 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long __v
) const
2326 { return this->do_put(__s
, __f
, __fill
, __v
); }
2329 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2330 unsigned long __v
) const
2331 { return this->do_put(__s
, __f
, __fill
, __v
); }
2333 #ifdef _GLIBCXX_USE_LONG_LONG
2335 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long long __v
) const
2336 { return this->do_put(__s
, __f
, __fill
, __v
); }
2339 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2340 unsigned long long __v
) const
2341 { return this->do_put(__s
, __f
, __fill
, __v
); }
2347 * @brief Numeric formatting.
2349 * Formats the floating point value @a v and inserts it into a stream.
2350 * It does so by calling num_put::do_put().
2352 * Formatting is affected by the flag settings in @a io.
2354 * The basic format is affected by the value of io.flags() &
2355 * ios_base::floatfield. If equal to ios_base::fixed, formats like the
2356 * printf %f specifier. Else if equal to ios_base::scientific, formats
2357 * like %e or %E with ios_base::uppercase unset or set respectively.
2358 * Otherwise, formats like %g or %G depending on uppercase. Note that
2359 * if both fixed and scientific are set, the effect will also be like
2362 * The output precision is given by io.precision(). This precision is
2363 * capped at numeric_limits::digits10 + 2 (different for double and
2364 * long double). The default precision is 6.
2366 * If ios_base::showpos is set, '+' is output before positive values.
2367 * If ios_base::showpoint is set, a decimal point will always be
2370 * Thousands separators are inserted according to numpunct::grouping()
2371 * and numpunct::thousands_sep(). The decimal point character used is
2372 * numpunct::decimal_point().
2374 * If io.width() is non-zero, enough @a fill characters are inserted to
2375 * make the result at least that wide. If
2376 * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2377 * padded at the end. If ios_base::internal, then padding occurs
2378 * immediately after either a '+' or '-' or after '0x' or '0X'.
2379 * Otherwise, padding occurs at the beginning.
2381 * @param s Stream to write to.
2382 * @param io Source of locale and flags.
2383 * @param fill Char_type to use for filling.
2384 * @param v Value to format and insert.
2385 * @return Iterator after writing.
2388 put(iter_type __s
, ios_base
& __f
, char_type __fill
, double __v
) const
2389 { return this->do_put(__s
, __f
, __fill
, __v
); }
2392 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2393 long double __v
) const
2394 { return this->do_put(__s
, __f
, __fill
, __v
); }
2398 * @brief Numeric formatting.
2400 * Formats the pointer value @a v and inserts it into a stream. It
2401 * does so by calling num_put::do_put().
2403 * This function formats @a v as an unsigned long with ios_base::hex
2404 * and ios_base::showbase set.
2406 * @param s Stream to write to.
2407 * @param io Source of locale and flags.
2408 * @param fill Char_type to use for filling.
2409 * @param v Value to format and insert.
2410 * @return Iterator after writing.
2413 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
2414 const void* __v
) const
2415 { return this->do_put(__s
, __f
, __fill
, __v
); }
2418 template<typename _ValueT
>
2420 _M_insert_float(iter_type
, ios_base
& __io
, char_type __fill
,
2421 char __mod
, _ValueT __v
) const;
2424 _M_group_float(const char* __grouping
, size_t __grouping_size
,
2425 char_type __sep
, const char_type
* __p
, char_type
* __new
,
2426 char_type
* __cs
, int& __len
) const;
2428 template<typename _ValueT
>
2430 _M_insert_int(iter_type
, ios_base
& __io
, char_type __fill
,
2434 _M_group_int(const char* __grouping
, size_t __grouping_size
,
2435 char_type __sep
, ios_base
& __io
, char_type
* __new
,
2436 char_type
* __cs
, int& __len
) const;
2439 _M_pad(char_type __fill
, streamsize __w
, ios_base
& __io
,
2440 char_type
* __new
, const char_type
* __cs
, int& __len
) const;
2448 * @brief Numeric formatting.
2450 * These functions do the work of formatting numeric values and
2451 * inserting them into a stream. This function is a hook for derived
2452 * classes to change the value returned.
2454 * @param s Stream to write to.
2455 * @param io Source of locale and flags.
2456 * @param fill Char_type to use for filling.
2457 * @param v Value to format and insert.
2458 * @return Iterator after writing.
2461 do_put(iter_type
, ios_base
&, char_type __fill
, bool __v
) const;
2464 do_put(iter_type
, ios_base
&, char_type __fill
, long __v
) const;
2467 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long) const;
2469 #ifdef _GLIBCXX_USE_LONG_LONG
2471 do_put(iter_type
, ios_base
&, char_type __fill
, long long __v
) const;
2474 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long long) const;
2478 do_put(iter_type
, ios_base
&, char_type __fill
, double __v
) const;
2480 // XXX GLIBCXX_ABI Deprecated
2481 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2483 __do_put(iter_type
, ios_base
&, char_type __fill
, double __v
) const;
2486 do_put(iter_type
, ios_base
&, char_type __fill
, long double __v
) const;
2490 do_put(iter_type
, ios_base
&, char_type __fill
, const void* __v
) const;
2492 // XXX GLIBCXX_ABI Deprecated
2493 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2495 do_put(iter_type
, ios_base
&, char_type __fill
, long double __v
) const;
2500 template <typename _CharT
, typename _OutIter
>
2501 locale::id num_put
<_CharT
, _OutIter
>::id
;
2503 _GLIBCXX_END_LDBL_NAMESPACE
2505 // Subclause convenience interfaces, inlines.
2506 // NB: These are inline because, when used in a loop, some compilers
2507 // can hoist the body out of the loop; then it's just as fast as the
2508 // C is*() function.
2510 /// Convenience interface to ctype.is(ctype_base::space, __c).
2511 template<typename _CharT
>
2513 isspace(_CharT __c
, const locale
& __loc
)
2514 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::space
, __c
); }
2516 /// Convenience interface to ctype.is(ctype_base::print, __c).
2517 template<typename _CharT
>
2519 isprint(_CharT __c
, const locale
& __loc
)
2520 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::print
, __c
); }
2522 /// Convenience interface to ctype.is(ctype_base::cntrl, __c).
2523 template<typename _CharT
>
2525 iscntrl(_CharT __c
, const locale
& __loc
)
2526 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::cntrl
, __c
); }
2528 /// Convenience interface to ctype.is(ctype_base::upper, __c).
2529 template<typename _CharT
>
2531 isupper(_CharT __c
, const locale
& __loc
)
2532 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::upper
, __c
); }
2534 /// Convenience interface to ctype.is(ctype_base::lower, __c).
2535 template<typename _CharT
>
2537 islower(_CharT __c
, const locale
& __loc
)
2538 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::lower
, __c
); }
2540 /// Convenience interface to ctype.is(ctype_base::alpha, __c).
2541 template<typename _CharT
>
2543 isalpha(_CharT __c
, const locale
& __loc
)
2544 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alpha
, __c
); }
2546 /// Convenience interface to ctype.is(ctype_base::digit, __c).
2547 template<typename _CharT
>
2549 isdigit(_CharT __c
, const locale
& __loc
)
2550 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::digit
, __c
); }
2552 /// Convenience interface to ctype.is(ctype_base::punct, __c).
2553 template<typename _CharT
>
2555 ispunct(_CharT __c
, const locale
& __loc
)
2556 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::punct
, __c
); }
2558 /// Convenience interface to ctype.is(ctype_base::xdigit, __c).
2559 template<typename _CharT
>
2561 isxdigit(_CharT __c
, const locale
& __loc
)
2562 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::xdigit
, __c
); }
2564 /// Convenience interface to ctype.is(ctype_base::alnum, __c).
2565 template<typename _CharT
>
2567 isalnum(_CharT __c
, const locale
& __loc
)
2568 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alnum
, __c
); }
2570 /// Convenience interface to ctype.is(ctype_base::graph, __c).
2571 template<typename _CharT
>
2573 isgraph(_CharT __c
, const locale
& __loc
)
2574 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::graph
, __c
); }
2576 /// Convenience interface to ctype.toupper(__c).
2577 template<typename _CharT
>
2579 toupper(_CharT __c
, const locale
& __loc
)
2580 { return use_facet
<ctype
<_CharT
> >(__loc
).toupper(__c
); }
2582 /// Convenience interface to ctype.tolower(__c).
2583 template<typename _CharT
>
2585 tolower(_CharT __c
, const locale
& __loc
)
2586 { return use_facet
<ctype
<_CharT
> >(__loc
).tolower(__c
); }
2588 _GLIBCXX_END_NAMESPACE
2590 #ifndef _GLIBCXX_EXPORT_TEMPLATE
2591 # include <bits/locale_facets.tcc>