libstdc++
locale_facets.h
Go to the documentation of this file.
1 // Locale support -*- C++ -*-
2 
3 // Copyright (C) 1997-2024 Free Software Foundation, Inc.
4 //
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)
9 // any later version.
10 
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.
15 
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.
19 
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/>.
24 
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}
28  */
29 
30 //
31 // ISO C++ 14882: 22.1 Locales
32 //
33 
34 #ifndef _LOCALE_FACETS_H
35 #define _LOCALE_FACETS_H 1
36 
37 #pragma GCC system_header
38 
39 #include <cwctype> // For wctype_t
40 #include <cctype>
41 #include <bits/ctype_base.h>
42 #include <iosfwd>
43 #include <bits/ios_base.h> // For ios_base, ios_base::iostate
44 #include <streambuf>
45 #include <bits/cpp_type_traits.h>
46 #include <ext/type_traits.h>
47 #include <ext/numeric_traits.h>
49 
50 namespace std _GLIBCXX_VISIBILITY(default)
51 {
52 _GLIBCXX_BEGIN_NAMESPACE_VERSION
53 
54 // Number of standard facets (for narrow characters only)
55 #define _GLIBCXX_NUM_FACETS 14
56 
57 // Number of duplicated facets for cxx11 ABI
58 #define _GLIBCXX_NUM_CXX11_FACETS (_GLIBCXX_USE_DUAL_ABI ? 8 : 0)
59 
60 // codecvt<char16_t> and codecvt<char32_t>
61 #ifdef _GLIBCXX_USE_CHAR8_T
62 # define _GLIBCXX_NUM_UNICODE_FACETS 4
63 #else
64 # define _GLIBCXX_NUM_UNICODE_FACETS 2
65 #endif
66 
67 // Facets duplicated for alt128 long double format
68 // num_get, num_put, money_get, money_put (+ cxx11 money_get, money_put)
69 #define _GLIBCXX_NUM_LBDL_ALT128_FACETS (4 + (_GLIBCXX_USE_DUAL_ABI ? 2 : 0))
70 
71  // Convert string to numeric value of type _Tp and store results.
72  // NB: This is specialized for all required types, there is no
73  // generic definition.
74  template<typename _Tp>
75  void
76  __convert_to_v(const char*, _Tp&, ios_base::iostate&,
77  const __c_locale&) throw();
78 
79  // Explicit specializations for required types.
80  template<>
81  void
82  __convert_to_v(const char*, float&, ios_base::iostate&,
83  const __c_locale&) throw();
84 
85  template<>
86  void
87  __convert_to_v(const char*, double&, ios_base::iostate&,
88  const __c_locale&) throw();
89 
90  template<>
91  void
92  __convert_to_v(const char*, long double&, ios_base::iostate&,
93  const __c_locale&) throw();
94 
95  // NB: __pad is a struct, rather than a function, so it can be
96  // partially-specialized.
97  template<typename _CharT, typename _Traits>
98  struct __pad
99  {
100  static void
101  _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
102  const _CharT* __olds, streamsize __newlen, streamsize __oldlen);
103  };
104 
105  // Used by both numeric and monetary facets.
106  // Inserts "group separator" characters into an array of characters.
107  // It's recursive, one iteration per group. It moves the characters
108  // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
109  // only with __gsize != 0.
110  template<typename _CharT>
111  _CharT*
112  __add_grouping(_CharT* __s, _CharT __sep,
113  const char* __gbeg, size_t __gsize,
114  const _CharT* __first, const _CharT* __last);
115 
116  // This template permits specializing facet output code for
117  // ostreambuf_iterator. For ostreambuf_iterator, sputn is
118  // significantly more efficient than incrementing iterators.
119  template<typename _CharT>
120  inline
121  ostreambuf_iterator<_CharT>
122  __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
123  {
124  __s._M_put(__ws, __len);
125  return __s;
126  }
127 
128  // This is the unspecialized form of the template.
129  template<typename _CharT, typename _OutIter>
130  inline
131  _OutIter
132  __write(_OutIter __s, const _CharT* __ws, int __len)
133  {
134  for (int __j = 0; __j < __len; __j++, ++__s)
135  *__s = __ws[__j];
136  return __s;
137  }
138 
139 
140  // 22.2.1.1 Template class ctype
141  // Include host and configuration specific ctype enums for ctype_base.
142 
143  /**
144  * @brief Common base for ctype facet
145  *
146  * This template class provides implementations of the public functions
147  * that forward to the protected virtual functions.
148  *
149  * This template also provides abstract stubs for the protected virtual
150  * functions.
151  */
152  template<typename _CharT>
154  {
155  public:
156  // Types:
157  /// Typedef for the template parameter
158  typedef _CharT char_type;
159 
160  /**
161  * @brief Test char_type classification.
162  *
163  * This function finds a mask M for @a __c and compares it to
164  * mask @a __m. It does so by returning the value of
165  * ctype<char_type>::do_is().
166  *
167  * @param __c The char_type to compare the mask of.
168  * @param __m The mask to compare against.
169  * @return (M & __m) != 0.
170  */
171  bool
172  is(mask __m, char_type __c) const
173  { return this->do_is(__m, __c); }
174 
175  /**
176  * @brief Return a mask array.
177  *
178  * This function finds the mask for each char_type in the range [lo,hi)
179  * and successively writes it to vec. vec must have as many elements
180  * as the char array. It does so by returning the value of
181  * ctype<char_type>::do_is().
182  *
183  * @param __lo Pointer to start of range.
184  * @param __hi Pointer to end of range.
185  * @param __vec Pointer to an array of mask storage.
186  * @return @a __hi.
187  */
188  const char_type*
189  is(const char_type *__lo, const char_type *__hi, mask *__vec) const
190  { return this->do_is(__lo, __hi, __vec); }
191 
192  /**
193  * @brief Find char_type matching a mask
194  *
195  * This function searches for and returns the first char_type c in
196  * [lo,hi) for which is(m,c) is true. It does so by returning
197  * ctype<char_type>::do_scan_is().
198  *
199  * @param __m The mask to compare against.
200  * @param __lo Pointer to start of range.
201  * @param __hi Pointer to end of range.
202  * @return Pointer to matching char_type if found, else @a __hi.
203  */
204  const char_type*
205  scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
206  { return this->do_scan_is(__m, __lo, __hi); }
207 
208  /**
209  * @brief Find char_type not matching a mask
210  *
211  * This function searches for and returns the first char_type c in
212  * [lo,hi) for which is(m,c) is false. It does so by returning
213  * ctype<char_type>::do_scan_not().
214  *
215  * @param __m The mask to compare against.
216  * @param __lo Pointer to first char in range.
217  * @param __hi Pointer to end of range.
218  * @return Pointer to non-matching char if found, else @a __hi.
219  */
220  const char_type*
221  scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
222  { return this->do_scan_not(__m, __lo, __hi); }
223 
224  /**
225  * @brief Convert to uppercase.
226  *
227  * This function converts the argument to uppercase if possible.
228  * If not possible (for example, '2'), returns the argument. It does
229  * so by returning ctype<char_type>::do_toupper().
230  *
231  * @param __c The char_type to convert.
232  * @return The uppercase char_type if convertible, else @a __c.
233  */
234  char_type
235  toupper(char_type __c) const
236  { return this->do_toupper(__c); }
237 
238  /**
239  * @brief Convert array to uppercase.
240  *
241  * This function converts each char_type in the range [lo,hi) to
242  * uppercase if possible. Other elements remain untouched. It does so
243  * by returning ctype<char_type>:: do_toupper(lo, hi).
244  *
245  * @param __lo Pointer to start of range.
246  * @param __hi Pointer to end of range.
247  * @return @a __hi.
248  */
249  const char_type*
250  toupper(char_type *__lo, const char_type* __hi) const
251  { return this->do_toupper(__lo, __hi); }
252 
253  /**
254  * @brief Convert to lowercase.
255  *
256  * This function converts the argument to lowercase if possible. If
257  * not possible (for example, '2'), returns the argument. It does so
258  * by returning ctype<char_type>::do_tolower(c).
259  *
260  * @param __c The char_type to convert.
261  * @return The lowercase char_type if convertible, else @a __c.
262  */
263  char_type
264  tolower(char_type __c) const
265  { return this->do_tolower(__c); }
266 
267  /**
268  * @brief Convert array to lowercase.
269  *
270  * This function converts each char_type in the range [__lo,__hi) to
271  * lowercase if possible. Other elements remain untouched. It does so
272  * by returning ctype<char_type>:: do_tolower(__lo, __hi).
273  *
274  * @param __lo Pointer to start of range.
275  * @param __hi Pointer to end of range.
276  * @return @a __hi.
277  */
278  const char_type*
279  tolower(char_type* __lo, const char_type* __hi) const
280  { return this->do_tolower(__lo, __hi); }
281 
282  /**
283  * @brief Widen char to char_type
284  *
285  * This function converts the char argument to char_type using the
286  * simplest reasonable transformation. It does so by returning
287  * ctype<char_type>::do_widen(c).
288  *
289  * Note: this is not what you want for codepage conversions. See
290  * codecvt for that.
291  *
292  * @param __c The char to convert.
293  * @return The converted char_type.
294  */
295  char_type
296  widen(char __c) const
297  { return this->do_widen(__c); }
298 
299  /**
300  * @brief Widen array to char_type
301  *
302  * This function converts each char in the input to char_type using the
303  * simplest reasonable transformation. It does so by returning
304  * ctype<char_type>::do_widen(c).
305  *
306  * Note: this is not what you want for codepage conversions. See
307  * codecvt for that.
308  *
309  * @param __lo Pointer to start of range.
310  * @param __hi Pointer to end of range.
311  * @param __to Pointer to the destination array.
312  * @return @a __hi.
313  */
314  const char*
315  widen(const char* __lo, const char* __hi, char_type* __to) const
316  { return this->do_widen(__lo, __hi, __to); }
317 
318  /**
319  * @brief Narrow char_type to char
320  *
321  * This function converts the char_type to char using the simplest
322  * reasonable transformation. If the conversion fails, dfault is
323  * returned instead. It does so by returning
324  * ctype<char_type>::do_narrow(__c).
325  *
326  * Note: this is not what you want for codepage conversions. See
327  * codecvt for that.
328  *
329  * @param __c The char_type to convert.
330  * @param __dfault Char to return if conversion fails.
331  * @return The converted char.
332  */
333  char
334  narrow(char_type __c, char __dfault) const
335  { return this->do_narrow(__c, __dfault); }
336 
337  /**
338  * @brief Narrow array to char array
339  *
340  * This function converts each char_type in the input to char using the
341  * simplest reasonable transformation and writes the results to the
342  * destination array. For any char_type in the input that cannot be
343  * converted, @a dfault is used instead. It does so by returning
344  * ctype<char_type>::do_narrow(__lo, __hi, __dfault, __to).
345  *
346  * Note: this is not what you want for codepage conversions. See
347  * codecvt for that.
348  *
349  * @param __lo Pointer to start of range.
350  * @param __hi Pointer to end of range.
351  * @param __dfault Char to use if conversion fails.
352  * @param __to Pointer to the destination array.
353  * @return @a __hi.
354  */
355  const char_type*
356  narrow(const char_type* __lo, const char_type* __hi,
357  char __dfault, char* __to) const
358  { return this->do_narrow(__lo, __hi, __dfault, __to); }
359 
360  protected:
361  explicit
362  __ctype_abstract_base(size_t __refs = 0): facet(__refs) { }
363 
364  virtual
365  ~__ctype_abstract_base() { }
366 
367  /**
368  * @brief Test char_type classification.
369  *
370  * This function finds a mask M for @a c and compares it to mask @a m.
371  *
372  * do_is() is a hook for a derived facet to change the behavior of
373  * classifying. do_is() must always return the same result for the
374  * same input.
375  *
376  * @param __c The char_type to find the mask of.
377  * @param __m The mask to compare against.
378  * @return (M & __m) != 0.
379  */
380  virtual bool
381  do_is(mask __m, char_type __c) const = 0;
382 
383  /**
384  * @brief Return a mask array.
385  *
386  * This function finds the mask for each char_type in the range [lo,hi)
387  * and successively writes it to vec. vec must have as many elements
388  * as the input.
389  *
390  * do_is() is a hook for a derived facet to change the behavior of
391  * classifying. do_is() must always return the same result for the
392  * same input.
393  *
394  * @param __lo Pointer to start of range.
395  * @param __hi Pointer to end of range.
396  * @param __vec Pointer to an array of mask storage.
397  * @return @a __hi.
398  */
399  virtual const char_type*
400  do_is(const char_type* __lo, const char_type* __hi,
401  mask* __vec) const = 0;
402 
403  /**
404  * @brief Find char_type matching mask
405  *
406  * This function searches for and returns the first char_type c in
407  * [__lo,__hi) for which is(__m,c) is true.
408  *
409  * do_scan_is() is a hook for a derived facet to change the behavior of
410  * match searching. do_is() must always return the same result for the
411  * same input.
412  *
413  * @param __m The mask to compare against.
414  * @param __lo Pointer to start of range.
415  * @param __hi Pointer to end of range.
416  * @return Pointer to a matching char_type if found, else @a __hi.
417  */
418  virtual const char_type*
419  do_scan_is(mask __m, const char_type* __lo,
420  const char_type* __hi) const = 0;
421 
422  /**
423  * @brief Find char_type not matching mask
424  *
425  * This function searches for and returns a pointer to the first
426  * char_type c of [lo,hi) for which is(m,c) is false.
427  *
428  * do_scan_is() is a hook for a derived facet to change the behavior of
429  * match searching. do_is() must always return the same result for the
430  * same input.
431  *
432  * @param __m The mask to compare against.
433  * @param __lo Pointer to start of range.
434  * @param __hi Pointer to end of range.
435  * @return Pointer to a non-matching char_type if found, else @a __hi.
436  */
437  virtual const char_type*
438  do_scan_not(mask __m, const char_type* __lo,
439  const char_type* __hi) const = 0;
440 
441  /**
442  * @brief Convert to uppercase.
443  *
444  * This virtual function converts the char_type argument to uppercase
445  * if possible. If not possible (for example, '2'), returns the
446  * argument.
447  *
448  * do_toupper() is a hook for a derived facet to change the behavior of
449  * uppercasing. do_toupper() must always return the same result for
450  * the same input.
451  *
452  * @param __c The char_type to convert.
453  * @return The uppercase char_type if convertible, else @a __c.
454  */
455  virtual char_type
456  do_toupper(char_type __c) const = 0;
457 
458  /**
459  * @brief Convert array to uppercase.
460  *
461  * This virtual function converts each char_type in the range [__lo,__hi)
462  * to uppercase if possible. Other elements remain untouched.
463  *
464  * do_toupper() is a hook for a derived facet to change the behavior of
465  * uppercasing. do_toupper() must always return the same result for
466  * the same input.
467  *
468  * @param __lo Pointer to start of range.
469  * @param __hi Pointer to end of range.
470  * @return @a __hi.
471  */
472  virtual const char_type*
473  do_toupper(char_type* __lo, const char_type* __hi) const = 0;
474 
475  /**
476  * @brief Convert to lowercase.
477  *
478  * This virtual function converts the argument to lowercase if
479  * possible. If not possible (for example, '2'), returns the argument.
480  *
481  * do_tolower() is a hook for a derived facet to change the behavior of
482  * lowercasing. do_tolower() must always return the same result for
483  * the same input.
484  *
485  * @param __c The char_type to convert.
486  * @return The lowercase char_type if convertible, else @a __c.
487  */
488  virtual char_type
489  do_tolower(char_type __c) const = 0;
490 
491  /**
492  * @brief Convert array to lowercase.
493  *
494  * This virtual function converts each char_type in the range [__lo,__hi)
495  * to lowercase if possible. Other elements remain untouched.
496  *
497  * do_tolower() is a hook for a derived facet to change the behavior of
498  * lowercasing. do_tolower() must always return the same result for
499  * the same input.
500  *
501  * @param __lo Pointer to start of range.
502  * @param __hi Pointer to end of range.
503  * @return @a __hi.
504  */
505  virtual const char_type*
506  do_tolower(char_type* __lo, const char_type* __hi) const = 0;
507 
508  /**
509  * @brief Widen char
510  *
511  * This virtual function converts the char to char_type using the
512  * simplest reasonable transformation.
513  *
514  * do_widen() is a hook for a derived facet to change the behavior of
515  * widening. do_widen() must always return the same result for the
516  * same input.
517  *
518  * Note: this is not what you want for codepage conversions. See
519  * codecvt for that.
520  *
521  * @param __c The char to convert.
522  * @return The converted char_type
523  */
524  virtual char_type
525  do_widen(char __c) const = 0;
526 
527  /**
528  * @brief Widen char array
529  *
530  * This function converts each char in the input to char_type using the
531  * simplest reasonable transformation.
532  *
533  * do_widen() is a hook for a derived facet to change the behavior of
534  * widening. do_widen() must always return the same result for the
535  * same input.
536  *
537  * Note: this is not what you want for codepage conversions. See
538  * codecvt for that.
539  *
540  * @param __lo Pointer to start range.
541  * @param __hi Pointer to end of range.
542  * @param __to Pointer to the destination array.
543  * @return @a __hi.
544  */
545  virtual const char*
546  do_widen(const char* __lo, const char* __hi, char_type* __to) const = 0;
547 
548  /**
549  * @brief Narrow char_type to char
550  *
551  * This virtual function converts the argument to char using the
552  * simplest reasonable transformation. If the conversion fails, dfault
553  * is returned instead.
554  *
555  * do_narrow() is a hook for a derived facet to change the behavior of
556  * narrowing. do_narrow() must always return the same result for the
557  * same input.
558  *
559  * Note: this is not what you want for codepage conversions. See
560  * codecvt for that.
561  *
562  * @param __c The char_type to convert.
563  * @param __dfault Char to return if conversion fails.
564  * @return The converted char.
565  */
566  virtual char
567  do_narrow(char_type __c, char __dfault) const = 0;
568 
569  /**
570  * @brief Narrow char_type array to char
571  *
572  * This virtual function converts each char_type in the range
573  * [__lo,__hi) to char using the simplest reasonable
574  * transformation and writes the results to the destination
575  * array. For any element in the input that cannot be
576  * converted, @a __dfault is used instead.
577  *
578  * do_narrow() is a hook for a derived facet to change the behavior of
579  * narrowing. do_narrow() must always return the same result for the
580  * same input.
581  *
582  * Note: this is not what you want for codepage conversions. See
583  * codecvt for that.
584  *
585  * @param __lo Pointer to start of range.
586  * @param __hi Pointer to end of range.
587  * @param __dfault Char to use if conversion fails.
588  * @param __to Pointer to the destination array.
589  * @return @a __hi.
590  */
591  virtual const char_type*
592  do_narrow(const char_type* __lo, const char_type* __hi,
593  char __dfault, char* __to) const = 0;
594  };
595 
596  /**
597  * @brief Primary class template ctype facet.
598  * @ingroup locales
599  *
600  * This template class defines classification and conversion functions for
601  * character sets. It wraps cctype functionality. Ctype gets used by
602  * streams for many I/O operations.
603  *
604  * This template provides the protected virtual functions the developer
605  * will have to replace in a derived class or specialization to make a
606  * working facet. The public functions that access them are defined in
607  * __ctype_abstract_base, to allow for implementation flexibility. See
608  * ctype<wchar_t> for an example. The functions are documented in
609  * __ctype_abstract_base.
610  *
611  * Note: implementations are provided for all the protected virtual
612  * functions, but will likely not be useful.
613  */
614  template<typename _CharT>
615  class ctype : public __ctype_abstract_base<_CharT>
616  {
617  public:
618  // Types:
619  typedef _CharT char_type;
620  typedef typename __ctype_abstract_base<_CharT>::mask mask;
621 
622  /// The facet id for ctype<char_type>
623  static locale::id id;
624 
625  explicit
626  ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
627 
628  protected:
629  virtual
630  ~ctype();
631 
632  virtual bool
633  do_is(mask __m, char_type __c) const;
634 
635  virtual const char_type*
636  do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
637 
638  virtual const char_type*
639  do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
640 
641  virtual const char_type*
642  do_scan_not(mask __m, const char_type* __lo,
643  const char_type* __hi) const;
644 
645  virtual char_type
646  do_toupper(char_type __c) const;
647 
648  virtual const char_type*
649  do_toupper(char_type* __lo, const char_type* __hi) const;
650 
651  virtual char_type
652  do_tolower(char_type __c) const;
653 
654  virtual const char_type*
655  do_tolower(char_type* __lo, const char_type* __hi) const;
656 
657  virtual char_type
658  do_widen(char __c) const;
659 
660  virtual const char*
661  do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
662 
663  virtual char
664  do_narrow(char_type, char __dfault) const;
665 
666  virtual const char_type*
667  do_narrow(const char_type* __lo, const char_type* __hi,
668  char __dfault, char* __to) const;
669  };
670 
671  template<typename _CharT>
672  locale::id ctype<_CharT>::id;
673 
674  // Incomplete to provide a compile time diagnostics for common misuse
675  // of [locale.convenience] functions with basic_string as a character type.
676  template<typename _CharT, typename _Traits, typename _Alloc>
677  class ctype<basic_string<_CharT, _Traits, _Alloc> >;
678 
679  /**
680  * @brief The ctype<char> specialization.
681  * @ingroup locales
682  *
683  * This class defines classification and conversion functions for
684  * the char type. It gets used by char streams for many I/O
685  * operations. The char specialization provides a number of
686  * optimizations as well.
687  */
688  template<>
689  class ctype<char> : public locale::facet, public ctype_base
690  {
691  public:
692  // Types:
693  /// Typedef for the template parameter char.
694  typedef char char_type;
695 
696  protected:
697  // Data Members:
698  __c_locale _M_c_locale_ctype;
699  bool _M_del;
700  __to_type _M_toupper;
701  __to_type _M_tolower;
702  const mask* _M_table;
703  mutable char _M_widen_ok;
704  mutable char _M_widen[1 + static_cast<unsigned char>(-1)];
705  mutable char _M_narrow[1 + static_cast<unsigned char>(-1)];
706  mutable char _M_narrow_ok; // 0 uninitialized, 1 init,
707  // 2 memcpy can't be used
708 
709  public:
710  /// The facet id for ctype<char>
711  static locale::id id;
712  /// The size of the mask table. It is SCHAR_MAX + 1.
713  static const size_t table_size = 1 + static_cast<unsigned char>(-1);
714 
715  /**
716  * @brief Constructor performs initialization.
717  *
718  * This is the constructor provided by the standard.
719  *
720  * @param __table If non-zero, table is used as the per-char mask.
721  * Else classic_table() is used.
722  * @param __del If true, passes ownership of table to this facet.
723  * @param __refs Passed to the base facet class.
724  */
725  explicit
726  ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
727 
728  /**
729  * @brief Constructor performs static initialization.
730  *
731  * This constructor is used to construct the initial C locale facet.
732  *
733  * @param __cloc Handle to C locale data.
734  * @param __table If non-zero, table is used as the per-char mask.
735  * @param __del If true, passes ownership of table to this facet.
736  * @param __refs Passed to the base facet class.
737  */
738  explicit
739  ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false,
740  size_t __refs = 0);
741 
742  /**
743  * @brief Test char classification.
744  *
745  * This function compares the mask table[c] to @a __m.
746  *
747  * @param __c The char to compare the mask of.
748  * @param __m The mask to compare against.
749  * @return True if __m & table[__c] is true, false otherwise.
750  */
751  inline bool
752  is(mask __m, char __c) const;
753 
754  /**
755  * @brief Return a mask array.
756  *
757  * This function finds the mask for each char in the range [lo, hi) and
758  * successively writes it to vec. vec must have as many elements as
759  * the char array.
760  *
761  * @param __lo Pointer to start of range.
762  * @param __hi Pointer to end of range.
763  * @param __vec Pointer to an array of mask storage.
764  * @return @a __hi.
765  */
766  inline const char*
767  is(const char* __lo, const char* __hi, mask* __vec) const;
768 
769  /**
770  * @brief Find char matching a mask
771  *
772  * This function searches for and returns the first char in [lo,hi) for
773  * which is(m,char) is true.
774  *
775  * @param __m The mask to compare against.
776  * @param __lo Pointer to start of range.
777  * @param __hi Pointer to end of range.
778  * @return Pointer to a matching char if found, else @a __hi.
779  */
780  inline const char*
781  scan_is(mask __m, const char* __lo, const char* __hi) const;
782 
783  /**
784  * @brief Find char not matching a mask
785  *
786  * This function searches for and returns a pointer to the first char
787  * in [__lo,__hi) for which is(m,char) is false.
788  *
789  * @param __m The mask to compare against.
790  * @param __lo Pointer to start of range.
791  * @param __hi Pointer to end of range.
792  * @return Pointer to a non-matching char if found, else @a __hi.
793  */
794  inline const char*
795  scan_not(mask __m, const char* __lo, const char* __hi) const;
796 
797  /**
798  * @brief Convert to uppercase.
799  *
800  * This function converts the char argument to uppercase if possible.
801  * If not possible (for example, '2'), returns the argument.
802  *
803  * toupper() acts as if it returns ctype<char>::do_toupper(c).
804  * do_toupper() must always return the same result for the same input.
805  *
806  * @param __c The char to convert.
807  * @return The uppercase char if convertible, else @a __c.
808  */
809  char_type
810  toupper(char_type __c) const
811  { return this->do_toupper(__c); }
812 
813  /**
814  * @brief Convert array to uppercase.
815  *
816  * This function converts each char in the range [__lo,__hi) to uppercase
817  * if possible. Other chars remain untouched.
818  *
819  * toupper() acts as if it returns ctype<char>:: do_toupper(__lo, __hi).
820  * do_toupper() must always return the same result for the same input.
821  *
822  * @param __lo Pointer to first char in range.
823  * @param __hi Pointer to end of range.
824  * @return @a __hi.
825  */
826  const char_type*
827  toupper(char_type *__lo, const char_type* __hi) const
828  { return this->do_toupper(__lo, __hi); }
829 
830  /**
831  * @brief Convert to lowercase.
832  *
833  * This function converts the char argument to lowercase if possible.
834  * If not possible (for example, '2'), returns the argument.
835  *
836  * tolower() acts as if it returns ctype<char>::do_tolower(__c).
837  * do_tolower() must always return the same result for the same input.
838  *
839  * @param __c The char to convert.
840  * @return The lowercase char if convertible, else @a __c.
841  */
842  char_type
843  tolower(char_type __c) const
844  { return this->do_tolower(__c); }
845 
846  /**
847  * @brief Convert array to lowercase.
848  *
849  * This function converts each char in the range [lo,hi) to lowercase
850  * if possible. Other chars remain untouched.
851  *
852  * tolower() acts as if it returns ctype<char>:: do_tolower(__lo, __hi).
853  * do_tolower() must always return the same result for the same input.
854  *
855  * @param __lo Pointer to first char in range.
856  * @param __hi Pointer to end of range.
857  * @return @a __hi.
858  */
859  const char_type*
860  tolower(char_type* __lo, const char_type* __hi) const
861  { return this->do_tolower(__lo, __hi); }
862 
863  /**
864  * @brief Widen char
865  *
866  * This function converts the char to char_type using the simplest
867  * reasonable transformation. For an underived ctype<char> facet, the
868  * argument will be returned unchanged.
869  *
870  * This function works as if it returns ctype<char>::do_widen(c).
871  * do_widen() must always return the same result for the same input.
872  *
873  * Note: this is not what you want for codepage conversions. See
874  * codecvt for that.
875  *
876  * @param __c The char to convert.
877  * @return The converted character.
878  */
879  char_type
880  widen(char __c) const
881  {
882  if (_M_widen_ok)
883  return _M_widen[static_cast<unsigned char>(__c)];
884  this->_M_widen_init();
885  return this->do_widen(__c);
886  }
887 
888  /**
889  * @brief Widen char array
890  *
891  * This function converts each char in the input to char using the
892  * simplest reasonable transformation. For an underived ctype<char>
893  * facet, the argument will be copied unchanged.
894  *
895  * This function works as if it returns ctype<char>::do_widen(c).
896  * do_widen() must always return the same result for the same input.
897  *
898  * Note: this is not what you want for codepage conversions. See
899  * codecvt for that.
900  *
901  * @param __lo Pointer to first char in range.
902  * @param __hi Pointer to end of range.
903  * @param __to Pointer to the destination array.
904  * @return @a __hi.
905  */
906  const char*
907  widen(const char* __lo, const char* __hi, char_type* __to) const
908  {
909  if (_M_widen_ok == 1)
910  {
911  if (__builtin_expect(__hi != __lo, true))
912  __builtin_memcpy(__to, __lo, __hi - __lo);
913  return __hi;
914  }
915  if (!_M_widen_ok)
916  _M_widen_init();
917  return this->do_widen(__lo, __hi, __to);
918  }
919 
920  /**
921  * @brief Narrow char
922  *
923  * This function converts the char to char using the simplest
924  * reasonable transformation. If the conversion fails, dfault is
925  * returned instead. For an underived ctype<char> facet, @a c
926  * will be returned unchanged.
927  *
928  * This function works as if it returns ctype<char>::do_narrow(c).
929  * do_narrow() must always return the same result for the same input.
930  *
931  * Note: this is not what you want for codepage conversions. See
932  * codecvt for that.
933  *
934  * @param __c The char to convert.
935  * @param __dfault Char to return if conversion fails.
936  * @return The converted character.
937  */
938  char
939  narrow(char_type __c, char __dfault) const
940  {
941  if (_M_narrow[static_cast<unsigned char>(__c)])
942  return _M_narrow[static_cast<unsigned char>(__c)];
943  const char __t = do_narrow(__c, __dfault);
944  if (__t != __dfault)
945  _M_narrow[static_cast<unsigned char>(__c)] = __t;
946  return __t;
947  }
948 
949  /**
950  * @brief Narrow char array
951  *
952  * This function converts each char in the input to char using the
953  * simplest reasonable transformation and writes the results to the
954  * destination array. For any char in the input that cannot be
955  * converted, @a dfault is used instead. For an underived ctype<char>
956  * facet, the argument will be copied unchanged.
957  *
958  * This function works as if it returns ctype<char>::do_narrow(lo, hi,
959  * dfault, to). do_narrow() must always return the same result for the
960  * same input.
961  *
962  * Note: this is not what you want for codepage conversions. See
963  * codecvt for that.
964  *
965  * @param __lo Pointer to start of range.
966  * @param __hi Pointer to end of range.
967  * @param __dfault Char to use if conversion fails.
968  * @param __to Pointer to the destination array.
969  * @return @a __hi.
970  */
971  const char_type*
972  narrow(const char_type* __lo, const char_type* __hi,
973  char __dfault, char* __to) const
974  {
975  if (__builtin_expect(_M_narrow_ok == 1, true))
976  {
977  if (__builtin_expect(__hi != __lo, true))
978  __builtin_memcpy(__to, __lo, __hi - __lo);
979  return __hi;
980  }
981  if (!_M_narrow_ok)
982  _M_narrow_init();
983  return this->do_narrow(__lo, __hi, __dfault, __to);
984  }
985 
986  // _GLIBCXX_RESOLVE_LIB_DEFECTS
987  // DR 695. ctype<char>::classic_table() not accessible.
988  /// Returns a pointer to the mask table provided to the constructor, or
989  /// the default from classic_table() if none was provided.
990  const mask*
991  table() const throw()
992  { return _M_table; }
993 
994  /// Returns a pointer to the C locale mask table.
995  static const mask*
996  classic_table() throw();
997  protected:
998 
999  /**
1000  * @brief Destructor.
1001  *
1002  * This function deletes table() if @a del was true in the
1003  * constructor.
1004  */
1005  virtual
1006  ~ctype();
1007 
1008  /**
1009  * @brief Convert to uppercase.
1010  *
1011  * This virtual function converts the char argument to uppercase if
1012  * possible. If not possible (for example, '2'), returns the argument.
1013  *
1014  * do_toupper() is a hook for a derived facet to change the behavior of
1015  * uppercasing. do_toupper() must always return the same result for
1016  * the same input.
1017  *
1018  * @param __c The char to convert.
1019  * @return The uppercase char if convertible, else @a __c.
1020  */
1021  virtual char_type
1022  do_toupper(char_type __c) const;
1023 
1024  /**
1025  * @brief Convert array to uppercase.
1026  *
1027  * This virtual function converts each char in the range [lo,hi) to
1028  * uppercase if possible. Other chars remain untouched.
1029  *
1030  * do_toupper() is a hook for a derived facet to change the behavior of
1031  * uppercasing. do_toupper() must always return the same result for
1032  * the same input.
1033  *
1034  * @param __lo Pointer to start of range.
1035  * @param __hi Pointer to end of range.
1036  * @return @a __hi.
1037  */
1038  virtual const char_type*
1039  do_toupper(char_type* __lo, const char_type* __hi) const;
1040 
1041  /**
1042  * @brief Convert to lowercase.
1043  *
1044  * This virtual function converts the char argument to lowercase if
1045  * possible. If not possible (for example, '2'), returns the argument.
1046  *
1047  * do_tolower() is a hook for a derived facet to change the behavior of
1048  * lowercasing. do_tolower() must always return the same result for
1049  * the same input.
1050  *
1051  * @param __c The char to convert.
1052  * @return The lowercase char if convertible, else @a __c.
1053  */
1054  virtual char_type
1055  do_tolower(char_type __c) const;
1056 
1057  /**
1058  * @brief Convert array to lowercase.
1059  *
1060  * This virtual function converts each char in the range [lo,hi) to
1061  * lowercase if possible. Other chars remain untouched.
1062  *
1063  * do_tolower() is a hook for a derived facet to change the behavior of
1064  * lowercasing. do_tolower() must always return the same result for
1065  * the same input.
1066  *
1067  * @param __lo Pointer to first char in range.
1068  * @param __hi Pointer to end of range.
1069  * @return @a __hi.
1070  */
1071  virtual const char_type*
1072  do_tolower(char_type* __lo, const char_type* __hi) const;
1073 
1074  /**
1075  * @brief Widen char
1076  *
1077  * This virtual function converts the char to char using the simplest
1078  * reasonable transformation. For an underived ctype<char> facet, the
1079  * argument will be returned unchanged.
1080  *
1081  * do_widen() is a hook for a derived facet to change the behavior of
1082  * widening. do_widen() must always return the same result for the
1083  * same input.
1084  *
1085  * Note: this is not what you want for codepage conversions. See
1086  * codecvt for that.
1087  *
1088  * @param __c The char to convert.
1089  * @return The converted character.
1090  */
1091  virtual char_type
1092  do_widen(char __c) const
1093  { return __c; }
1094 
1095  /**
1096  * @brief Widen char array
1097  *
1098  * This function converts each char in the range [lo,hi) to char using
1099  * the simplest reasonable transformation. For an underived
1100  * ctype<char> facet, the argument will be copied unchanged.
1101  *
1102  * do_widen() is a hook for a derived facet to change the behavior of
1103  * widening. do_widen() must always return the same result for the
1104  * same input.
1105  *
1106  * Note: this is not what you want for codepage conversions. See
1107  * codecvt for that.
1108  *
1109  * @param __lo Pointer to start of range.
1110  * @param __hi Pointer to end of range.
1111  * @param __to Pointer to the destination array.
1112  * @return @a __hi.
1113  */
1114  virtual const char*
1115  do_widen(const char* __lo, const char* __hi, char_type* __to) const
1116  {
1117  if (__builtin_expect(__hi != __lo, true))
1118  __builtin_memcpy(__to, __lo, __hi - __lo);
1119  return __hi;
1120  }
1121 
1122  /**
1123  * @brief Narrow char
1124  *
1125  * This virtual function converts the char to char using the simplest
1126  * reasonable transformation. If the conversion fails, dfault is
1127  * returned instead. For an underived ctype<char> facet, @a c will be
1128  * returned unchanged.
1129  *
1130  * do_narrow() is a hook for a derived facet to change the behavior of
1131  * narrowing. do_narrow() must always return the same result for the
1132  * same input.
1133  *
1134  * Note: this is not what you want for codepage conversions. See
1135  * codecvt for that.
1136  *
1137  * @param __c The char to convert.
1138  * @param __dfault Char to return if conversion fails.
1139  * @return The converted char.
1140  */
1141  virtual char
1142  do_narrow(char_type __c, char __dfault __attribute__((__unused__))) const
1143  { return __c; }
1144 
1145  /**
1146  * @brief Narrow char array to char array
1147  *
1148  * This virtual function converts each char in the range [lo,hi) to
1149  * char using the simplest reasonable transformation and writes the
1150  * results to the destination array. For any char in the input that
1151  * cannot be converted, @a dfault is used instead. For an underived
1152  * ctype<char> facet, the argument will be copied unchanged.
1153  *
1154  * do_narrow() is a hook for a derived facet to change the behavior of
1155  * narrowing. do_narrow() must always return the same result for the
1156  * same input.
1157  *
1158  * Note: this is not what you want for codepage conversions. See
1159  * codecvt for that.
1160  *
1161  * @param __lo Pointer to start of range.
1162  * @param __hi Pointer to end of range.
1163  * @param __dfault Char to use if conversion fails.
1164  * @param __to Pointer to the destination array.
1165  * @return @a __hi.
1166  */
1167  virtual const char_type*
1168  do_narrow(const char_type* __lo, const char_type* __hi,
1169  char __dfault __attribute__((__unused__)), char* __to) const
1170  {
1171  if (__builtin_expect(__hi != __lo, true))
1172  __builtin_memcpy(__to, __lo, __hi - __lo);
1173  return __hi;
1174  }
1175 
1176  private:
1177  void _M_narrow_init() const;
1178  void _M_widen_init() const;
1179  };
1180 
1181 #ifdef _GLIBCXX_USE_WCHAR_T
1182  /**
1183  * @brief The ctype<wchar_t> specialization.
1184  * @ingroup locales
1185  *
1186  * This class defines classification and conversion functions for the
1187  * wchar_t type. It gets used by wchar_t streams for many I/O operations.
1188  * The wchar_t specialization provides a number of optimizations as well.
1189  *
1190  * ctype<wchar_t> inherits its public methods from
1191  * __ctype_abstract_base<wchar_t>.
1192  */
1193  template<>
1194  class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
1195  {
1196  public:
1197  // Types:
1198  /// Typedef for the template parameter wchar_t.
1199  typedef wchar_t char_type;
1200  typedef wctype_t __wmask_type;
1201 
1202  protected:
1203  __c_locale _M_c_locale_ctype;
1204 
1205  // Pre-computed narrowed and widened chars.
1206  bool _M_narrow_ok;
1207  char _M_narrow[128];
1208  wint_t _M_widen[1 + static_cast<unsigned char>(-1)];
1209 
1210  // Pre-computed elements for do_is.
1211  mask _M_bit[16];
1212  __wmask_type _M_wmask[16];
1213 
1214  public:
1215  // Data Members:
1216  /// The facet id for ctype<wchar_t>
1217  static locale::id id;
1218 
1219  /**
1220  * @brief Constructor performs initialization.
1221  *
1222  * This is the constructor provided by the standard.
1223  *
1224  * @param __refs Passed to the base facet class.
1225  */
1226  explicit
1227  ctype(size_t __refs = 0);
1228 
1229  /**
1230  * @brief Constructor performs static initialization.
1231  *
1232  * This constructor is used to construct the initial C locale facet.
1233  *
1234  * @param __cloc Handle to C locale data.
1235  * @param __refs Passed to the base facet class.
1236  */
1237  explicit
1238  ctype(__c_locale __cloc, size_t __refs = 0);
1239 
1240  protected:
1241  __wmask_type
1242  _M_convert_to_wmask(const mask __m) const throw();
1243 
1244  /// Destructor
1245  virtual
1246  ~ctype();
1247 
1248  /**
1249  * @brief Test wchar_t classification.
1250  *
1251  * This function finds a mask M for @a c and compares it to mask @a m.
1252  *
1253  * do_is() is a hook for a derived facet to change the behavior of
1254  * classifying. do_is() must always return the same result for the
1255  * same input.
1256  *
1257  * @param __c The wchar_t to find the mask of.
1258  * @param __m The mask to compare against.
1259  * @return (M & __m) != 0.
1260  */
1261  virtual bool
1262  do_is(mask __m, char_type __c) const;
1263 
1264  /**
1265  * @brief Return a mask array.
1266  *
1267  * This function finds the mask for each wchar_t in the range [lo,hi)
1268  * and successively writes it to vec. vec must have as many elements
1269  * as the input.
1270  *
1271  * do_is() is a hook for a derived facet to change the behavior of
1272  * classifying. do_is() must always return the same result for the
1273  * same input.
1274  *
1275  * @param __lo Pointer to start of range.
1276  * @param __hi Pointer to end of range.
1277  * @param __vec Pointer to an array of mask storage.
1278  * @return @a __hi.
1279  */
1280  virtual const char_type*
1281  do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
1282 
1283  /**
1284  * @brief Find wchar_t matching mask
1285  *
1286  * This function searches for and returns the first wchar_t c in
1287  * [__lo,__hi) for which is(__m,c) is true.
1288  *
1289  * do_scan_is() is a hook for a derived facet to change the behavior of
1290  * match searching. do_is() must always return the same result for the
1291  * same input.
1292  *
1293  * @param __m The mask to compare against.
1294  * @param __lo Pointer to start of range.
1295  * @param __hi Pointer to end of range.
1296  * @return Pointer to a matching wchar_t if found, else @a __hi.
1297  */
1298  virtual const char_type*
1299  do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
1300 
1301  /**
1302  * @brief Find wchar_t not matching mask
1303  *
1304  * This function searches for and returns a pointer to the first
1305  * wchar_t c of [__lo,__hi) for which is(__m,c) is false.
1306  *
1307  * do_scan_is() is a hook for a derived facet to change the behavior of
1308  * match searching. do_is() must always return the same result for the
1309  * same input.
1310  *
1311  * @param __m The mask to compare against.
1312  * @param __lo Pointer to start of range.
1313  * @param __hi Pointer to end of range.
1314  * @return Pointer to a non-matching wchar_t if found, else @a __hi.
1315  */
1316  virtual const char_type*
1317  do_scan_not(mask __m, const char_type* __lo,
1318  const char_type* __hi) const;
1319 
1320  /**
1321  * @brief Convert to uppercase.
1322  *
1323  * This virtual function converts the wchar_t argument to uppercase if
1324  * possible. If not possible (for example, '2'), returns the argument.
1325  *
1326  * do_toupper() is a hook for a derived facet to change the behavior of
1327  * uppercasing. do_toupper() must always return the same result for
1328  * the same input.
1329  *
1330  * @param __c The wchar_t to convert.
1331  * @return The uppercase wchar_t if convertible, else @a __c.
1332  */
1333  virtual char_type
1334  do_toupper(char_type __c) const;
1335 
1336  /**
1337  * @brief Convert array to uppercase.
1338  *
1339  * This virtual function converts each wchar_t in the range [lo,hi) to
1340  * uppercase if possible. Other elements remain untouched.
1341  *
1342  * do_toupper() is a hook for a derived facet to change the behavior of
1343  * uppercasing. do_toupper() must always return the same result for
1344  * the same input.
1345  *
1346  * @param __lo Pointer to start of range.
1347  * @param __hi Pointer to end of range.
1348  * @return @a __hi.
1349  */
1350  virtual const char_type*
1351  do_toupper(char_type* __lo, const char_type* __hi) const;
1352 
1353  /**
1354  * @brief Convert to lowercase.
1355  *
1356  * This virtual function converts the argument to lowercase if
1357  * possible. If not possible (for example, '2'), returns the argument.
1358  *
1359  * do_tolower() is a hook for a derived facet to change the behavior of
1360  * lowercasing. do_tolower() must always return the same result for
1361  * the same input.
1362  *
1363  * @param __c The wchar_t to convert.
1364  * @return The lowercase wchar_t if convertible, else @a __c.
1365  */
1366  virtual char_type
1367  do_tolower(char_type __c) const;
1368 
1369  /**
1370  * @brief Convert array to lowercase.
1371  *
1372  * This virtual function converts each wchar_t in the range [lo,hi) to
1373  * lowercase if possible. Other elements remain untouched.
1374  *
1375  * do_tolower() is a hook for a derived facet to change the behavior of
1376  * lowercasing. do_tolower() must always return the same result for
1377  * the same input.
1378  *
1379  * @param __lo Pointer to start of range.
1380  * @param __hi Pointer to end of range.
1381  * @return @a __hi.
1382  */
1383  virtual const char_type*
1384  do_tolower(char_type* __lo, const char_type* __hi) const;
1385 
1386  /**
1387  * @brief Widen char to wchar_t
1388  *
1389  * This virtual function converts the char to wchar_t using the
1390  * simplest reasonable transformation. For an underived ctype<wchar_t>
1391  * facet, the argument will be cast to wchar_t.
1392  *
1393  * do_widen() is a hook for a derived facet to change the behavior of
1394  * widening. do_widen() must always return the same result for the
1395  * same input.
1396  *
1397  * Note: this is not what you want for codepage conversions. See
1398  * codecvt for that.
1399  *
1400  * @param __c The char to convert.
1401  * @return The converted wchar_t.
1402  */
1403  virtual char_type
1404  do_widen(char __c) const;
1405 
1406  /**
1407  * @brief Widen char array to wchar_t array
1408  *
1409  * This function converts each char in the input to wchar_t using the
1410  * simplest reasonable transformation. For an underived ctype<wchar_t>
1411  * facet, the argument will be copied, casting each element to wchar_t.
1412  *
1413  * do_widen() is a hook for a derived facet to change the behavior of
1414  * widening. do_widen() must always return the same result for the
1415  * same input.
1416  *
1417  * Note: this is not what you want for codepage conversions. See
1418  * codecvt for that.
1419  *
1420  * @param __lo Pointer to start range.
1421  * @param __hi Pointer to end of range.
1422  * @param __to Pointer to the destination array.
1423  * @return @a __hi.
1424  */
1425  virtual const char*
1426  do_widen(const char* __lo, const char* __hi, char_type* __to) const;
1427 
1428  /**
1429  * @brief Narrow wchar_t to char
1430  *
1431  * This virtual function converts the argument to char using
1432  * the simplest reasonable transformation. If the conversion
1433  * fails, dfault is returned instead. For an underived
1434  * ctype<wchar_t> facet, @a c will be cast to char and
1435  * returned.
1436  *
1437  * do_narrow() is a hook for a derived facet to change the
1438  * behavior of narrowing. do_narrow() must always return the
1439  * same result for the same input.
1440  *
1441  * Note: this is not what you want for codepage conversions. See
1442  * codecvt for that.
1443  *
1444  * @param __c The wchar_t to convert.
1445  * @param __dfault Char to return if conversion fails.
1446  * @return The converted char.
1447  */
1448  virtual char
1449  do_narrow(char_type __c, char __dfault) const;
1450 
1451  /**
1452  * @brief Narrow wchar_t array to char array
1453  *
1454  * This virtual function converts each wchar_t in the range [lo,hi) to
1455  * char using the simplest reasonable transformation and writes the
1456  * results to the destination array. For any wchar_t in the input that
1457  * cannot be converted, @a dfault is used instead. For an underived
1458  * ctype<wchar_t> facet, the argument will be copied, casting each
1459  * element to char.
1460  *
1461  * do_narrow() is a hook for a derived facet to change the behavior of
1462  * narrowing. do_narrow() must always return the same result for the
1463  * same input.
1464  *
1465  * Note: this is not what you want for codepage conversions. See
1466  * codecvt for that.
1467  *
1468  * @param __lo Pointer to start of range.
1469  * @param __hi Pointer to end of range.
1470  * @param __dfault Char to use if conversion fails.
1471  * @param __to Pointer to the destination array.
1472  * @return @a __hi.
1473  */
1474  virtual const char_type*
1475  do_narrow(const char_type* __lo, const char_type* __hi,
1476  char __dfault, char* __to) const;
1477 
1478  // For use at construction time only.
1479  void
1480  _M_initialize_ctype() throw();
1481  };
1482 #endif //_GLIBCXX_USE_WCHAR_T
1483 
1484  /// class ctype_byname [22.2.1.2].
1485  template<typename _CharT>
1486  class ctype_byname : public ctype<_CharT>
1487  {
1488  public:
1489  typedef typename ctype<_CharT>::mask mask;
1490 
1491  explicit
1492  ctype_byname(const char* __s, size_t __refs = 0);
1493 
1494 #if __cplusplus >= 201103L
1495  explicit
1496  ctype_byname(const string& __s, size_t __refs = 0)
1497  : ctype_byname(__s.c_str(), __refs) { }
1498 #endif
1499 
1500  protected:
1501  virtual
1502  ~ctype_byname() { }
1503  };
1504 
1505  /// 22.2.1.4 Class ctype_byname specializations.
1506  template<>
1507  class ctype_byname<char> : public ctype<char>
1508  {
1509  public:
1510  explicit
1511  ctype_byname(const char* __s, size_t __refs = 0);
1512 
1513 #if __cplusplus >= 201103L
1514  explicit
1515  ctype_byname(const string& __s, size_t __refs = 0);
1516 #endif
1517 
1518  protected:
1519  virtual
1520  ~ctype_byname();
1521  };
1522 
1523 #ifdef _GLIBCXX_USE_WCHAR_T
1524  template<>
1525  class ctype_byname<wchar_t> : public ctype<wchar_t>
1526  {
1527  public:
1528  explicit
1529  ctype_byname(const char* __s, size_t __refs = 0);
1530 
1531 #if __cplusplus >= 201103L
1532  explicit
1533  ctype_byname(const string& __s, size_t __refs = 0);
1534 #endif
1535 
1536  protected:
1537  virtual
1538  ~ctype_byname();
1539  };
1540 #endif
1541 
1542 _GLIBCXX_END_NAMESPACE_VERSION
1543 } // namespace
1544 
1545 // Include host and configuration specific ctype inlines.
1546 #include <bits/ctype_inline.h>
1547 
1548 namespace std _GLIBCXX_VISIBILITY(default)
1549 {
1550 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1551 
1552  // 22.2.2 The numeric category.
1553  class __num_base
1554  {
1555  public:
1556  // NB: Code depends on the order of _S_atoms_out elements.
1557  // Below are the indices into _S_atoms_out.
1558  enum
1559  {
1560  _S_ominus,
1561  _S_oplus,
1562  _S_ox,
1563  _S_oX,
1564  _S_odigits,
1565  _S_odigits_end = _S_odigits + 16,
1566  _S_oudigits = _S_odigits_end,
1567  _S_oudigits_end = _S_oudigits + 16,
1568  _S_oe = _S_odigits + 14, // For scientific notation, 'e'
1569  _S_oE = _S_oudigits + 14, // For scientific notation, 'E'
1570  _S_oend = _S_oudigits_end
1571  };
1572 
1573  // A list of valid numeric literals for output. This array
1574  // contains chars that will be passed through the current locale's
1575  // ctype<_CharT>.widen() and then used to render numbers.
1576  // For the standard "C" locale, this is
1577  // "-+xX0123456789abcdef0123456789ABCDEF".
1578  static const char* _S_atoms_out;
1579 
1580  // String literal of acceptable (narrow) input, for num_get.
1581  // "-+xX0123456789abcdefABCDEF"
1582  static const char* _S_atoms_in;
1583 
1584  enum
1585  {
1586  _S_iminus,
1587  _S_iplus,
1588  _S_ix,
1589  _S_iX,
1590  _S_izero,
1591  _S_ie = _S_izero + 14,
1592  _S_iE = _S_izero + 20,
1593  _S_iend = 26
1594  };
1595 
1596  // num_put
1597  // Construct and return valid scanf format for floating point types.
1598  static void
1599  _S_format_float(const ios_base& __io, char* __fptr, char __mod) throw();
1600  };
1601 
1602  template<typename _CharT>
1603  struct __numpunct_cache : public locale::facet
1604  {
1605  const char* _M_grouping;
1606  size_t _M_grouping_size;
1607  bool _M_use_grouping;
1608  const _CharT* _M_truename;
1609  size_t _M_truename_size;
1610  const _CharT* _M_falsename;
1611  size_t _M_falsename_size;
1612  _CharT _M_decimal_point;
1613  _CharT _M_thousands_sep;
1614 
1615  // A list of valid numeric literals for output: in the standard
1616  // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
1617  // This array contains the chars after having been passed
1618  // through the current locale's ctype<_CharT>.widen().
1619  _CharT _M_atoms_out[__num_base::_S_oend];
1620 
1621  // A list of valid numeric literals for input: in the standard
1622  // "C" locale, this is "-+xX0123456789abcdefABCDEF"
1623  // This array contains the chars after having been passed
1624  // through the current locale's ctype<_CharT>.widen().
1625  _CharT _M_atoms_in[__num_base::_S_iend];
1626 
1627  bool _M_allocated;
1628 
1629  __numpunct_cache(size_t __refs = 0)
1630  : facet(__refs), _M_grouping(0), _M_grouping_size(0),
1631  _M_use_grouping(false),
1632  _M_truename(0), _M_truename_size(0), _M_falsename(0),
1633  _M_falsename_size(0), _M_decimal_point(_CharT()),
1634  _M_thousands_sep(_CharT()), _M_allocated(false)
1635  { }
1636 
1637  ~__numpunct_cache();
1638 
1639  void
1640  _M_cache(const locale& __loc);
1641 
1642  private:
1643  __numpunct_cache&
1644  operator=(const __numpunct_cache&);
1645 
1646  explicit
1647  __numpunct_cache(const __numpunct_cache&);
1648  };
1649 
1650  template<typename _CharT>
1651  __numpunct_cache<_CharT>::~__numpunct_cache()
1652  {
1653  if (_M_allocated)
1654  {
1655  delete [] _M_grouping;
1656  delete [] _M_truename;
1657  delete [] _M_falsename;
1658  }
1659  }
1660 
1661 _GLIBCXX_BEGIN_NAMESPACE_CXX11
1662 
1663  /**
1664  * @brief Primary class template numpunct.
1665  * @ingroup locales
1666  *
1667  * This facet stores several pieces of information related to printing and
1668  * scanning numbers, such as the decimal point character. It takes a
1669  * template parameter specifying the char type. The numpunct facet is
1670  * used by streams for many I/O operations involving numbers.
1671  *
1672  * The numpunct template uses protected virtual functions to provide the
1673  * actual results. The public accessors forward the call to the virtual
1674  * functions. These virtual functions are hooks for developers to
1675  * implement the behavior they require from a numpunct facet.
1676  */
1677  template<typename _CharT>
1678  class numpunct : public locale::facet
1679  {
1680  public:
1681  // Types:
1682  ///@{
1683  /// Public typedefs
1684  typedef _CharT char_type;
1686  ///@}
1687  typedef __numpunct_cache<_CharT> __cache_type;
1688 
1689  protected:
1690  __cache_type* _M_data;
1691 
1692  public:
1693  /// Numpunct facet id.
1694  static locale::id id;
1695 
1696  /**
1697  * @brief Numpunct constructor.
1698  *
1699  * @param __refs Refcount to pass to the base class.
1700  */
1701  explicit
1702  numpunct(size_t __refs = 0)
1703  : facet(__refs), _M_data(0)
1704  { _M_initialize_numpunct(); }
1705 
1706  /**
1707  * @brief Internal constructor. Not for general use.
1708  *
1709  * This is a constructor for use by the library itself to set up the
1710  * predefined locale facets.
1711  *
1712  * @param __cache __numpunct_cache object.
1713  * @param __refs Refcount to pass to the base class.
1714  */
1715  explicit
1716  numpunct(__cache_type* __cache, size_t __refs = 0)
1717  : facet(__refs), _M_data(__cache)
1718  { _M_initialize_numpunct(); }
1719 
1720  /**
1721  * @brief Internal constructor. Not for general use.
1722  *
1723  * This is a constructor for use by the library itself to set up new
1724  * locales.
1725  *
1726  * @param __cloc The C locale.
1727  * @param __refs Refcount to pass to the base class.
1728  */
1729  explicit
1730  numpunct(__c_locale __cloc, size_t __refs = 0)
1731  : facet(__refs), _M_data(0)
1732  { _M_initialize_numpunct(__cloc); }
1733 
1734  /**
1735  * @brief Return decimal point character.
1736  *
1737  * This function returns a char_type to use as a decimal point. It
1738  * does so by returning returning
1739  * numpunct<char_type>::do_decimal_point().
1740  *
1741  * @return @a char_type representing a decimal point.
1742  */
1743  char_type
1745  { return this->do_decimal_point(); }
1746 
1747  /**
1748  * @brief Return thousands separator character.
1749  *
1750  * This function returns a char_type to use as a thousands
1751  * separator. It does so by returning returning
1752  * numpunct<char_type>::do_thousands_sep().
1753  *
1754  * @return char_type representing a thousands separator.
1755  */
1756  char_type
1758  { return this->do_thousands_sep(); }
1759 
1760  /**
1761  * @brief Return grouping specification.
1762  *
1763  * This function returns a string representing groupings for the
1764  * integer part of a number. Groupings indicate where thousands
1765  * separators should be inserted in the integer part of a number.
1766  *
1767  * Each char in the return string is interpret as an integer
1768  * rather than a character. These numbers represent the number
1769  * of digits in a group. The first char in the string
1770  * represents the number of digits in the least significant
1771  * group. If a char is negative, it indicates an unlimited
1772  * number of digits for the group. If more chars from the
1773  * string are required to group a number, the last char is used
1774  * repeatedly.
1775  *
1776  * For example, if the grouping() returns "\003\002" and is
1777  * applied to the number 123456789, this corresponds to
1778  * 12,34,56,789. Note that if the string was "32", this would
1779  * put more than 50 digits into the least significant group if
1780  * the character set is ASCII.
1781  *
1782  * The string is returned by calling
1783  * numpunct<char_type>::do_grouping().
1784  *
1785  * @return string representing grouping specification.
1786  */
1787  string
1788  grouping() const
1789  { return this->do_grouping(); }
1790 
1791  /**
1792  * @brief Return string representation of bool true.
1793  *
1794  * This function returns a string_type containing the text
1795  * representation for true bool variables. It does so by calling
1796  * numpunct<char_type>::do_truename().
1797  *
1798  * @return string_type representing printed form of true.
1799  */
1800  string_type
1801  truename() const
1802  { return this->do_truename(); }
1803 
1804  /**
1805  * @brief Return string representation of bool false.
1806  *
1807  * This function returns a string_type containing the text
1808  * representation for false bool variables. It does so by calling
1809  * numpunct<char_type>::do_falsename().
1810  *
1811  * @return string_type representing printed form of false.
1812  */
1813  string_type
1814  falsename() const
1815  { return this->do_falsename(); }
1816 
1817  protected:
1818  /// Destructor.
1819  virtual
1820  ~numpunct();
1821 
1822  /**
1823  * @brief Return decimal point character.
1824  *
1825  * Returns a char_type to use as a decimal point. This function is a
1826  * hook for derived classes to change the value returned.
1827  *
1828  * @return @a char_type representing a decimal point.
1829  */
1830  virtual char_type
1832  { return _M_data->_M_decimal_point; }
1833 
1834  /**
1835  * @brief Return thousands separator character.
1836  *
1837  * Returns a char_type to use as a thousands separator. This function
1838  * is a hook for derived classes to change the value returned.
1839  *
1840  * @return @a char_type representing a thousands separator.
1841  */
1842  virtual char_type
1844  { return _M_data->_M_thousands_sep; }
1845 
1846  /**
1847  * @brief Return grouping specification.
1848  *
1849  * Returns a string representing groupings for the integer part of a
1850  * number. This function is a hook for derived classes to change the
1851  * value returned. @see grouping() for details.
1852  *
1853  * @return String representing grouping specification.
1854  */
1855  virtual string
1856  do_grouping() const
1857  { return _M_data->_M_grouping; }
1858 
1859  /**
1860  * @brief Return string representation of bool true.
1861  *
1862  * Returns a string_type containing the text representation for true
1863  * bool variables. This function is a hook for derived classes to
1864  * change the value returned.
1865  *
1866  * @return string_type representing printed form of true.
1867  */
1868  virtual string_type
1869  do_truename() const
1870  { return _M_data->_M_truename; }
1871 
1872  /**
1873  * @brief Return string representation of bool false.
1874  *
1875  * Returns a string_type containing the text representation for false
1876  * bool variables. This function is a hook for derived classes to
1877  * change the value returned.
1878  *
1879  * @return string_type representing printed form of false.
1880  */
1881  virtual string_type
1883  { return _M_data->_M_falsename; }
1884 
1885  // For use at construction time only.
1886  void
1887  _M_initialize_numpunct(__c_locale __cloc = 0);
1888  };
1889 
1890  template<typename _CharT>
1891  locale::id numpunct<_CharT>::id;
1892 
1893  template<>
1895 
1896  template<>
1897  void
1898  numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
1899 
1900 #ifdef _GLIBCXX_USE_WCHAR_T
1901  template<>
1903 
1904  template<>
1905  void
1906  numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
1907 #endif
1908 
1909  /// class numpunct_byname [22.2.3.2].
1910  template<typename _CharT>
1911  class numpunct_byname : public numpunct<_CharT>
1912  {
1913  public:
1914  typedef _CharT char_type;
1916 
1917  explicit
1918  numpunct_byname(const char* __s, size_t __refs = 0)
1919  : numpunct<_CharT>(__refs)
1920  {
1921  if (__builtin_strcmp(__s, "C") != 0
1922  && __builtin_strcmp(__s, "POSIX") != 0)
1923  {
1924  __c_locale __tmp;
1925  this->_S_create_c_locale(__tmp, __s);
1926  this->_M_initialize_numpunct(__tmp);
1927  this->_S_destroy_c_locale(__tmp);
1928  }
1929  }
1930 
1931 #if __cplusplus >= 201103L
1932  explicit
1933  numpunct_byname(const string& __s, size_t __refs = 0)
1934  : numpunct_byname(__s.c_str(), __refs) { }
1935 #endif
1936 
1937  protected:
1938  virtual
1939  ~numpunct_byname() { }
1940  };
1941 
1942 _GLIBCXX_END_NAMESPACE_CXX11
1943 
1944 _GLIBCXX_BEGIN_NAMESPACE_LDBL
1945 
1946  /**
1947  * @brief Primary class template num_get.
1948  * @ingroup locales
1949  *
1950  * This facet encapsulates the code to parse and return a number
1951  * from a string. It is used by the istream numeric extraction
1952  * operators.
1953  *
1954  * The num_get template uses protected virtual functions to provide the
1955  * actual results. The public accessors forward the call to the virtual
1956  * functions. These virtual functions are hooks for developers to
1957  * implement the behavior they require from the num_get facet.
1958  */
1959  template<typename _CharT, typename _InIter>
1960  class num_get : public locale::facet
1961  {
1962  public:
1963  // Types:
1964  ///@{
1965  /// Public typedefs
1966  typedef _CharT char_type;
1967  typedef _InIter iter_type;
1968  ///@}
1969 
1970  /// Numpunct facet id.
1971  static locale::id id;
1972 
1973  /**
1974  * @brief Constructor performs initialization.
1975  *
1976  * This is the constructor provided by the standard.
1977  *
1978  * @param __refs Passed to the base facet class.
1979  */
1980  explicit
1981  num_get(size_t __refs = 0) : facet(__refs) { }
1982 
1983  /**
1984  * @brief Numeric parsing.
1985  *
1986  * Parses the input stream into the bool @a v. It does so by calling
1987  * num_get::do_get().
1988  *
1989  * If ios_base::boolalpha is set, attempts to read
1990  * ctype<CharT>::truename() or ctype<CharT>::falsename(). Sets
1991  * @a v to true or false if successful. Sets err to
1992  * ios_base::failbit if reading the string fails. Sets err to
1993  * ios_base::eofbit if the stream is emptied.
1994  *
1995  * If ios_base::boolalpha is not set, proceeds as with reading a long,
1996  * except if the value is 1, sets @a v to true, if the value is 0, sets
1997  * @a v to false, and otherwise set err to ios_base::failbit.
1998  *
1999  * @param __in Start of input stream.
2000  * @param __end End of input stream.
2001  * @param __io Source of locale and flags.
2002  * @param __err Error flags to set.
2003  * @param __v Value to format and insert.
2004  * @return Iterator after reading.
2005  */
2006  iter_type
2007  get(iter_type __in, iter_type __end, ios_base& __io,
2008  ios_base::iostate& __err, bool& __v) const
2009  { return this->do_get(__in, __end, __io, __err, __v); }
2010 
2011  ///@{
2012  /**
2013  * @brief Numeric parsing.
2014  *
2015  * Parses the input stream into the integral variable @a v. It does so
2016  * by calling num_get::do_get().
2017  *
2018  * Parsing is affected by the flag settings in @a io.
2019  *
2020  * The basic parse is affected by the value of io.flags() &
2021  * ios_base::basefield. If equal to ios_base::oct, parses like the
2022  * scanf %o specifier. Else if equal to ios_base::hex, parses like %X
2023  * specifier. Else if basefield equal to 0, parses like the %i
2024  * specifier. Otherwise, parses like %d for signed and %u for unsigned
2025  * types. The matching type length modifier is also used.
2026  *
2027  * Digit grouping is interpreted according to
2028  * numpunct::grouping() and numpunct::thousands_sep(). If the
2029  * pattern of digit groups isn't consistent, sets err to
2030  * ios_base::failbit.
2031  *
2032  * If parsing the string yields a valid value for @a v, @a v is set.
2033  * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2034  * Sets err to ios_base::eofbit if the stream is emptied.
2035  *
2036  * @param __in Start of input stream.
2037  * @param __end End of input stream.
2038  * @param __io Source of locale and flags.
2039  * @param __err Error flags to set.
2040  * @param __v Value to format and insert.
2041  * @return Iterator after reading.
2042  */
2043  iter_type
2044  get(iter_type __in, iter_type __end, ios_base& __io,
2045  ios_base::iostate& __err, long& __v) const
2046  { return this->do_get(__in, __end, __io, __err, __v); }
2047 
2048  iter_type
2049  get(iter_type __in, iter_type __end, ios_base& __io,
2050  ios_base::iostate& __err, unsigned short& __v) const
2051  { return this->do_get(__in, __end, __io, __err, __v); }
2052 
2053  iter_type
2054  get(iter_type __in, iter_type __end, ios_base& __io,
2055  ios_base::iostate& __err, unsigned int& __v) const
2056  { return this->do_get(__in, __end, __io, __err, __v); }
2057 
2058  iter_type
2059  get(iter_type __in, iter_type __end, ios_base& __io,
2060  ios_base::iostate& __err, unsigned long& __v) const
2061  { return this->do_get(__in, __end, __io, __err, __v); }
2062 
2063 #ifdef _GLIBCXX_USE_LONG_LONG
2064 #pragma GCC diagnostic push
2065 #pragma GCC diagnostic ignored "-Wlong-long"
2066  iter_type
2067  get(iter_type __in, iter_type __end, ios_base& __io,
2068  ios_base::iostate& __err, long long& __v) const
2069  { return this->do_get(__in, __end, __io, __err, __v); }
2070 
2071  iter_type
2072  get(iter_type __in, iter_type __end, ios_base& __io,
2073  ios_base::iostate& __err, unsigned long long& __v) const
2074  { return this->do_get(__in, __end, __io, __err, __v); }
2075 #pragma GCC diagnostic pop
2076 #endif
2077  ///@}
2078 
2079  ///@{
2080  /**
2081  * @brief Numeric parsing.
2082  *
2083  * Parses the input stream into the integral variable @a v. It does so
2084  * by calling num_get::do_get().
2085  *
2086  * The input characters are parsed like the scanf %g specifier. The
2087  * matching type length modifier is also used.
2088  *
2089  * The decimal point character used is numpunct::decimal_point().
2090  * Digit grouping is interpreted according to
2091  * numpunct::grouping() and numpunct::thousands_sep(). If the
2092  * pattern of digit groups isn't consistent, sets err to
2093  * ios_base::failbit.
2094  *
2095  * If parsing the string yields a valid value for @a v, @a v is set.
2096  * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2097  * Sets err to ios_base::eofbit if the stream is emptied.
2098  *
2099  * @param __in Start of input stream.
2100  * @param __end End of input stream.
2101  * @param __io Source of locale and flags.
2102  * @param __err Error flags to set.
2103  * @param __v Value to format and insert.
2104  * @return Iterator after reading.
2105  */
2106  iter_type
2107  get(iter_type __in, iter_type __end, ios_base& __io,
2108  ios_base::iostate& __err, float& __v) const
2109  { return this->do_get(__in, __end, __io, __err, __v); }
2110 
2111  iter_type
2112  get(iter_type __in, iter_type __end, ios_base& __io,
2113  ios_base::iostate& __err, double& __v) const
2114  { return this->do_get(__in, __end, __io, __err, __v); }
2115 
2116  iter_type
2117  get(iter_type __in, iter_type __end, ios_base& __io,
2118  ios_base::iostate& __err, long double& __v) const
2119  { return this->do_get(__in, __end, __io, __err, __v); }
2120  ///@}
2121 
2122  /**
2123  * @brief Numeric parsing.
2124  *
2125  * Parses the input stream into the pointer variable @a v. It does so
2126  * by calling num_get::do_get().
2127  *
2128  * The input characters are parsed like the scanf %p specifier.
2129  *
2130  * Digit grouping is interpreted according to
2131  * numpunct::grouping() and numpunct::thousands_sep(). If the
2132  * pattern of digit groups isn't consistent, sets err to
2133  * ios_base::failbit.
2134  *
2135  * Note that the digit grouping effect for pointers is a bit ambiguous
2136  * in the standard and shouldn't be relied on. See DR 344.
2137  *
2138  * If parsing the string yields a valid value for @a v, @a v is set.
2139  * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2140  * Sets err to ios_base::eofbit if the stream is emptied.
2141  *
2142  * @param __in Start of input stream.
2143  * @param __end End of input stream.
2144  * @param __io Source of locale and flags.
2145  * @param __err Error flags to set.
2146  * @param __v Value to format and insert.
2147  * @return Iterator after reading.
2148  */
2149  iter_type
2150  get(iter_type __in, iter_type __end, ios_base& __io,
2151  ios_base::iostate& __err, void*& __v) const
2152  { return this->do_get(__in, __end, __io, __err, __v); }
2153 
2154  protected:
2155  /// Destructor.
2156  virtual ~num_get() { }
2157 
2158  _GLIBCXX_DEFAULT_ABI_TAG
2159  iter_type
2160  _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
2161  string&) const;
2162 
2163  template<typename _ValueT>
2164  _GLIBCXX_DEFAULT_ABI_TAG
2165  iter_type
2166  _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
2167  _ValueT&) const;
2168 
2169  template<typename _CharT2>
2170  typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, int>::__type
2171  _M_find(const _CharT2*, size_t __len, _CharT2 __c) const
2172  {
2173  int __ret = -1;
2174  if (__len <= 10)
2175  {
2176  if (__c >= _CharT2('0') && __c < _CharT2(_CharT2('0') + __len))
2177  __ret = __c - _CharT2('0');
2178  }
2179  else
2180  {
2181  if (__c >= _CharT2('0') && __c <= _CharT2('9'))
2182  __ret = __c - _CharT2('0');
2183  else if (__c >= _CharT2('a') && __c <= _CharT2('f'))
2184  __ret = 10 + (__c - _CharT2('a'));
2185  else if (__c >= _CharT2('A') && __c <= _CharT2('F'))
2186  __ret = 10 + (__c - _CharT2('A'));
2187  }
2188  return __ret;
2189  }
2190 
2191  template<typename _CharT2>
2192  typename __gnu_cxx::__enable_if<!__is_char<_CharT2>::__value,
2193  int>::__type
2194  _M_find(const _CharT2* __zero, size_t __len, _CharT2 __c) const
2195  {
2196  int __ret = -1;
2197  const char_type* __q = char_traits<_CharT2>::find(__zero, __len, __c);
2198  if (__q)
2199  {
2200  __ret = __q - __zero;
2201  if (__ret > 15)
2202  __ret -= 6;
2203  }
2204  return __ret;
2205  }
2206 
2207  ///@{
2208  /**
2209  * @brief Numeric parsing.
2210  *
2211  * Parses the input stream into the variable @a v. This function is a
2212  * hook for derived classes to change the value returned. @see get()
2213  * for more details.
2214  *
2215  * @param __beg Start of input stream.
2216  * @param __end End of input stream.
2217  * @param __io Source of locale and flags.
2218  * @param __err Error flags to set.
2219  * @param __v Value to format and insert.
2220  * @return Iterator after reading.
2221  */
2222  virtual iter_type
2223  do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
2224 
2225  virtual iter_type
2226  do_get(iter_type __beg, iter_type __end, ios_base& __io,
2227  ios_base::iostate& __err, long& __v) const
2228  { return _M_extract_int(__beg, __end, __io, __err, __v); }
2229 
2230  virtual iter_type
2231  do_get(iter_type __beg, iter_type __end, ios_base& __io,
2232  ios_base::iostate& __err, unsigned short& __v) const
2233  { return _M_extract_int(__beg, __end, __io, __err, __v); }
2234 
2235  virtual iter_type
2236  do_get(iter_type __beg, iter_type __end, ios_base& __io,
2237  ios_base::iostate& __err, unsigned int& __v) const
2238  { return _M_extract_int(__beg, __end, __io, __err, __v); }
2239 
2240  virtual iter_type
2241  do_get(iter_type __beg, iter_type __end, ios_base& __io,
2242  ios_base::iostate& __err, unsigned long& __v) const
2243  { return _M_extract_int(__beg, __end, __io, __err, __v); }
2244 
2245 #ifdef _GLIBCXX_USE_LONG_LONG
2246 #pragma GCC diagnostic push
2247 #pragma GCC diagnostic ignored "-Wlong-long"
2248  virtual iter_type
2249  do_get(iter_type __beg, iter_type __end, ios_base& __io,
2250  ios_base::iostate& __err, long long& __v) const
2251  { return _M_extract_int(__beg, __end, __io, __err, __v); }
2252 
2253  virtual iter_type
2254  do_get(iter_type __beg, iter_type __end, ios_base& __io,
2255  ios_base::iostate& __err, unsigned long long& __v) const
2256  { return _M_extract_int(__beg, __end, __io, __err, __v); }
2257 #pragma GCC diagnostic pop
2258 #endif
2259 
2260  virtual iter_type
2261  do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, float&) const;
2262 
2263  virtual iter_type
2264  do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
2265  double&) const;
2266 
2267  // XXX GLIBCXX_ABI Deprecated
2268 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2269  // For __gnu_cxx_ldbl128::num_get and __gnu_cxx_ieee128::num_get
2270  // this entry in the vtable is for a 64-bit "long double" with the
2271  // same format as double. This keeps the vtable layout consistent
2272  // with std::num_get (visible when -mlong-double-64 is used).
2273  virtual iter_type
2274  __do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
2275  double&) const;
2276 #else
2277  virtual iter_type
2278  do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
2279  long double&) const;
2280 #endif
2281 
2282  virtual iter_type
2283  do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, void*&) const;
2284 
2285  // XXX GLIBCXX_ABI Deprecated
2286 #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
2287  && defined __LONG_DOUBLE_IEEE128__
2288  // For __gnu_cxx_ieee128::num_get this entry in the vtable is for
2289  // the non-IEEE 128-bit "long double" (aka "double double"). This
2290  // is consistent with __gnu_cxx_ldbl128::num_get (-mabi=ibmlongdouble)
2291  virtual iter_type
2292  __do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
2293  __ibm128&) const;
2294 #endif
2295 
2296  // XXX GLIBCXX_ABI Deprecated
2297 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2298  // For __gnu_cxx_ldbl128::num_get and __gnu_cxx_ieee128::num_get
2299  // this entry in the vtable is for the 128-bit "long double" type.
2300  virtual iter_type
2301  do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
2302  long double&) const;
2303 #endif
2304  ///@}
2305  };
2306 
2307  template<typename _CharT, typename _InIter>
2308  locale::id num_get<_CharT, _InIter>::id;
2309 
2310 
2311  /**
2312  * @brief Primary class template num_put.
2313  * @ingroup locales
2314  *
2315  * This facet encapsulates the code to convert a number to a string. It is
2316  * used by the ostream numeric insertion operators.
2317  *
2318  * The num_put template uses protected virtual functions to provide the
2319  * actual results. The public accessors forward the call to the virtual
2320  * functions. These virtual functions are hooks for developers to
2321  * implement the behavior they require from the num_put facet.
2322  */
2323  template<typename _CharT, typename _OutIter>
2324  class num_put : public locale::facet
2325  {
2326  public:
2327  // Types:
2328  ///@{
2329  /// Public typedefs
2330  typedef _CharT char_type;
2331  typedef _OutIter iter_type;
2332  ///@}
2333 
2334  /// Numpunct facet id.
2335  static locale::id id;
2336 
2337  /**
2338  * @brief Constructor performs initialization.
2339  *
2340  * This is the constructor provided by the standard.
2341  *
2342  * @param __refs Passed to the base facet class.
2343  */
2344  explicit
2345  num_put(size_t __refs = 0) : facet(__refs) { }
2346 
2347  /**
2348  * @brief Numeric formatting.
2349  *
2350  * Formats the boolean @a v and inserts it into a stream. It does so
2351  * by calling num_put::do_put().
2352  *
2353  * If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
2354  * ctype<CharT>::falsename(). Otherwise formats @a v as an int.
2355  *
2356  * @param __s Stream to write to.
2357  * @param __io Source of locale and flags.
2358  * @param __fill Char_type to use for filling.
2359  * @param __v Value to format and insert.
2360  * @return Iterator after writing.
2361  */
2362  iter_type
2363  put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
2364  { return this->do_put(__s, __io, __fill, __v); }
2365 
2366  ///@{
2367  /**
2368  * @brief Numeric formatting.
2369  *
2370  * Formats the integral value @a v and inserts it into a
2371  * stream. It does so by calling num_put::do_put().
2372  *
2373  * Formatting is affected by the flag settings in @a io.
2374  *
2375  * The basic format is affected by the value of io.flags() &
2376  * ios_base::basefield. If equal to ios_base::oct, formats like the
2377  * printf %o specifier. Else if equal to ios_base::hex, formats like
2378  * %x or %X with ios_base::uppercase unset or set respectively.
2379  * Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
2380  * for unsigned values. Note that if both oct and hex are set, neither
2381  * will take effect.
2382  *
2383  * If ios_base::showpos is set, '+' is output before positive values.
2384  * If ios_base::showbase is set, '0' precedes octal values (except 0)
2385  * and '0[xX]' precedes hex values.
2386  *
2387  * The decimal point character used is numpunct::decimal_point().
2388  * Thousands separators are inserted according to
2389  * numpunct::grouping() and numpunct::thousands_sep().
2390  *
2391  * If io.width() is non-zero, enough @a fill characters are inserted to
2392  * make the result at least that wide. If
2393  * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2394  * padded at the end. If ios_base::internal, then padding occurs
2395  * immediately after either a '+' or '-' or after '0x' or '0X'.
2396  * Otherwise, padding occurs at the beginning.
2397  *
2398  * @param __s Stream to write to.
2399  * @param __io Source of locale and flags.
2400  * @param __fill Char_type to use for filling.
2401  * @param __v Value to format and insert.
2402  * @return Iterator after writing.
2403  */
2404  iter_type
2405  put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
2406  { return this->do_put(__s, __io, __fill, __v); }
2407 
2408  iter_type
2409  put(iter_type __s, ios_base& __io, char_type __fill,
2410  unsigned long __v) const
2411  { return this->do_put(__s, __io, __fill, __v); }
2412 
2413 #ifdef _GLIBCXX_USE_LONG_LONG
2414 #pragma GCC diagnostic push
2415 #pragma GCC diagnostic ignored "-Wlong-long"
2416  iter_type
2417  put(iter_type __s, ios_base& __io, char_type __fill, long long __v) const
2418  { return this->do_put(__s, __io, __fill, __v); }
2419 
2420  iter_type
2421  put(iter_type __s, ios_base& __io, char_type __fill,
2422  unsigned long long __v) const
2423  { return this->do_put(__s, __io, __fill, __v); }
2424 #pragma GCC diagnostic pop
2425 #endif
2426  ///@}
2427 
2428  ///@{
2429  /**
2430  * @brief Numeric formatting.
2431  *
2432  * Formats the floating point value @a v and inserts it into a stream.
2433  * It does so by calling num_put::do_put().
2434  *
2435  * Formatting is affected by the flag settings in @a io.
2436  *
2437  * The basic format is affected by the value of io.flags() &
2438  * ios_base::floatfield. If equal to ios_base::fixed, formats like the
2439  * printf %f specifier. Else if equal to ios_base::scientific, formats
2440  * like %e or %E with ios_base::uppercase unset or set respectively.
2441  * Otherwise, formats like %g or %G depending on uppercase. Note that
2442  * if both fixed and scientific are set, the effect will also be like
2443  * %g or %G.
2444  *
2445  * The output precision is given by io.precision(). This precision is
2446  * capped at numeric_limits::digits10 + 2 (different for double and
2447  * long double). The default precision is 6.
2448  *
2449  * If ios_base::showpos is set, '+' is output before positive values.
2450  * If ios_base::showpoint is set, a decimal point will always be
2451  * output.
2452  *
2453  * The decimal point character used is numpunct::decimal_point().
2454  * Thousands separators are inserted according to
2455  * numpunct::grouping() and numpunct::thousands_sep().
2456  *
2457  * If io.width() is non-zero, enough @a fill characters are inserted to
2458  * make the result at least that wide. If
2459  * (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2460  * padded at the end. If ios_base::internal, then padding occurs
2461  * immediately after either a '+' or '-' or after '0x' or '0X'.
2462  * Otherwise, padding occurs at the beginning.
2463  *
2464  * @param __s Stream to write to.
2465  * @param __io Source of locale and flags.
2466  * @param __fill Char_type to use for filling.
2467  * @param __v Value to format and insert.
2468  * @return Iterator after writing.
2469  */
2470  iter_type
2471  put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
2472  { return this->do_put(__s, __io, __fill, __v); }
2473 
2474  iter_type
2475  put(iter_type __s, ios_base& __io, char_type __fill,
2476  long double __v) const
2477  { return this->do_put(__s, __io, __fill, __v); }
2478  ///@}
2479 
2480  /**
2481  * @brief Numeric formatting.
2482  *
2483  * Formats the pointer value @a v and inserts it into a stream. It
2484  * does so by calling num_put::do_put().
2485  *
2486  * This function formats @a v as an unsigned long with ios_base::hex
2487  * and ios_base::showbase set.
2488  *
2489  * @param __s Stream to write to.
2490  * @param __io Source of locale and flags.
2491  * @param __fill Char_type to use for filling.
2492  * @param __v Value to format and insert.
2493  * @return Iterator after writing.
2494  */
2495  iter_type
2496  put(iter_type __s, ios_base& __io, char_type __fill,
2497  const void* __v) const
2498  { return this->do_put(__s, __io, __fill, __v); }
2499 
2500  protected:
2501  template<typename _ValueT>
2502  iter_type
2503  _M_insert_float(iter_type, ios_base& __io, char_type __fill,
2504  char __mod, _ValueT __v) const;
2505 
2506  void
2507  _M_group_float(const char* __grouping, size_t __grouping_size,
2508  char_type __sep, const char_type* __p, char_type* __new,
2509  char_type* __cs, int& __len) const;
2510 
2511  template<typename _ValueT>
2512  iter_type
2513  _M_insert_int(iter_type, ios_base& __io, char_type __fill,
2514  _ValueT __v) const;
2515 
2516  void
2517  _M_group_int(const char* __grouping, size_t __grouping_size,
2518  char_type __sep, ios_base& __io, char_type* __new,
2519  char_type* __cs, int& __len) const;
2520 
2521  void
2522  _M_pad(char_type __fill, streamsize __w, ios_base& __io,
2523  char_type* __new, const char_type* __cs, int& __len) const;
2524 
2525  /// Destructor.
2526  virtual
2527  ~num_put() { }
2528 
2529  ///@{
2530  /**
2531  * @brief Numeric formatting.
2532  *
2533  * These functions do the work of formatting numeric values and
2534  * inserting them into a stream. This function is a hook for derived
2535  * classes to change the value returned.
2536  *
2537  * @param __s Stream to write to.
2538  * @param __io Source of locale and flags.
2539  * @param __fill Char_type to use for filling.
2540  * @param __v Value to format and insert.
2541  * @return Iterator after writing.
2542  */
2543  virtual iter_type
2544  do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const;
2545 
2546  virtual iter_type
2547  do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
2548  { return _M_insert_int(__s, __io, __fill, __v); }
2549 
2550  virtual iter_type
2551  do_put(iter_type __s, ios_base& __io, char_type __fill,
2552  unsigned long __v) const
2553  { return _M_insert_int(__s, __io, __fill, __v); }
2554 
2555 #ifdef _GLIBCXX_USE_LONG_LONG
2556 #pragma GCC diagnostic push
2557 #pragma GCC diagnostic ignored "-Wlong-long"
2558  virtual iter_type
2559  do_put(iter_type __s, ios_base& __io, char_type __fill,
2560  long long __v) const
2561  { return _M_insert_int(__s, __io, __fill, __v); }
2562 
2563  virtual iter_type
2564  do_put(iter_type __s, ios_base& __io, char_type __fill,
2565  unsigned long long __v) const
2566  { return _M_insert_int(__s, __io, __fill, __v); }
2567 #pragma GCC diagnostic pop
2568 #endif
2569 
2570  virtual iter_type
2571  do_put(iter_type, ios_base&, char_type, double) const;
2572 
2573  // XXX GLIBCXX_ABI Deprecated
2574 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2575  virtual iter_type
2576  __do_put(iter_type, ios_base&, char_type, double) const;
2577 #else
2578  virtual iter_type
2579  do_put(iter_type, ios_base&, char_type, long double) const;
2580 #endif
2581 
2582  virtual iter_type
2583  do_put(iter_type, ios_base&, char_type, const void*) const;
2584 
2585  // XXX GLIBCXX_ABI Deprecated
2586 #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
2587  && defined __LONG_DOUBLE_IEEE128__
2588  virtual iter_type
2589  __do_put(iter_type, ios_base&, char_type, __ibm128) const;
2590 #endif
2591 
2592  // XXX GLIBCXX_ABI Deprecated
2593 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2594  virtual iter_type
2595  do_put(iter_type, ios_base&, char_type, long double) const;
2596 #endif
2597  ///@}
2598  };
2599 
2600  template <typename _CharT, typename _OutIter>
2601  locale::id num_put<_CharT, _OutIter>::id;
2602 
2603 _GLIBCXX_END_NAMESPACE_LDBL
2604 
2605  // Subclause convenience interfaces, inlines.
2606  // NB: These are inline because, when used in a loop, some compilers
2607  // can hoist the body out of the loop; then it's just as fast as the
2608  // C is*() function.
2609 
2610  /// Convenience interface to ctype.is(ctype_base::space, __c).
2611  template<typename _CharT>
2612  inline bool
2613  isspace(_CharT __c, const locale& __loc)
2614  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
2615 
2616  /// Convenience interface to ctype.is(ctype_base::print, __c).
2617  template<typename _CharT>
2618  inline bool
2619  isprint(_CharT __c, const locale& __loc)
2620  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
2621 
2622  /// Convenience interface to ctype.is(ctype_base::cntrl, __c).
2623  template<typename _CharT>
2624  inline bool
2625  iscntrl(_CharT __c, const locale& __loc)
2626  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
2627 
2628  /// Convenience interface to ctype.is(ctype_base::upper, __c).
2629  template<typename _CharT>
2630  inline bool
2631  isupper(_CharT __c, const locale& __loc)
2632  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
2633 
2634  /// Convenience interface to ctype.is(ctype_base::lower, __c).
2635  template<typename _CharT>
2636  inline bool
2637  islower(_CharT __c, const locale& __loc)
2638  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
2639 
2640  /// Convenience interface to ctype.is(ctype_base::alpha, __c).
2641  template<typename _CharT>
2642  inline bool
2643  isalpha(_CharT __c, const locale& __loc)
2644  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
2645 
2646  /// Convenience interface to ctype.is(ctype_base::digit, __c).
2647  template<typename _CharT>
2648  inline bool
2649  isdigit(_CharT __c, const locale& __loc)
2650  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
2651 
2652  /// Convenience interface to ctype.is(ctype_base::punct, __c).
2653  template<typename _CharT>
2654  inline bool
2655  ispunct(_CharT __c, const locale& __loc)
2656  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
2657 
2658  /// Convenience interface to ctype.is(ctype_base::xdigit, __c).
2659  template<typename _CharT>
2660  inline bool
2661  isxdigit(_CharT __c, const locale& __loc)
2662  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
2663 
2664  /// Convenience interface to ctype.is(ctype_base::alnum, __c).
2665  template<typename _CharT>
2666  inline bool
2667  isalnum(_CharT __c, const locale& __loc)
2668  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
2669 
2670  /// Convenience interface to ctype.is(ctype_base::graph, __c).
2671  template<typename _CharT>
2672  inline bool
2673  isgraph(_CharT __c, const locale& __loc)
2674  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
2675 
2676 #if __cplusplus >= 201103L
2677  /// Convenience interface to ctype.is(ctype_base::blank, __c).
2678  template<typename _CharT>
2679  inline bool
2680  isblank(_CharT __c, const locale& __loc)
2681  { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::blank, __c); }
2682 #endif
2683 
2684  /// Convenience interface to ctype.toupper(__c).
2685  template<typename _CharT>
2686  inline _CharT
2687  toupper(_CharT __c, const locale& __loc)
2688  { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
2689 
2690  /// Convenience interface to ctype.tolower(__c).
2691  template<typename _CharT>
2692  inline _CharT
2693  tolower(_CharT __c, const locale& __loc)
2694  { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
2695 
2696 _GLIBCXX_END_NAMESPACE_VERSION
2697 } // namespace std
2698 
2699 # include <bits/locale_facets.tcc>
2700 
2701 #endif
std::num_get::~num_get
virtual ~num_get()
Destructor.
Definition: locale_facets.h:2156
std::ctype< char >::do_narrow
virtual char do_narrow(char_type __c, char __dfault) const
Narrow char.
Definition: locale_facets.h:1142
std::ios_base::iostate
_Ios_Iostate iostate
This is a bitmask type.
Definition: ios_base.h:442
std::numpunct::do_thousands_sep
virtual char_type do_thousands_sep() const
Return thousands separator character.
Definition: locale_facets.h:1843
std::num_get::get
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, long &__v) const
Numeric parsing.
Definition: locale_facets.h:2044
std::num_get::get
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned int &__v) const
Numeric parsing.
Definition: locale_facets.h:2054
std::num_get::get
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned long long &__v) const
Numeric parsing.
Definition: locale_facets.h:2072
std::ctype< wchar_t >::id
static locale::id id
The facet id for ctype<wchar_t>
Definition: locale_facets.h:1217
std::isalnum
bool isalnum(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::alnum, __c).
Definition: locale_facets.h:2667
std::locale
Container class for localization functionality.
Definition: locale_classes.h:66
std::ctype::do_tolower
virtual char_type do_tolower(char_type __c) const
Convert to lowercase.
std::numpunct::numpunct
numpunct(size_t __refs=0)
Numpunct constructor.
Definition: locale_facets.h:1702
std::numpunct_byname
class numpunct_byname [22.2.3.2].
Definition: locale_facets.h:1911
std::numpunct::char_type
_CharT char_type
Public typedefs.
Definition: locale_facets.h:1684
std::__ctype_abstract_base::is
const char_type * is(const char_type *__lo, const char_type *__hi, mask *__vec) const
Return a mask array.
Definition: locale_facets.h:189
std::num_get::do_get
virtual iter_type do_get(iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, long &__v) const
Numeric parsing.
Definition: locale_facets.h:2226
std::ctype< char >::toupper
const char_type * toupper(char_type *__lo, const char_type *__hi) const
Convert array to uppercase.
Definition: locale_facets.h:827
std::ctype
Primary class template ctype facet.
Definition: locale_facets.h:615
std::num_get::do_get
virtual iter_type do_get(iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned short &__v) const
Numeric parsing.
Definition: locale_facets.h:2231
std::isspace
bool isspace(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::space, __c).
Definition: locale_facets.h:2613
std::num_put::put
iter_type put(iter_type __s, ios_base &__io, char_type __fill, long double __v) const
Numeric formatting.
Definition: locale_facets.h:2475
std::num_get::do_get
virtual iter_type do_get(iter_type, iter_type, ios_base &, ios_base::iostate &, bool &) const
Numeric parsing.
Definition: locale_facets.tcc:595
ctype_base.h
std
ISO C++ entities toplevel namespace is std.
cpp_type_traits.h
std::ctype< char >::id
static locale::id id
The facet id for ctype<char>
Definition: locale_facets.h:711
std::streamsize
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
Definition: postypes.h:68
std::numpunct::do_grouping
virtual string do_grouping() const
Return grouping specification.
Definition: locale_facets.h:1856
std::num_get::get
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, long double &__v) const
Numeric parsing.
Definition: locale_facets.h:2117
std::num_put::put
iter_type put(iter_type __s, ios_base &__io, char_type __fill, unsigned long long __v) const
Numeric formatting.
Definition: locale_facets.h:2421
std::ctype< char >::widen
const char * widen(const char *__lo, const char *__hi, char_type *__to) const
Widen char array.
Definition: locale_facets.h:907
std::numpunct::grouping
string grouping() const
Return grouping specification.
Definition: locale_facets.h:1788
std::__ctype_abstract_base
Common base for ctype facet.
Definition: locale_facets.h:153
std::ctype< char >::narrow
const char_type * narrow(const char_type *__lo, const char_type *__hi, char __dfault, char *__to) const
Narrow char array.
Definition: locale_facets.h:972
std::num_get::get
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, void *&__v) const
Numeric parsing.
Definition: locale_facets.h:2150
std::num_put::num_put
num_put(size_t __refs=0)
Constructor performs initialization.
Definition: locale_facets.h:2345
std::num_put::iter_type
_OutIter iter_type
Public typedefs.
Definition: locale_facets.h:2331
std::ispunct
bool ispunct(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::punct, __c).
Definition: locale_facets.h:2655
std::ctype_base
Base class for ctype.
Definition: ctype_base.h:41
std::__ctype_abstract_base::char_type
_CharT char_type
Typedef for the template parameter.
Definition: locale_facets.h:158
std::ctype< char >::narrow
char narrow(char_type __c, char __dfault) const
Narrow char.
Definition: locale_facets.h:939
std::ctype::do_toupper
virtual char_type do_toupper(char_type __c) const
Convert to uppercase.
std::numpunct::truename
string_type truename() const
Return string representation of bool true.
Definition: locale_facets.h:1801
std::ctype::do_widen
virtual char_type do_widen(char __c) const
Widen char.
std::ctype< char >::toupper
char_type toupper(char_type __c) const
Convert to uppercase.
Definition: locale_facets.h:810
std::__ctype_abstract_base::tolower
const char_type * tolower(char_type *__lo, const char_type *__hi) const
Convert array to lowercase.
Definition: locale_facets.h:279
std::locale::facet::facet
facet(size_t __refs=0)
Facet constructor.
Definition: locale_classes.h:428
std::__ctype_abstract_base::do_tolower
virtual char_type do_tolower(char_type __c) const =0
Convert to lowercase.
std::num_put::put
iter_type put(iter_type __s, ios_base &__io, char_type __fill, double __v) const
Numeric formatting.
Definition: locale_facets.h:2471
std::ctype< char >::tolower
char_type tolower(char_type __c) const
Convert to lowercase.
Definition: locale_facets.h:843
std::__ctype_abstract_base::widen
char_type widen(char __c) const
Widen char to char_type.
Definition: locale_facets.h:296
cwctype
std::isalpha
bool isalpha(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::alpha, __c).
Definition: locale_facets.h:2643
std::ctype::id
static locale::id id
The facet id for ctype<char_type>
Definition: locale_facets.h:623
std::ctype< char >::do_narrow
virtual const char_type * do_narrow(const char_type *__lo, const char_type *__hi, char __dfault, char *__to) const
Narrow char array to char array.
Definition: locale_facets.h:1168
std::numpunct::thousands_sep
char_type thousands_sep() const
Return thousands separator character.
Definition: locale_facets.h:1757
std::num_get::get
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, double &__v) const
Numeric parsing.
Definition: locale_facets.h:2112
std::num_put::do_put
virtual iter_type do_put(iter_type __s, ios_base &__io, char_type __fill, unsigned long long __v) const
Numeric formatting.
Definition: locale_facets.h:2564
std::num_put::put
iter_type put(iter_type __s, ios_base &__io, char_type __fill, const void *__v) const
Numeric formatting.
Definition: locale_facets.h:2496
std::isblank
bool isblank(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::blank, __c).
Definition: locale_facets.h:2680
std::num_get::get
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, bool &__v) const
Numeric parsing.
Definition: locale_facets.h:2007
std::ctype::do_narrow
virtual char do_narrow(char_type, char __dfault) const
Narrow char_type to char.
std::__ctype_abstract_base::do_toupper
virtual char_type do_toupper(char_type __c) const =0
Convert to uppercase.
std::__ctype_abstract_base::widen
const char * widen(const char *__lo, const char *__hi, char_type *__to) const
Widen array to char_type.
Definition: locale_facets.h:315
std::num_get::do_get
virtual iter_type do_get(iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned long &__v) const
Numeric parsing.
Definition: locale_facets.h:2241
std::numpunct::~numpunct
virtual ~numpunct()
Destructor.
std::numpunct::falsename
string_type falsename() const
Return string representation of bool false.
Definition: locale_facets.h:1814
std::num_put::put
iter_type put(iter_type __s, ios_base &__io, char_type __fill, unsigned long __v) const
Numeric formatting.
Definition: locale_facets.h:2409
std::isgraph
bool isgraph(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::graph, __c).
Definition: locale_facets.h:2673
ios_base.h
type_traits.h
std::__ctype_abstract_base::do_scan_not
virtual const char_type * do_scan_not(mask __m, const char_type *__lo, const char_type *__hi) const =0
Find char_type not matching mask.
std::__ctype_abstract_base::do_is
virtual bool do_is(mask __m, char_type __c) const =0
Test char_type classification.
std::num_put::do_put
virtual iter_type do_put(iter_type __s, ios_base &__io, char_type __fill, bool __v) const
Numeric formatting.
Definition: locale_facets.tcc:1127
std::num_get::num_get
num_get(size_t __refs=0)
Constructor performs initialization.
Definition: locale_facets.h:1981
std::numpunct::numpunct
numpunct(__cache_type *__cache, size_t __refs=0)
Internal constructor. Not for general use.
Definition: locale_facets.h:1716
std::numpunct::do_falsename
virtual string_type do_falsename() const
Return string representation of bool false.
Definition: locale_facets.h:1882
std::ctype< wchar_t >::char_type
wchar_t char_type
Typedef for the template parameter wchar_t.
Definition: locale_facets.h:1199
std::num_get::get
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, float &__v) const
Numeric parsing.
Definition: locale_facets.h:2107
std::num_get::get
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, long long &__v) const
Numeric parsing.
Definition: locale_facets.h:2067
std::__ctype_abstract_base::toupper
char_type toupper(char_type __c) const
Convert to uppercase.
Definition: locale_facets.h:235
std::ctype< char >::char_type
char char_type
Typedef for the template parameter char.
Definition: locale_facets.h:694
std::num_get::do_get
virtual iter_type do_get(iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned int &__v) const
Numeric parsing.
Definition: locale_facets.h:2236
std::__ctype_abstract_base::narrow
const char_type * narrow(const char_type *__lo, const char_type *__hi, char __dfault, char *__to) const
Narrow array to char array.
Definition: locale_facets.h:356
locale_facets.tcc
std::num_put::put
iter_type put(iter_type __s, ios_base &__io, char_type __fill, long long __v) const
Numeric formatting.
Definition: locale_facets.h:2417
std::islower
bool islower(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::lower, __c).
Definition: locale_facets.h:2637
std::numpunct::id
static locale::id id
Numpunct facet id.
Definition: locale_facets.h:1694
std::ctype::do_scan_is
virtual const char_type * do_scan_is(mask __m, const char_type *__lo, const char_type *__hi) const
Find char_type matching mask.
std::num_put::do_put
virtual iter_type do_put(iter_type __s, ios_base &__io, char_type __fill, long __v) const
Numeric formatting.
Definition: locale_facets.h:2547
std::numpunct
Primary class template numpunct.
Definition: locale_facets.h:1678
std::numpunct::do_decimal_point
virtual char_type do_decimal_point() const
Return decimal point character.
Definition: locale_facets.h:1831
iosfwd
std::__ctype_abstract_base::toupper
const char_type * toupper(char_type *__lo, const char_type *__hi) const
Convert array to uppercase.
Definition: locale_facets.h:250
std::isxdigit
bool isxdigit(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::xdigit, __c).
Definition: locale_facets.h:2661
std::ctype::do_is
virtual bool do_is(mask __m, char_type __c) const
Test char_type classification.
std::num_put::do_put
virtual iter_type do_put(iter_type __s, ios_base &__io, char_type __fill, long long __v) const
Numeric formatting.
Definition: locale_facets.h:2559
std::ctype< char >::table
const mask * table() const
Returns a pointer to the mask table provided to the constructor, or the default from classic_table() ...
Definition: locale_facets.h:991
streambuf_iterator.h
std::ctype< char >::do_widen
virtual const char * do_widen(const char *__lo, const char *__hi, char_type *__to) const
Widen char array.
Definition: locale_facets.h:1115
std::num_get::iter_type
_InIter iter_type
Public typedefs.
Definition: locale_facets.h:1967
std::ctype_byname
class ctype_byname [22.2.1.2].
Definition: locale_facets.h:1486
std::ctype::do_scan_not
virtual const char_type * do_scan_not(mask __m, const char_type *__lo, const char_type *__hi) const
Find char_type not matching mask.
std::num_get::char_type
_CharT char_type
Public typedefs.
Definition: locale_facets.h:1966
std::num_get::do_get
virtual iter_type do_get(iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned long long &__v) const
Numeric parsing.
Definition: locale_facets.h:2254
std::num_put
Primary class template num_put.
Definition: locale_facets.h:2324
std::num_get::do_get
virtual iter_type do_get(iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, long long &__v) const
Numeric parsing.
Definition: locale_facets.h:2249
std::iscntrl
bool iscntrl(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::cntrl, __c).
Definition: locale_facets.h:2625
cctype
std::num_put::put
iter_type put(iter_type __s, ios_base &__io, char_type __fill, long __v) const
Numeric formatting.
Definition: locale_facets.h:2405
std::numpunct::decimal_point
char_type decimal_point() const
Return decimal point character.
Definition: locale_facets.h:1744
std::basic_string::c_str
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
Definition: cow_string.h:2249
streambuf
std::toupper
_CharT toupper(_CharT __c, const locale &__loc)
Convenience interface to ctype.toupper(__c).
Definition: locale_facets.h:2687
std::ctype< char >::tolower
const char_type * tolower(char_type *__lo, const char_type *__hi) const
Convert array to lowercase.
Definition: locale_facets.h:860
std::numpunct::string_type
basic_string< _CharT > string_type
Public typedefs.
Definition: locale_facets.h:1685
ctype_inline.h
std::__ctype_abstract_base::scan_is
const char_type * scan_is(mask __m, const char_type *__lo, const char_type *__hi) const
Find char_type matching a mask.
Definition: locale_facets.h:205
std::num_put::id
static locale::id id
Numpunct facet id.
Definition: locale_facets.h:2335
std::isprint
bool isprint(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::print, __c).
Definition: locale_facets.h:2619
std::num_put::~num_put
virtual ~num_put()
Destructor.
Definition: locale_facets.h:2527
std::num_get::id
static locale::id id
Numpunct facet id.
Definition: locale_facets.h:1971
std::tolower
_CharT tolower(_CharT __c, const locale &__loc)
Convenience interface to ctype.tolower(__c).
Definition: locale_facets.h:2693
std::__ctype_abstract_base::scan_not
const char_type * scan_not(mask __m, const char_type *__lo, const char_type *__hi) const
Find char_type not matching a mask.
Definition: locale_facets.h:221
std::__ctype_abstract_base::do_scan_is
virtual const char_type * do_scan_is(mask __m, const char_type *__lo, const char_type *__hi) const =0
Find char_type matching mask.
std::__ctype_abstract_base::do_narrow
virtual char do_narrow(char_type __c, char __dfault) const =0
Narrow char_type to char.
std::num_get::get
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned short &__v) const
Numeric parsing.
Definition: locale_facets.h:2049
std::num_put::put
iter_type put(iter_type __s, ios_base &__io, char_type __fill, bool __v) const
Numeric formatting.
Definition: locale_facets.h:2363
std::isupper
bool isupper(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::upper, __c).
Definition: locale_facets.h:2631
std::ctype< char >::widen
char_type widen(char __c) const
Widen char.
Definition: locale_facets.h:880
std::__ctype_abstract_base::tolower
char_type tolower(char_type __c) const
Convert to lowercase.
Definition: locale_facets.h:264
std::__ctype_abstract_base::is
bool is(mask __m, char_type __c) const
Test char_type classification.
Definition: locale_facets.h:172
std::isdigit
bool isdigit(_CharT __c, const locale &__loc)
Convenience interface to ctype.is(ctype_base::digit, __c).
Definition: locale_facets.h:2649
std::num_put::char_type
_CharT char_type
Public typedefs.
Definition: locale_facets.h:2330
std::__ctype_abstract_base::narrow
char narrow(char_type __c, char __dfault) const
Narrow char_type to char.
Definition: locale_facets.h:334
std::num_get::get
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, unsigned long &__v) const
Numeric parsing.
Definition: locale_facets.h:2059
std::locale::facet
Localization functionality base class.
Definition: locale_classes.h:396
std::num_put::do_put
virtual iter_type do_put(iter_type __s, ios_base &__io, char_type __fill, unsigned long __v) const
Numeric formatting.
Definition: locale_facets.h:2551
std::num_get
Primary class template num_get.
Definition: locale_facets.h:1960
std::numpunct::numpunct
numpunct(__c_locale __cloc, size_t __refs=0)
Internal constructor. Not for general use.
Definition: locale_facets.h:1730
std::numpunct::do_truename
virtual string_type do_truename() const
Return string representation of bool true.
Definition: locale_facets.h:1869
std::basic_string< _CharT >
std::ios_base
The base of the I/O class hierarchy.
Definition: ios_base.h:254
std::locale::id
Facet ID class.
Definition: locale_classes.h:508
std::__ctype_abstract_base::do_widen
virtual char_type do_widen(char __c) const =0
Widen char.
numeric_traits.h