1    	// Locale support -*- C++ -*-
2    	
3    	// Copyright (C) 2007-2017 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_nonio.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_NONIO_H
35   	#define _LOCALE_FACETS_NONIO_H 1
36   	
37   	#pragma GCC system_header
38   	
39   	#include <ctime>	// For struct tm
40   	
41   	namespace std _GLIBCXX_VISIBILITY(default)
42   	{
43   	_GLIBCXX_BEGIN_NAMESPACE_VERSION
44   	
45   	  /**
46   	   *  @brief  Time format ordering data.
47   	   *  @ingroup locales
48   	   *
49   	   *  This class provides an enum representing different orderings of
50   	   *  time: day, month, and year.
51   	  */
52   	  class time_base
53   	  {
54   	  public:
55   	    enum dateorder { no_order, dmy, mdy, ymd, ydm };
56   	  };
57   	
58   	  template<typename _CharT>
59   	    struct __timepunct_cache : public locale::facet
60   	    {
61   	      // List of all known timezones, with GMT first.
62   	      static const _CharT*		_S_timezones[14];
63   	
64   	      const _CharT*			_M_date_format;
65   	      const _CharT*			_M_date_era_format;
66   	      const _CharT*			_M_time_format;
67   	      const _CharT*			_M_time_era_format;
68   	      const _CharT*			_M_date_time_format;
69   	      const _CharT*			_M_date_time_era_format;
70   	      const _CharT*			_M_am;
71   	      const _CharT*			_M_pm;
72   	      const _CharT*			_M_am_pm_format;
73   	
74   	      // Day names, starting with "C"'s Sunday.
75   	      const _CharT*			_M_day1;
76   	      const _CharT*			_M_day2;
77   	      const _CharT*			_M_day3;
78   	      const _CharT*			_M_day4;
79   	      const _CharT*			_M_day5;
80   	      const _CharT*			_M_day6;
81   	      const _CharT*			_M_day7;
82   	
83   	      // Abbreviated day names, starting with "C"'s Sun.
84   	      const _CharT*			_M_aday1;
85   	      const _CharT*			_M_aday2;
86   	      const _CharT*			_M_aday3;
87   	      const _CharT*			_M_aday4;
88   	      const _CharT*			_M_aday5;
89   	      const _CharT*			_M_aday6;
90   	      const _CharT*			_M_aday7;
91   	
92   	      // Month names, starting with "C"'s January.
93   	      const _CharT*			_M_month01;
94   	      const _CharT*			_M_month02;
95   	      const _CharT*			_M_month03;
96   	      const _CharT*			_M_month04;
97   	      const _CharT*			_M_month05;
98   	      const _CharT*			_M_month06;
99   	      const _CharT*			_M_month07;
100  	      const _CharT*			_M_month08;
101  	      const _CharT*			_M_month09;
102  	      const _CharT*			_M_month10;
103  	      const _CharT*			_M_month11;
104  	      const _CharT*			_M_month12;
105  	
106  	      // Abbreviated month names, starting with "C"'s Jan.
107  	      const _CharT*			_M_amonth01;
108  	      const _CharT*			_M_amonth02;
109  	      const _CharT*			_M_amonth03;
110  	      const _CharT*			_M_amonth04;
111  	      const _CharT*			_M_amonth05;
112  	      const _CharT*			_M_amonth06;
113  	      const _CharT*			_M_amonth07;
114  	      const _CharT*			_M_amonth08;
115  	      const _CharT*			_M_amonth09;
116  	      const _CharT*			_M_amonth10;
117  	      const _CharT*			_M_amonth11;
118  	      const _CharT*			_M_amonth12;
119  	
120  	      bool				_M_allocated;
121  	
122  	      __timepunct_cache(size_t __refs = 0) : facet(__refs),
123  	      _M_date_format(0), _M_date_era_format(0), _M_time_format(0),
124  	      _M_time_era_format(0), _M_date_time_format(0),
125  	      _M_date_time_era_format(0), _M_am(0), _M_pm(0),
126  	      _M_am_pm_format(0), _M_day1(0), _M_day2(0), _M_day3(0),
127  	      _M_day4(0), _M_day5(0), _M_day6(0), _M_day7(0),
128  	      _M_aday1(0), _M_aday2(0), _M_aday3(0), _M_aday4(0),
129  	      _M_aday5(0), _M_aday6(0), _M_aday7(0), _M_month01(0),
130  	      _M_month02(0), _M_month03(0), _M_month04(0), _M_month05(0),
131  	      _M_month06(0), _M_month07(0), _M_month08(0), _M_month09(0),
132  	      _M_month10(0), _M_month11(0), _M_month12(0), _M_amonth01(0),
133  	      _M_amonth02(0), _M_amonth03(0), _M_amonth04(0),
134  	      _M_amonth05(0), _M_amonth06(0), _M_amonth07(0),
135  	      _M_amonth08(0), _M_amonth09(0), _M_amonth10(0),
136  	      _M_amonth11(0), _M_amonth12(0), _M_allocated(false)
137  	      { }
138  	
139  	      ~__timepunct_cache();
140  	
141  	    private:
142  	      __timepunct_cache&
143  	      operator=(const __timepunct_cache&);
144  	      
145  	      explicit
146  	      __timepunct_cache(const __timepunct_cache&);
147  	    };
148  	
149  	  template<typename _CharT>
150  	    __timepunct_cache<_CharT>::~__timepunct_cache()
151  	    {
152  	      if (_M_allocated)
153  		{
154  		  // Unused.
155  		}
156  	    }
157  	
158  	  // Specializations.
159  	  template<>
160  	    const char*
161  	    __timepunct_cache<char>::_S_timezones[14];
162  	
163  	#ifdef _GLIBCXX_USE_WCHAR_T
164  	  template<>
165  	    const wchar_t*
166  	    __timepunct_cache<wchar_t>::_S_timezones[14];
167  	#endif
168  	
169  	  // Generic.
170  	  template<typename _CharT>
171  	    const _CharT* __timepunct_cache<_CharT>::_S_timezones[14];
172  	
173  	  template<typename _CharT>
174  	    class __timepunct : public locale::facet
175  	    {
176  	    public:
177  	      // Types:
178  	      typedef _CharT			__char_type;
179  	      typedef __timepunct_cache<_CharT>	__cache_type;
180  	
181  	    protected:
182  	      __cache_type*			_M_data;
183  	      __c_locale			_M_c_locale_timepunct;
184  	      const char*			_M_name_timepunct;
185  	
186  	    public:
187  	      /// Numpunct facet id.
188  	      static locale::id			id;
189  	
190  	      explicit
191  	      __timepunct(size_t __refs = 0);
192  	
193  	      explicit
194  	      __timepunct(__cache_type* __cache, size_t __refs = 0);
195  	
196  	      /**
197  	       *  @brief  Internal constructor. Not for general use.
198  	       *
199  	       *  This is a constructor for use by the library itself to set up new
200  	       *  locales.
201  	       *
202  	       *  @param __cloc  The C locale.
203  	       *  @param __s  The name of a locale.
204  	       *  @param refs  Passed to the base facet class.
205  	      */
206  	      explicit
207  	      __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0);
208  	
209  	      // FIXME: for error checking purposes _M_put should return the return
210  	      // value of strftime/wcsftime.
211  	      void
212  	      _M_put(_CharT* __s, size_t __maxlen, const _CharT* __format,
213  		     const tm* __tm) const throw ();
214  	
215  	      void
216  	      _M_date_formats(const _CharT** __date) const
217  	      {
218  		// Always have default first.
219  		__date[0] = _M_data->_M_date_format;
220  		__date[1] = _M_data->_M_date_era_format;
221  	      }
222  	
223  	      void
224  	      _M_time_formats(const _CharT** __time) const
225  	      {
226  		// Always have default first.
227  		__time[0] = _M_data->_M_time_format;
228  		__time[1] = _M_data->_M_time_era_format;
229  	      }
230  	
231  	      void
232  	      _M_date_time_formats(const _CharT** __dt) const
233  	      {
234  		// Always have default first.
235  		__dt[0] = _M_data->_M_date_time_format;
236  		__dt[1] = _M_data->_M_date_time_era_format;
237  	      }
238  	
239  	      void
240  	      _M_am_pm_format(const _CharT* __ampm) const
241  	      { __ampm = _M_data->_M_am_pm_format; }
242  	
243  	      void
244  	      _M_am_pm(const _CharT** __ampm) const
245  	      {
246  		__ampm[0] = _M_data->_M_am;
247  		__ampm[1] = _M_data->_M_pm;
248  	      }
249  	
250  	      void
251  	      _M_days(const _CharT** __days) const
252  	      {
253  		__days[0] = _M_data->_M_day1;
254  		__days[1] = _M_data->_M_day2;
255  		__days[2] = _M_data->_M_day3;
256  		__days[3] = _M_data->_M_day4;
257  		__days[4] = _M_data->_M_day5;
258  		__days[5] = _M_data->_M_day6;
259  		__days[6] = _M_data->_M_day7;
260  	      }
261  	
262  	      void
263  	      _M_days_abbreviated(const _CharT** __days) const
264  	      {
265  		__days[0] = _M_data->_M_aday1;
266  		__days[1] = _M_data->_M_aday2;
267  		__days[2] = _M_data->_M_aday3;
268  		__days[3] = _M_data->_M_aday4;
269  		__days[4] = _M_data->_M_aday5;
270  		__days[5] = _M_data->_M_aday6;
271  		__days[6] = _M_data->_M_aday7;
272  	      }
273  	
274  	      void
275  	      _M_months(const _CharT** __months) const
276  	      {
277  		__months[0] = _M_data->_M_month01;
278  		__months[1] = _M_data->_M_month02;
279  		__months[2] = _M_data->_M_month03;
280  		__months[3] = _M_data->_M_month04;
281  		__months[4] = _M_data->_M_month05;
282  		__months[5] = _M_data->_M_month06;
283  		__months[6] = _M_data->_M_month07;
284  		__months[7] = _M_data->_M_month08;
285  		__months[8] = _M_data->_M_month09;
286  		__months[9] = _M_data->_M_month10;
287  		__months[10] = _M_data->_M_month11;
288  		__months[11] = _M_data->_M_month12;
289  	      }
290  	
291  	      void
292  	      _M_months_abbreviated(const _CharT** __months) const
293  	      {
294  		__months[0] = _M_data->_M_amonth01;
295  		__months[1] = _M_data->_M_amonth02;
296  		__months[2] = _M_data->_M_amonth03;
297  		__months[3] = _M_data->_M_amonth04;
298  		__months[4] = _M_data->_M_amonth05;
299  		__months[5] = _M_data->_M_amonth06;
300  		__months[6] = _M_data->_M_amonth07;
301  		__months[7] = _M_data->_M_amonth08;
302  		__months[8] = _M_data->_M_amonth09;
303  		__months[9] = _M_data->_M_amonth10;
304  		__months[10] = _M_data->_M_amonth11;
305  		__months[11] = _M_data->_M_amonth12;
306  	      }
307  	
308  	    protected:
309  	      virtual
310  	      ~__timepunct();
311  	
312  	      // For use at construction time only.
313  	      void
314  	      _M_initialize_timepunct(__c_locale __cloc = 0);
315  	    };
316  	
317  	  template<typename _CharT>
318  	    locale::id __timepunct<_CharT>::id;
319  	
320  	  // Specializations.
321  	  template<>
322  	    void
323  	    __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc);
324  	
325  	  template<>
326  	    void
327  	    __timepunct<char>::_M_put(char*, size_t, const char*, const tm*) const throw ();
328  	
329  	#ifdef _GLIBCXX_USE_WCHAR_T
330  	  template<>
331  	    void
332  	    __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc);
333  	
334  	  template<>
335  	    void
336  	    __timepunct<wchar_t>::_M_put(wchar_t*, size_t, const wchar_t*,
337  					 const tm*) const throw ();
338  	#endif
339  	
340  	_GLIBCXX_END_NAMESPACE_VERSION
341  	} // namespace
342  	
343  	  // Include host and configuration specific timepunct functions.
344  	  #include <bits/time_members.h>
345  	
346  	namespace std _GLIBCXX_VISIBILITY(default)
347  	{
348  	_GLIBCXX_BEGIN_NAMESPACE_VERSION
349  	
350  	_GLIBCXX_BEGIN_NAMESPACE_CXX11
351  	
352  	  /**
353  	   *  @brief  Primary class template time_get.
354  	   *  @ingroup locales
355  	   *
356  	   *  This facet encapsulates the code to parse and return a date or
357  	   *  time from a string.  It is used by the istream numeric
358  	   *  extraction operators.
359  	   *
360  	   *  The time_get template uses protected virtual functions to provide the
361  	   *  actual results.  The public accessors forward the call to the virtual
362  	   *  functions.  These virtual functions are hooks for developers to
363  	   *  implement the behavior they require from the time_get facet.
364  	  */
365  	  template<typename _CharT, typename _InIter>
366  	    class time_get : public locale::facet, public time_base
367  	    {
368  	    public:
369  	      // Types:
370  	      //@{
371  	      /// Public typedefs
372  	      typedef _CharT			char_type;
373  	      typedef _InIter			iter_type;
374  	      //@}
375  	
376  	      /// Numpunct facet id.
377  	      static locale::id			id;
378  	
379  	      /**
380  	       *  @brief  Constructor performs initialization.
381  	       *
382  	       *  This is the constructor provided by the standard.
383  	       *
384  	       *  @param __refs  Passed to the base facet class.
385  	      */
386  	      explicit
387  	      time_get(size_t __refs = 0)
388  	      : facet (__refs) { }
389  	
390  	      /**
391  	       *  @brief  Return preferred order of month, day, and year.
392  	       *
393  	       *  This function returns an enum from time_base::dateorder giving the
394  	       *  preferred ordering if the format @a x given to time_put::put() only
395  	       *  uses month, day, and year.  If the format @a x for the associated
396  	       *  locale uses other fields, this function returns
397  	       *  time_base::dateorder::noorder.
398  	       *
399  	       *  NOTE: The library always returns noorder at the moment.
400  	       *
401  	       *  @return  A member of time_base::dateorder.
402  	      */
403  	      dateorder
404  	      date_order()  const
405  	      { return this->do_date_order(); }
406  	
407  	      /**
408  	       *  @brief  Parse input time string.
409  	       *
410  	       *  This function parses a time according to the format @a X and puts the
411  	       *  results into a user-supplied struct tm.  The result is returned by
412  	       *  calling time_get::do_get_time().
413  	       *
414  	       *  If there is a valid time string according to format @a X, @a tm will
415  	       *  be filled in accordingly and the returned iterator will point to the
416  	       *  first character beyond the time string.  If an error occurs before
417  	       *  the end, err |= ios_base::failbit.  If parsing reads all the
418  	       *  characters, err |= ios_base::eofbit.
419  	       *
420  	       *  @param  __beg  Start of string to parse.
421  	       *  @param  __end  End of string to parse.
422  	       *  @param  __io  Source of the locale.
423  	       *  @param  __err  Error flags to set.
424  	       *  @param  __tm  Pointer to struct tm to fill in.
425  	       *  @return  Iterator to first char beyond time string.
426  	      */
427  	      iter_type
428  	      get_time(iter_type __beg, iter_type __end, ios_base& __io,
429  		       ios_base::iostate& __err, tm* __tm)  const
430  	      { return this->do_get_time(__beg, __end, __io, __err, __tm); }
431  	
432  	      /**
433  	       *  @brief  Parse input date string.
434  	       *
435  	       *  This function parses a date according to the format @a x and puts the
436  	       *  results into a user-supplied struct tm.  The result is returned by
437  	       *  calling time_get::do_get_date().
438  	       *
439  	       *  If there is a valid date string according to format @a x, @a tm will
440  	       *  be filled in accordingly and the returned iterator will point to the
441  	       *  first character beyond the date string.  If an error occurs before
442  	       *  the end, err |= ios_base::failbit.  If parsing reads all the
443  	       *  characters, err |= ios_base::eofbit.
444  	       *
445  	       *  @param  __beg  Start of string to parse.
446  	       *  @param  __end  End of string to parse.
447  	       *  @param  __io  Source of the locale.
448  	       *  @param  __err  Error flags to set.
449  	       *  @param  __tm  Pointer to struct tm to fill in.
450  	       *  @return  Iterator to first char beyond date string.
451  	      */
452  	      iter_type
453  	      get_date(iter_type __beg, iter_type __end, ios_base& __io,
454  		       ios_base::iostate& __err, tm* __tm)  const
455  	      { return this->do_get_date(__beg, __end, __io, __err, __tm); }
456  	
457  	      /**
458  	       *  @brief  Parse input weekday string.
459  	       *
460  	       *  This function parses a weekday name and puts the results into a
461  	       *  user-supplied struct tm.  The result is returned by calling
462  	       *  time_get::do_get_weekday().
463  	       *
464  	       *  Parsing starts by parsing an abbreviated weekday name.  If a valid
465  	       *  abbreviation is followed by a character that would lead to the full
466  	       *  weekday name, parsing continues until the full name is found or an
467  	       *  error occurs.  Otherwise parsing finishes at the end of the
468  	       *  abbreviated name.
469  	       *
470  	       *  If an error occurs before the end, err |= ios_base::failbit.  If
471  	       *  parsing reads all the characters, err |= ios_base::eofbit.
472  	       *
473  	       *  @param  __beg  Start of string to parse.
474  	       *  @param  __end  End of string to parse.
475  	       *  @param  __io  Source of the locale.
476  	       *  @param  __err  Error flags to set.
477  	       *  @param  __tm  Pointer to struct tm to fill in.
478  	       *  @return  Iterator to first char beyond weekday name.
479  	      */
480  	      iter_type
481  	      get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
482  			  ios_base::iostate& __err, tm* __tm) const
483  	      { return this->do_get_weekday(__beg, __end, __io, __err, __tm); }
484  	
485  	      /**
486  	       *  @brief  Parse input month string.
487  	       *
488  	       *  This function parses a month name and puts the results into a
489  	       *  user-supplied struct tm.  The result is returned by calling
490  	       *  time_get::do_get_monthname().
491  	       *
492  	       *  Parsing starts by parsing an abbreviated month name.  If a valid
493  	       *  abbreviation is followed by a character that would lead to the full
494  	       *  month name, parsing continues until the full name is found or an
495  	       *  error occurs.  Otherwise parsing finishes at the end of the
496  	       *  abbreviated name.
497  	       *
498  	       *  If an error occurs before the end, err |= ios_base::failbit.  If
499  	       *  parsing reads all the characters, err |=
500  	       *  ios_base::eofbit.
501  	       *
502  	       *  @param  __beg  Start of string to parse.
503  	       *  @param  __end  End of string to parse.
504  	       *  @param  __io  Source of the locale.
505  	       *  @param  __err  Error flags to set.
506  	       *  @param  __tm  Pointer to struct tm to fill in.
507  	       *  @return  Iterator to first char beyond month name.
508  	      */
509  	      iter_type
510  	      get_monthname(iter_type __beg, iter_type __end, ios_base& __io,
511  			    ios_base::iostate& __err, tm* __tm) const
512  	      { return this->do_get_monthname(__beg, __end, __io, __err, __tm); }
513  	
514  	      /**
515  	       *  @brief  Parse input year string.
516  	       *
517  	       *  This function reads up to 4 characters to parse a year string and
518  	       *  puts the results into a user-supplied struct tm.  The result is
519  	       *  returned by calling time_get::do_get_year().
520  	       *
521  	       *  4 consecutive digits are interpreted as a full year.  If there are
522  	       *  exactly 2 consecutive digits, the library interprets this as the
523  	       *  number of years since 1900.
524  	       *
525  	       *  If an error occurs before the end, err |= ios_base::failbit.  If
526  	       *  parsing reads all the characters, err |= ios_base::eofbit.
527  	       *
528  	       *  @param  __beg  Start of string to parse.
529  	       *  @param  __end  End of string to parse.
530  	       *  @param  __io  Source of the locale.
531  	       *  @param  __err  Error flags to set.
532  	       *  @param  __tm  Pointer to struct tm to fill in.
533  	       *  @return  Iterator to first char beyond year.
534  	      */
535  	      iter_type
536  	      get_year(iter_type __beg, iter_type __end, ios_base& __io,
537  		       ios_base::iostate& __err, tm* __tm) const
538  	      { return this->do_get_year(__beg, __end, __io, __err, __tm); }
539  	
540  	#if __cplusplus >= 201103L
541  	      /**
542  	       *  @brief  Parse input string according to format.
543  	       *
544  	       *  This function calls time_get::do_get with the provided
545  	       *  parameters.  @see do_get() and get().
546  	       *
547  	       *  @param __s        Start of string to parse.
548  	       *  @param __end      End of string to parse.
549  	       *  @param __io       Source of the locale.
550  	       *  @param __err      Error flags to set.
551  	       *  @param __tm       Pointer to struct tm to fill in.
552  	       *  @param __format   Format specifier.
553  	       *  @param __modifier Format modifier.
554  	       *  @return  Iterator to first char not parsed.
555  	       */
556  	      inline
557  	      iter_type get(iter_type __s, iter_type __end, ios_base& __io,
558  	                    ios_base::iostate& __err, tm* __tm, char __format,
559  	                    char __modifier = 0) const
560  	      {
561  	        return this->do_get(__s, __end, __io, __err, __tm, __format,
562  	                            __modifier);
563  	      }
564  	
565  	      /**
566  	       *  @brief  Parse input string according to format.
567  	       *
568  	       *  This function parses the input string according to a
569  	       *  provided format string.  It does the inverse of
570  	       *  time_put::put.  The format string follows the format
571  	       *  specified for strftime(3)/strptime(3).  The actual parsing
572  	       *  is done by time_get::do_get.
573  	       *
574  	       *  @param __s        Start of string to parse.
575  	       *  @param __end      End of string to parse.
576  	       *  @param __io       Source of the locale.
577  	       *  @param __err      Error flags to set.
578  	       *  @param __tm       Pointer to struct tm to fill in.
579  	       *  @param __fmt      Start of the format string.
580  	       *  @param __fmtend   End of the format string.
581  	       *  @return  Iterator to first char not parsed.
582  	       */
583  	      iter_type get(iter_type __s, iter_type __end, ios_base& __io,
584  	                    ios_base::iostate& __err, tm* __tm, const char_type* __fmt,
585  	                    const char_type* __fmtend) const;
586  	#endif // __cplusplus >= 201103L
587  	
588  	    protected:
589  	      /// Destructor.
590  	      virtual
591  	      ~time_get() { }
592  	
593  	      /**
594  	       *  @brief  Return preferred order of month, day, and year.
595  	       *
596  	       *  This function returns an enum from time_base::dateorder giving the
597  	       *  preferred ordering if the format @a x given to time_put::put() only
598  	       *  uses month, day, and year.  This function is a hook for derived
599  	       *  classes to change the value returned.
600  	       *
601  	       *  @return  A member of time_base::dateorder.
602  	      */
603  	      virtual dateorder
604  	      do_date_order() const;
605  	
606  	      /**
607  	       *  @brief  Parse input time string.
608  	       *
609  	       *  This function parses a time according to the format @a x and puts the
610  	       *  results into a user-supplied struct tm.  This function is a hook for
611  	       *  derived classes to change the value returned.  @see get_time() for
612  	       *  details.
613  	       *
614  	       *  @param  __beg  Start of string to parse.
615  	       *  @param  __end  End of string to parse.
616  	       *  @param  __io  Source of the locale.
617  	       *  @param  __err  Error flags to set.
618  	       *  @param  __tm  Pointer to struct tm to fill in.
619  	       *  @return  Iterator to first char beyond time string.
620  	      */
621  	      virtual iter_type
622  	      do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
623  			  ios_base::iostate& __err, tm* __tm) const;
624  	
625  	      /**
626  	       *  @brief  Parse input date string.
627  	       *
628  	       *  This function parses a date according to the format @a X and puts the
629  	       *  results into a user-supplied struct tm.  This function is a hook for
630  	       *  derived classes to change the value returned.  @see get_date() for
631  	       *  details.
632  	       *
633  	       *  @param  __beg  Start of string to parse.
634  	       *  @param  __end  End of string to parse.
635  	       *  @param  __io  Source of the locale.
636  	       *  @param  __err  Error flags to set.
637  	       *  @param  __tm  Pointer to struct tm to fill in.
638  	       *  @return  Iterator to first char beyond date string.
639  	      */
640  	      virtual iter_type
641  	      do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
642  			  ios_base::iostate& __err, tm* __tm) const;
643  	
644  	      /**
645  	       *  @brief  Parse input weekday string.
646  	       *
647  	       *  This function parses a weekday name and puts the results into a
648  	       *  user-supplied struct tm.  This function is a hook for derived
649  	       *  classes to change the value returned.  @see get_weekday() for
650  	       *  details.
651  	       *
652  	       *  @param  __beg  Start of string to parse.
653  	       *  @param  __end  End of string to parse.
654  	       *  @param  __io  Source of the locale.
655  	       *  @param  __err  Error flags to set.
656  	       *  @param  __tm  Pointer to struct tm to fill in.
657  	       *  @return  Iterator to first char beyond weekday name.
658  	      */
659  	      virtual iter_type
660  	      do_get_weekday(iter_type __beg, iter_type __end, ios_base&,
661  			     ios_base::iostate& __err, tm* __tm) const;
662  	
663  	      /**
664  	       *  @brief  Parse input month string.
665  	       *
666  	       *  This function parses a month name and puts the results into a
667  	       *  user-supplied struct tm.  This function is a hook for derived
668  	       *  classes to change the value returned.  @see get_monthname() for
669  	       *  details.
670  	       *
671  	       *  @param  __beg  Start of string to parse.
672  	       *  @param  __end  End of string to parse.
673  	       *  @param  __io  Source of the locale.
674  	       *  @param  __err  Error flags to set.
675  	       *  @param  __tm  Pointer to struct tm to fill in.
676  	       *  @return  Iterator to first char beyond month name.
677  	      */
678  	      virtual iter_type
679  	      do_get_monthname(iter_type __beg, iter_type __end, ios_base&,
680  			       ios_base::iostate& __err, tm* __tm) const;
681  	
682  	      /**
683  	       *  @brief  Parse input year string.
684  	       *
685  	       *  This function reads up to 4 characters to parse a year string and
686  	       *  puts the results into a user-supplied struct tm.  This function is a
687  	       *  hook for derived classes to change the value returned.  @see
688  	       *  get_year() for details.
689  	       *
690  	       *  @param  __beg  Start of string to parse.
691  	       *  @param  __end  End of string to parse.
692  	       *  @param  __io  Source of the locale.
693  	       *  @param  __err  Error flags to set.
694  	       *  @param  __tm  Pointer to struct tm to fill in.
695  	       *  @return  Iterator to first char beyond year.
696  	      */
697  	      virtual iter_type
698  	      do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
699  			  ios_base::iostate& __err, tm* __tm) const;
700  	
701  	#if __cplusplus >= 201103L
702  	      /**
703  	       *  @brief  Parse input string according to format.
704  	       *
705  	       *  This function parses the string according to the provided
706  	       *  format and optional modifier.  This function is a hook for
707  	       *  derived classes to change the value returned.  @see get()
708  	       *  for more details.
709  	       *
710  	       *  @param __s        Start of string to parse.
711  	       *  @param __end      End of string to parse.
712  	       *  @param __f        Source of the locale.
713  	       *  @param __err      Error flags to set.
714  	       *  @param __tm       Pointer to struct tm to fill in.
715  	       *  @param __format   Format specifier.
716  	       *  @param __modifier Format modifier.
717  	       *  @return  Iterator to first char not parsed.
718  	       */
719  	#if _GLIBCXX_USE_CXX11_ABI
720  	      virtual
721  	#endif
722  	      iter_type
723  	      do_get(iter_type __s, iter_type __end, ios_base& __f,
724  	             ios_base::iostate& __err, tm* __tm,
725  	             char __format, char __modifier) const;
726  	#endif // __cplusplus >= 201103L
727  	
728  	      // Extract numeric component of length __len.
729  	      iter_type
730  	      _M_extract_num(iter_type __beg, iter_type __end, int& __member,
731  			     int __min, int __max, size_t __len,
732  			     ios_base& __io, ios_base::iostate& __err) const;
733  	
734  	      // Extract any unique array of string literals in a const _CharT* array.
735  	      iter_type
736  	      _M_extract_name(iter_type __beg, iter_type __end, int& __member,
737  			      const _CharT** __names, size_t __indexlen,
738  			      ios_base& __io, ios_base::iostate& __err) const;
739  	
740  	      // Extract day or month name in a const _CharT* array.
741  	      iter_type
742  	      _M_extract_wday_or_month(iter_type __beg, iter_type __end, int& __member,
743  				       const _CharT** __names, size_t __indexlen,
744  				       ios_base& __io, ios_base::iostate& __err) const;
745  	
746  	      // Extract on a component-by-component basis, via __format argument.
747  	      iter_type
748  	      _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
749  				    ios_base::iostate& __err, tm* __tm,
750  				    const _CharT* __format) const;
751  	    };
752  	
753  	  template<typename _CharT, typename _InIter>
754  	    locale::id time_get<_CharT, _InIter>::id;
755  	
756  	  /// class time_get_byname [22.2.5.2].
757  	  template<typename _CharT, typename _InIter>
758  	    class time_get_byname : public time_get<_CharT, _InIter>
759  	    {
760  	    public:
761  	      // Types:
762  	      typedef _CharT			char_type;
763  	      typedef _InIter			iter_type;
764  	
765  	      explicit
766  	      time_get_byname(const char*, size_t __refs = 0)
767  	      : time_get<_CharT, _InIter>(__refs) { }
768  	
769  	#if __cplusplus >= 201103L
770  	      explicit
771  	      time_get_byname(const string& __s, size_t __refs = 0)
772  	      : time_get_byname(__s.c_str(), __refs) { }
773  	#endif
774  	
775  	    protected:
776  	      virtual
777  	      ~time_get_byname() { }
778  	    };
779  	
780  	_GLIBCXX_END_NAMESPACE_CXX11
781  	
782  	  /**
783  	   *  @brief  Primary class template time_put.
784  	   *  @ingroup locales
785  	   *
786  	   *  This facet encapsulates the code to format and output dates and times
787  	   *  according to formats used by strftime().
788  	   *
789  	   *  The time_put template uses protected virtual functions to provide the
790  	   *  actual results.  The public accessors forward the call to the virtual
791  	   *  functions.  These virtual functions are hooks for developers to
792  	   *  implement the behavior they require from the time_put facet.
793  	  */
794  	  template<typename _CharT, typename _OutIter>
795  	    class time_put : public locale::facet
796  	    {
797  	    public:
798  	      // Types:
799  	      //@{
800  	      /// Public typedefs
801  	      typedef _CharT			char_type;
802  	      typedef _OutIter			iter_type;
803  	      //@}
804  	
805  	      /// Numpunct facet id.
806  	      static locale::id			id;
807  	
808  	      /**
809  	       *  @brief  Constructor performs initialization.
810  	       *
811  	       *  This is the constructor provided by the standard.
812  	       *
813  	       *  @param __refs  Passed to the base facet class.
814  	      */
815  	      explicit
816  	      time_put(size_t __refs = 0)
817  	      : facet(__refs) { }
818  	
819  	      /**
820  	       *  @brief  Format and output a time or date.
821  	       *
822  	       *  This function formats the data in struct tm according to the
823  	       *  provided format string.  The format string is interpreted as by
824  	       *  strftime().
825  	       *
826  	       *  @param  __s  The stream to write to.
827  	       *  @param  __io  Source of locale.
828  	       *  @param  __fill  char_type to use for padding.
829  	       *  @param  __tm  Struct tm with date and time info to format.
830  	       *  @param  __beg  Start of format string.
831  	       *  @param  __end  End of format string.
832  	       *  @return  Iterator after writing.
833  	       */
834  	      iter_type
835  	      put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
836  		  const _CharT* __beg, const _CharT* __end) const;
837  	
838  	      /**
839  	       *  @brief  Format and output a time or date.
840  	       *
841  	       *  This function formats the data in struct tm according to the
842  	       *  provided format char and optional modifier.  The format and modifier
843  	       *  are interpreted as by strftime().  It does so by returning
844  	       *  time_put::do_put().
845  	       *
846  	       *  @param  __s  The stream to write to.
847  	       *  @param  __io  Source of locale.
848  	       *  @param  __fill  char_type to use for padding.
849  	       *  @param  __tm  Struct tm with date and time info to format.
850  	       *  @param  __format  Format char.
851  	       *  @param  __mod  Optional modifier char.
852  	       *  @return  Iterator after writing.
853  	       */
854  	      iter_type
855  	      put(iter_type __s, ios_base& __io, char_type __fill,
856  		  const tm* __tm, char __format, char __mod = 0) const
857  	      { return this->do_put(__s, __io, __fill, __tm, __format, __mod); }
858  	
859  	    protected:
860  	      /// Destructor.
861  	      virtual
862  	      ~time_put()
863  	      { }
864  	
865  	      /**
866  	       *  @brief  Format and output a time or date.
867  	       *
868  	       *  This function formats the data in struct tm according to the
869  	       *  provided format char and optional modifier.  This function is a hook
870  	       *  for derived classes to change the value returned.  @see put() for
871  	       *  more details.
872  	       *
873  	       *  @param  __s  The stream to write to.
874  	       *  @param  __io  Source of locale.
875  	       *  @param  __fill  char_type to use for padding.
876  	       *  @param  __tm  Struct tm with date and time info to format.
877  	       *  @param  __format  Format char.
878  	       *  @param  __mod  Optional modifier char.
879  	       *  @return  Iterator after writing.
880  	       */
881  	      virtual iter_type
882  	      do_put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
883  		     char __format, char __mod) const;
884  	    };
885  	
886  	  template<typename _CharT, typename _OutIter>
887  	    locale::id time_put<_CharT, _OutIter>::id;
888  	
889  	  /// class time_put_byname [22.2.5.4].
890  	  template<typename _CharT, typename _OutIter>
891  	    class time_put_byname : public time_put<_CharT, _OutIter>
892  	    {
893  	    public:
894  	      // Types:
895  	      typedef _CharT			char_type;
896  	      typedef _OutIter			iter_type;
897  	
898  	      explicit
899  	      time_put_byname(const char*, size_t __refs = 0)
900  	      : time_put<_CharT, _OutIter>(__refs)
901  	      { };
902  	
903  	#if __cplusplus >= 201103L
904  	      explicit
905  	      time_put_byname(const string& __s, size_t __refs = 0)
906  	      : time_put_byname(__s.c_str(), __refs) { }
907  	#endif
908  	
909  	    protected:
910  	      virtual
911  	      ~time_put_byname() { }
912  	    };
913  	
914  	
915  	  /**
916  	   *  @brief  Money format ordering data.
917  	   *  @ingroup locales
918  	   *
919  	   *  This class contains an ordered array of 4 fields to represent the
920  	   *  pattern for formatting a money amount.  Each field may contain one entry
921  	   *  from the part enum.  symbol, sign, and value must be present and the
922  	   *  remaining field must contain either none or space.  @see
923  	   *  moneypunct::pos_format() and moneypunct::neg_format() for details of how
924  	   *  these fields are interpreted.
925  	  */
926  	  class money_base
927  	  {
928  	  public:
929  	    enum part { none, space, symbol, sign, value };
930  	    struct pattern { char field[4]; };
931  	
932  	    static const pattern _S_default_pattern;
933  	
934  	    enum
935  	    {
936  	      _S_minus,
937  	      _S_zero,
938  	      _S_end = 11
939  	    };
940  	
941  	    // String literal of acceptable (narrow) input/output, for
942  	    // money_get/money_put. "-0123456789"
943  	    static const char* _S_atoms;
944  	
945  	    // Construct and return valid pattern consisting of some combination of:
946  	    // space none symbol sign value
947  	    _GLIBCXX_CONST static pattern
948  	    _S_construct_pattern(char __precedes, char __space, char __posn) throw ();
949  	  };
950  	
951  	  template<typename _CharT, bool _Intl>
952  	    struct __moneypunct_cache : public locale::facet
953  	    {
954  	      const char*			_M_grouping;
955  	      size_t                            _M_grouping_size;
956  	      bool				_M_use_grouping;
957  	      _CharT				_M_decimal_point;
958  	      _CharT				_M_thousands_sep;
959  	      const _CharT*			_M_curr_symbol;
960  	      size_t                            _M_curr_symbol_size;
961  	      const _CharT*			_M_positive_sign;
962  	      size_t                            _M_positive_sign_size;
963  	      const _CharT*			_M_negative_sign;
964  	      size_t                            _M_negative_sign_size;
965  	      int				_M_frac_digits;
966  	      money_base::pattern		_M_pos_format;
967  	      money_base::pattern	        _M_neg_format;
968  	
969  	      // A list of valid numeric literals for input and output: in the standard
970  	      // "C" locale, this is "-0123456789". This array contains the chars after
971  	      // having been passed through the current locale's ctype<_CharT>.widen().
972  	      _CharT				_M_atoms[money_base::_S_end];
973  	
974  	      bool				_M_allocated;
975  	
976  	      __moneypunct_cache(size_t __refs = 0) : facet(__refs),
977  	      _M_grouping(0), _M_grouping_size(0), _M_use_grouping(false),
978  	      _M_decimal_point(_CharT()), _M_thousands_sep(_CharT()),
979  	      _M_curr_symbol(0), _M_curr_symbol_size(0),
980  	      _M_positive_sign(0), _M_positive_sign_size(0),
981  	      _M_negative_sign(0), _M_negative_sign_size(0),
982  	      _M_frac_digits(0),
983  	      _M_pos_format(money_base::pattern()),
984  	      _M_neg_format(money_base::pattern()), _M_allocated(false)
985  	      { }
986  	
987  	      ~__moneypunct_cache();
988  	
989  	      void
990  	      _M_cache(const locale& __loc);
991  	
992  	    private:
993  	      __moneypunct_cache&
994  	      operator=(const __moneypunct_cache&);
995  	      
996  	      explicit
997  	      __moneypunct_cache(const __moneypunct_cache&);
998  	    };
999  	
1000 	  template<typename _CharT, bool _Intl>
1001 	    __moneypunct_cache<_CharT, _Intl>::~__moneypunct_cache()
1002 	    {
1003 	      if (_M_allocated)
1004 		{
1005 		  delete [] _M_grouping;
1006 		  delete [] _M_curr_symbol;
1007 		  delete [] _M_positive_sign;
1008 		  delete [] _M_negative_sign;
1009 		}
1010 	    }
1011 	
1012 	_GLIBCXX_BEGIN_NAMESPACE_CXX11
1013 	
1014 	  /**
1015 	   *  @brief  Primary class template moneypunct.
1016 	   *  @ingroup locales
1017 	   *
1018 	   *  This facet encapsulates the punctuation, grouping and other formatting
1019 	   *  features of money amount string representations.
1020 	  */
1021 	  template<typename _CharT, bool _Intl>
1022 	    class moneypunct : public locale::facet, public money_base
1023 	    {
1024 	    public:
1025 	      // Types:
1026 	      //@{
1027 	      /// Public typedefs
1028 	      typedef _CharT			char_type;
1029 	      typedef basic_string<_CharT>	string_type;
1030 	      //@}
1031 	      typedef __moneypunct_cache<_CharT, _Intl>     __cache_type;
1032 	
1033 	    private:
1034 	      __cache_type*			_M_data;
1035 	
1036 	    public:
1037 	      /// This value is provided by the standard, but no reason for its
1038 	      /// existence.
1039 	      static const bool			intl = _Intl;
1040 	      /// Numpunct facet id.
1041 	      static locale::id			id;
1042 	
1043 	      /**
1044 	       *  @brief  Constructor performs initialization.
1045 	       *
1046 	       *  This is the constructor provided by the standard.
1047 	       *
1048 	       *  @param __refs  Passed to the base facet class.
1049 	      */
1050 	      explicit
1051 	      moneypunct(size_t __refs = 0)
1052 	      : facet(__refs), _M_data(0)
1053 	      { _M_initialize_moneypunct(); }
1054 	
1055 	      /**
1056 	       *  @brief  Constructor performs initialization.
1057 	       *
1058 	       *  This is an internal constructor.
1059 	       *
1060 	       *  @param __cache  Cache for optimization.
1061 	       *  @param __refs  Passed to the base facet class.
1062 	      */
1063 	      explicit
1064 	      moneypunct(__cache_type* __cache, size_t __refs = 0)
1065 	      : facet(__refs), _M_data(__cache)
1066 	      { _M_initialize_moneypunct(); }
1067 	
1068 	      /**
1069 	       *  @brief  Internal constructor. Not for general use.
1070 	       *
1071 	       *  This is a constructor for use by the library itself to set up new
1072 	       *  locales.
1073 	       *
1074 	       *  @param __cloc  The C locale.
1075 	       *  @param __s  The name of a locale.
1076 	       *  @param __refs  Passed to the base facet class.
1077 	      */
1078 	      explicit
1079 	      moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0)
1080 	      : facet(__refs), _M_data(0)
1081 	      { _M_initialize_moneypunct(__cloc, __s); }
1082 	
1083 	      /**
1084 	       *  @brief  Return decimal point character.
1085 	       *
1086 	       *  This function returns a char_type to use as a decimal point.  It
1087 	       *  does so by returning returning
1088 	       *  moneypunct<char_type>::do_decimal_point().
1089 	       *
1090 	       *  @return  @a char_type representing a decimal point.
1091 	      */
1092 	      char_type
1093 	      decimal_point() const
1094 	      { return this->do_decimal_point(); }
1095 	
1096 	      /**
1097 	       *  @brief  Return thousands separator character.
1098 	       *
1099 	       *  This function returns a char_type to use as a thousands
1100 	       *  separator.  It does so by returning returning
1101 	       *  moneypunct<char_type>::do_thousands_sep().
1102 	       *
1103 	       *  @return  char_type representing a thousands separator.
1104 	      */
1105 	      char_type
1106 	      thousands_sep() const
1107 	      { return this->do_thousands_sep(); }
1108 	
1109 	      /**
1110 	       *  @brief  Return grouping specification.
1111 	       *
1112 	       *  This function returns a string representing groupings for the
1113 	       *  integer part of an amount.  Groupings indicate where thousands
1114 	       *  separators should be inserted.
1115 	       *
1116 	       *  Each char in the return string is interpret as an integer rather
1117 	       *  than a character.  These numbers represent the number of digits in a
1118 	       *  group.  The first char in the string represents the number of digits
1119 	       *  in the least significant group.  If a char is negative, it indicates
1120 	       *  an unlimited number of digits for the group.  If more chars from the
1121 	       *  string are required to group a number, the last char is used
1122 	       *  repeatedly.
1123 	       *
1124 	       *  For example, if the grouping() returns <code>\003\002</code>
1125 	       *  and is applied to the number 123456789, this corresponds to
1126 	       *  12,34,56,789.  Note that if the string was <code>32</code>, this would
1127 	       *  put more than 50 digits into the least significant group if
1128 	       *  the character set is ASCII.
1129 	       *
1130 	       *  The string is returned by calling
1131 	       *  moneypunct<char_type>::do_grouping().
1132 	       *
1133 	       *  @return  string representing grouping specification.
1134 	      */
1135 	      string
1136 	      grouping() const
1137 	      { return this->do_grouping(); }
1138 	
1139 	      /**
1140 	       *  @brief  Return currency symbol string.
1141 	       *
1142 	       *  This function returns a string_type to use as a currency symbol.  It
1143 	       *  does so by returning returning
1144 	       *  moneypunct<char_type>::do_curr_symbol().
1145 	       *
1146 	       *  @return  @a string_type representing a currency symbol.
1147 	      */
1148 	      string_type
1149 	      curr_symbol() const
1150 	      { return this->do_curr_symbol(); }
1151 	
1152 	      /**
1153 	       *  @brief  Return positive sign string.
1154 	       *
1155 	       *  This function returns a string_type to use as a sign for positive
1156 	       *  amounts.  It does so by returning returning
1157 	       *  moneypunct<char_type>::do_positive_sign().
1158 	       *
1159 	       *  If the return value contains more than one character, the first
1160 	       *  character appears in the position indicated by pos_format() and the
1161 	       *  remainder appear at the end of the formatted string.
1162 	       *
1163 	       *  @return  @a string_type representing a positive sign.
1164 	      */
1165 	      string_type
1166 	      positive_sign() const
1167 	      { return this->do_positive_sign(); }
1168 	
1169 	      /**
1170 	       *  @brief  Return negative sign string.
1171 	       *
1172 	       *  This function returns a string_type to use as a sign for negative
1173 	       *  amounts.  It does so by returning returning
1174 	       *  moneypunct<char_type>::do_negative_sign().
1175 	       *
1176 	       *  If the return value contains more than one character, the first
1177 	       *  character appears in the position indicated by neg_format() and the
1178 	       *  remainder appear at the end of the formatted string.
1179 	       *
1180 	       *  @return  @a string_type representing a negative sign.
1181 	      */
1182 	      string_type
1183 	      negative_sign() const
1184 	      { return this->do_negative_sign(); }
1185 	
1186 	      /**
1187 	       *  @brief  Return number of digits in fraction.
1188 	       *
1189 	       *  This function returns the exact number of digits that make up the
1190 	       *  fractional part of a money amount.  It does so by returning
1191 	       *  returning moneypunct<char_type>::do_frac_digits().
1192 	       *
1193 	       *  The fractional part of a money amount is optional.  But if it is
1194 	       *  present, there must be frac_digits() digits.
1195 	       *
1196 	       *  @return  Number of digits in amount fraction.
1197 	      */
1198 	      int
1199 	      frac_digits() const
1200 	      { return this->do_frac_digits(); }
1201 	
1202 	      //@{
1203 	      /**
1204 	       *  @brief  Return pattern for money values.
1205 	       *
1206 	       *  This function returns a pattern describing the formatting of a
1207 	       *  positive or negative valued money amount.  It does so by returning
1208 	       *  returning moneypunct<char_type>::do_pos_format() or
1209 	       *  moneypunct<char_type>::do_neg_format().
1210 	       *
1211 	       *  The pattern has 4 fields describing the ordering of symbol, sign,
1212 	       *  value, and none or space.  There must be one of each in the pattern.
1213 	       *  The none and space enums may not appear in the first field and space
1214 	       *  may not appear in the final field.
1215 	       *
1216 	       *  The parts of a money string must appear in the order indicated by
1217 	       *  the fields of the pattern.  The symbol field indicates that the
1218 	       *  value of curr_symbol() may be present.  The sign field indicates
1219 	       *  that the value of positive_sign() or negative_sign() must be
1220 	       *  present.  The value field indicates that the absolute value of the
1221 	       *  money amount is present.  none indicates 0 or more whitespace
1222 	       *  characters, except at the end, where it permits no whitespace.
1223 	       *  space indicates that 1 or more whitespace characters must be
1224 	       *  present.
1225 	       *
1226 	       *  For example, for the US locale and pos_format() pattern
1227 	       *  {symbol,sign,value,none}, curr_symbol() == &apos;$&apos;
1228 	       *  positive_sign() == &apos;+&apos;, and value 10.01, and
1229 	       *  options set to force the symbol, the corresponding string is
1230 	       *  <code>$+10.01</code>.
1231 	       *
1232 	       *  @return  Pattern for money values.
1233 	      */
1234 	      pattern
1235 	      pos_format() const
1236 	      { return this->do_pos_format(); }
1237 	
1238 	      pattern
1239 	      neg_format() const
1240 	      { return this->do_neg_format(); }
1241 	      //@}
1242 	
1243 	    protected:
1244 	      /// Destructor.
1245 	      virtual
1246 	      ~moneypunct();
1247 	
1248 	      /**
1249 	       *  @brief  Return decimal point character.
1250 	       *
1251 	       *  Returns a char_type to use as a decimal point.  This function is a
1252 	       *  hook for derived classes to change the value returned.
1253 	       *
1254 	       *  @return  @a char_type representing a decimal point.
1255 	      */
1256 	      virtual char_type
1257 	      do_decimal_point() const
1258 	      { return _M_data->_M_decimal_point; }
1259 	
1260 	      /**
1261 	       *  @brief  Return thousands separator character.
1262 	       *
1263 	       *  Returns a char_type to use as a thousands separator.  This function
1264 	       *  is a hook for derived classes to change the value returned.
1265 	       *
1266 	       *  @return  @a char_type representing a thousands separator.
1267 	      */
1268 	      virtual char_type
1269 	      do_thousands_sep() const
1270 	      { return _M_data->_M_thousands_sep; }
1271 	
1272 	      /**
1273 	       *  @brief  Return grouping specification.
1274 	       *
1275 	       *  Returns a string representing groupings for the integer part of a
1276 	       *  number.  This function is a hook for derived classes to change the
1277 	       *  value returned.  @see grouping() for details.
1278 	       *
1279 	       *  @return  String representing grouping specification.
1280 	      */
1281 	      virtual string
1282 	      do_grouping() const
1283 	      { return _M_data->_M_grouping; }
1284 	
1285 	      /**
1286 	       *  @brief  Return currency symbol string.
1287 	       *
1288 	       *  This function returns a string_type to use as a currency symbol.
1289 	       *  This function is a hook for derived classes to change the value
1290 	       *  returned.  @see curr_symbol() for details.
1291 	       *
1292 	       *  @return  @a string_type representing a currency symbol.
1293 	      */
1294 	      virtual string_type
1295 	      do_curr_symbol()   const
1296 	      { return _M_data->_M_curr_symbol; }
1297 	
1298 	      /**
1299 	       *  @brief  Return positive sign string.
1300 	       *
1301 	       *  This function returns a string_type to use as a sign for positive
1302 	       *  amounts.  This function is a hook for derived classes to change the
1303 	       *  value returned.  @see positive_sign() for details.
1304 	       *
1305 	       *  @return  @a string_type representing a positive sign.
1306 	      */
1307 	      virtual string_type
1308 	      do_positive_sign() const
1309 	      { return _M_data->_M_positive_sign; }
1310 	
1311 	      /**
1312 	       *  @brief  Return negative sign string.
1313 	       *
1314 	       *  This function returns a string_type to use as a sign for negative
1315 	       *  amounts.  This function is a hook for derived classes to change the
1316 	       *  value returned.  @see negative_sign() for details.
1317 	       *
1318 	       *  @return  @a string_type representing a negative sign.
1319 	      */
1320 	      virtual string_type
1321 	      do_negative_sign() const
1322 	      { return _M_data->_M_negative_sign; }
1323 	
1324 	      /**
1325 	       *  @brief  Return number of digits in fraction.
1326 	       *
1327 	       *  This function returns the exact number of digits that make up the
1328 	       *  fractional part of a money amount.  This function is a hook for
1329 	       *  derived classes to change the value returned.  @see frac_digits()
1330 	       *  for details.
1331 	       *
1332 	       *  @return  Number of digits in amount fraction.
1333 	      */
1334 	      virtual int
1335 	      do_frac_digits() const
1336 	      { return _M_data->_M_frac_digits; }
1337 	
1338 	      /**
1339 	       *  @brief  Return pattern for money values.
1340 	       *
1341 	       *  This function returns a pattern describing the formatting of a
1342 	       *  positive valued money amount.  This function is a hook for derived
1343 	       *  classes to change the value returned.  @see pos_format() for
1344 	       *  details.
1345 	       *
1346 	       *  @return  Pattern for money values.
1347 	      */
1348 	      virtual pattern
1349 	      do_pos_format() const
1350 	      { return _M_data->_M_pos_format; }
1351 	
1352 	      /**
1353 	       *  @brief  Return pattern for money values.
1354 	       *
1355 	       *  This function returns a pattern describing the formatting of a
1356 	       *  negative valued money amount.  This function is a hook for derived
1357 	       *  classes to change the value returned.  @see neg_format() for
1358 	       *  details.
1359 	       *
1360 	       *  @return  Pattern for money values.
1361 	      */
1362 	      virtual pattern
1363 	      do_neg_format() const
1364 	      { return _M_data->_M_neg_format; }
1365 	
1366 	      // For use at construction time only.
1367 	       void
1368 	       _M_initialize_moneypunct(__c_locale __cloc = 0,
1369 					const char* __name = 0);
1370 	    };
1371 	
1372 	  template<typename _CharT, bool _Intl>
1373 	    locale::id moneypunct<_CharT, _Intl>::id;
1374 	
1375 	  template<typename _CharT, bool _Intl>
1376 	    const bool moneypunct<_CharT, _Intl>::intl;
1377 	
1378 	  template<>
1379 	    moneypunct<char, true>::~moneypunct();
1380 	
1381 	  template<>
1382 	    moneypunct<char, false>::~moneypunct();
1383 	
1384 	  template<>
1385 	    void
1386 	    moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*);
1387 	
1388 	  template<>
1389 	    void
1390 	    moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*);
1391 	
1392 	#ifdef _GLIBCXX_USE_WCHAR_T
1393 	  template<>
1394 	    moneypunct<wchar_t, true>::~moneypunct();
1395 	
1396 	  template<>
1397 	    moneypunct<wchar_t, false>::~moneypunct();
1398 	
1399 	  template<>
1400 	    void
1401 	    moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale,
1402 								const char*);
1403 	
1404 	  template<>
1405 	    void
1406 	    moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale,
1407 								 const char*);
1408 	#endif
1409 	
1410 	  /// class moneypunct_byname [22.2.6.4].
1411 	  template<typename _CharT, bool _Intl>
1412 	    class moneypunct_byname : public moneypunct<_CharT, _Intl>
1413 	    {
1414 	    public:
1415 	      typedef _CharT			char_type;
1416 	      typedef basic_string<_CharT>	string_type;
1417 	
1418 	      static const bool intl = _Intl;
1419 	
1420 	      explicit
1421 	      moneypunct_byname(const char* __s, size_t __refs = 0)
1422 	      : moneypunct<_CharT, _Intl>(__refs)
1423 	      {
1424 		if (__builtin_strcmp(__s, "C") != 0
1425 		    && __builtin_strcmp(__s, "POSIX") != 0)
1426 		  {
1427 		    __c_locale __tmp;
1428 		    this->_S_create_c_locale(__tmp, __s);
1429 		    this->_M_initialize_moneypunct(__tmp);
1430 		    this->_S_destroy_c_locale(__tmp);
1431 		  }
1432 	      }
1433 	
1434 	#if __cplusplus >= 201103L
1435 	      explicit
1436 	      moneypunct_byname(const string& __s, size_t __refs = 0)
1437 	      : moneypunct_byname(__s.c_str(), __refs) { }
1438 	#endif
1439 	
1440 	    protected:
1441 	      virtual
1442 	      ~moneypunct_byname() { }
1443 	    };
1444 	
1445 	  template<typename _CharT, bool _Intl>
1446 	    const bool moneypunct_byname<_CharT, _Intl>::intl;
1447 	
1448 	_GLIBCXX_END_NAMESPACE_CXX11
1449 	
1450 	_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
1451 	
1452 	  /**
1453 	   *  @brief  Primary class template money_get.
1454 	   *  @ingroup locales
1455 	   *
1456 	   *  This facet encapsulates the code to parse and return a monetary
1457 	   *  amount from a string.
1458 	   *
1459 	   *  The money_get template uses protected virtual functions to
1460 	   *  provide the actual results.  The public accessors forward the
1461 	   *  call to the virtual functions.  These virtual functions are
1462 	   *  hooks for developers to implement the behavior they require from
1463 	   *  the money_get facet.
1464 	  */
1465 	  template<typename _CharT, typename _InIter>
1466 	    class money_get : public locale::facet
1467 	    {
1468 	    public:
1469 	      // Types:
1470 	      //@{
1471 	      /// Public typedefs
1472 	      typedef _CharT			char_type;
1473 	      typedef _InIter			iter_type;
1474 	      typedef basic_string<_CharT>	string_type;
1475 	      //@}
1476 	
1477 	      /// Numpunct facet id.
1478 	      static locale::id			id;
1479 	
1480 	      /**
1481 	       *  @brief  Constructor performs initialization.
1482 	       *
1483 	       *  This is the constructor provided by the standard.
1484 	       *
1485 	       *  @param __refs  Passed to the base facet class.
1486 	      */
1487 	      explicit
1488 	      money_get(size_t __refs = 0) : facet(__refs) { }
1489 	
1490 	      /**
1491 	       *  @brief  Read and parse a monetary value.
1492 	       *
1493 	       *  This function reads characters from @a __s, interprets them as a
1494 	       *  monetary value according to moneypunct and ctype facets retrieved
1495 	       *  from io.getloc(), and returns the result in @a units as an integral
1496 	       *  value moneypunct::frac_digits() * the actual amount.  For example,
1497 	       *  the string $10.01 in a US locale would store 1001 in @a units.
1498 	       *
1499 	       *  Any characters not part of a valid money amount are not consumed.
1500 	       *
1501 	       *  If a money value cannot be parsed from the input stream, sets
1502 	       *  err=(err|io.failbit).  If the stream is consumed before finishing
1503 	       *  parsing,  sets err=(err|io.failbit|io.eofbit).  @a units is
1504 	       *  unchanged if parsing fails.
1505 	       *
1506 	       *  This function works by returning the result of do_get().
1507 	       *
1508 	       *  @param  __s  Start of characters to parse.
1509 	       *  @param  __end  End of characters to parse.
1510 	       *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1511 	       *  @param  __io  Source of facets and io state.
1512 	       *  @param  __err  Error field to set if parsing fails.
1513 	       *  @param  __units  Place to store result of parsing.
1514 	       *  @return  Iterator referencing first character beyond valid money
1515 	       *	   amount.
1516 	       */
1517 	      iter_type
1518 	      get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1519 		  ios_base::iostate& __err, long double& __units) const
1520 	      { return this->do_get(__s, __end, __intl, __io, __err, __units); }
1521 	
1522 	      /**
1523 	       *  @brief  Read and parse a monetary value.
1524 	       *
1525 	       *  This function reads characters from @a __s, interprets them as
1526 	       *  a monetary value according to moneypunct and ctype facets
1527 	       *  retrieved from io.getloc(), and returns the result in @a
1528 	       *  digits.  For example, the string $10.01 in a US locale would
1529 	       *  store <code>1001</code> in @a digits.
1530 	       *
1531 	       *  Any characters not part of a valid money amount are not consumed.
1532 	       *
1533 	       *  If a money value cannot be parsed from the input stream, sets
1534 	       *  err=(err|io.failbit).  If the stream is consumed before finishing
1535 	       *  parsing,  sets err=(err|io.failbit|io.eofbit).
1536 	       *
1537 	       *  This function works by returning the result of do_get().
1538 	       *
1539 	       *  @param  __s  Start of characters to parse.
1540 	       *  @param  __end  End of characters to parse.
1541 	       *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1542 	       *  @param  __io  Source of facets and io state.
1543 	       *  @param  __err  Error field to set if parsing fails.
1544 	       *  @param  __digits  Place to store result of parsing.
1545 	       *  @return  Iterator referencing first character beyond valid money
1546 	       *	   amount.
1547 	       */
1548 	      iter_type
1549 	      get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1550 		  ios_base::iostate& __err, string_type& __digits) const
1551 	      { return this->do_get(__s, __end, __intl, __io, __err, __digits); }
1552 	
1553 	    protected:
1554 	      /// Destructor.
1555 	      virtual
1556 	      ~money_get() { }
1557 	
1558 	      /**
1559 	       *  @brief  Read and parse a monetary value.
1560 	       *
1561 	       *  This function reads and parses characters representing a monetary
1562 	       *  value.  This function is a hook for derived classes to change the
1563 	       *  value returned.  @see get() for details.
1564 	       */
1565 	      // XXX GLIBCXX_ABI Deprecated
1566 	#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
1567 	      && _GLIBCXX_USE_CXX11_ABI == 0
1568 	      virtual iter_type
1569 	      __do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1570 		       ios_base::iostate& __err, double& __units) const;
1571 	#else
1572 	      virtual iter_type
1573 	      do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1574 		     ios_base::iostate& __err, long double& __units) const;
1575 	#endif
1576 	
1577 	      /**
1578 	       *  @brief  Read and parse a monetary value.
1579 	       *
1580 	       *  This function reads and parses characters representing a monetary
1581 	       *  value.  This function is a hook for derived classes to change the
1582 	       *  value returned.  @see get() for details.
1583 	       */
1584 	      virtual iter_type
1585 	      do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1586 		     ios_base::iostate& __err, string_type& __digits) const;
1587 	
1588 	      // XXX GLIBCXX_ABI Deprecated
1589 	#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
1590 	      && _GLIBCXX_USE_CXX11_ABI == 0
1591 	      virtual iter_type
1592 	      do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1593 		     ios_base::iostate& __err, long double& __units) const;
1594 	#endif
1595 	
1596 	      template<bool _Intl>
1597 	        iter_type
1598 	        _M_extract(iter_type __s, iter_type __end, ios_base& __io,
1599 			   ios_base::iostate& __err, string& __digits) const;     
1600 	    };
1601 	
1602 	  template<typename _CharT, typename _InIter>
1603 	    locale::id money_get<_CharT, _InIter>::id;
1604 	
1605 	  /**
1606 	   *  @brief  Primary class template money_put.
1607 	   *  @ingroup locales
1608 	   *
1609 	   *  This facet encapsulates the code to format and output a monetary
1610 	   *  amount.
1611 	   *
1612 	   *  The money_put template uses protected virtual functions to
1613 	   *  provide the actual results.  The public accessors forward the
1614 	   *  call to the virtual functions.  These virtual functions are
1615 	   *  hooks for developers to implement the behavior they require from
1616 	   *  the money_put facet.
1617 	  */
1618 	  template<typename _CharT, typename _OutIter>
1619 	    class money_put : public locale::facet
1620 	    {
1621 	    public:
1622 	      //@{
1623 	      /// Public typedefs
1624 	      typedef _CharT			char_type;
1625 	      typedef _OutIter			iter_type;
1626 	      typedef basic_string<_CharT>	string_type;
1627 	      //@}
1628 	
1629 	      /// Numpunct facet id.
1630 	      static locale::id			id;
1631 	
1632 	      /**
1633 	       *  @brief  Constructor performs initialization.
1634 	       *
1635 	       *  This is the constructor provided by the standard.
1636 	       *
1637 	       *  @param __refs  Passed to the base facet class.
1638 	      */
1639 	      explicit
1640 	      money_put(size_t __refs = 0) : facet(__refs) { }
1641 	
1642 	      /**
1643 	       *  @brief  Format and output a monetary value.
1644 	       *
1645 	       *  This function formats @a units as a monetary value according to
1646 	       *  moneypunct and ctype facets retrieved from io.getloc(), and writes
1647 	       *  the resulting characters to @a __s.  For example, the value 1001 in a
1648 	       *  US locale would write <code>$10.01</code> to @a __s.
1649 	       *
1650 	       *  This function works by returning the result of do_put().
1651 	       *
1652 	       *  @param  __s  The stream to write to.
1653 	       *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1654 	       *  @param  __io  Source of facets and io state.
1655 	       *  @param  __fill  char_type to use for padding.
1656 	       *  @param  __units  Place to store result of parsing.
1657 	       *  @return  Iterator after writing.
1658 	       */
1659 	      iter_type
1660 	      put(iter_type __s, bool __intl, ios_base& __io,
1661 		  char_type __fill, long double __units) const
1662 	      { return this->do_put(__s, __intl, __io, __fill, __units); }
1663 	
1664 	      /**
1665 	       *  @brief  Format and output a monetary value.
1666 	       *
1667 	       *  This function formats @a digits as a monetary value
1668 	       *  according to moneypunct and ctype facets retrieved from
1669 	       *  io.getloc(), and writes the resulting characters to @a __s.
1670 	       *  For example, the string <code>1001</code> in a US locale
1671 	       *  would write <code>$10.01</code> to @a __s.
1672 	       *
1673 	       *  This function works by returning the result of do_put().
1674 	       *
1675 	       *  @param  __s  The stream to write to.
1676 	       *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1677 	       *  @param  __io  Source of facets and io state.
1678 	       *  @param  __fill  char_type to use for padding.
1679 	       *  @param  __digits  Place to store result of parsing.
1680 	       *  @return  Iterator after writing.
1681 	       */
1682 	      iter_type
1683 	      put(iter_type __s, bool __intl, ios_base& __io,
1684 		  char_type __fill, const string_type& __digits) const
1685 	      { return this->do_put(__s, __intl, __io, __fill, __digits); }
1686 	
1687 	    protected:
1688 	      /// Destructor.
1689 	      virtual
1690 	      ~money_put() { }
1691 	
1692 	      /**
1693 	       *  @brief  Format and output a monetary value.
1694 	       *
1695 	       *  This function formats @a units as a monetary value according to
1696 	       *  moneypunct and ctype facets retrieved from io.getloc(), and writes
1697 	       *  the resulting characters to @a __s.  For example, the value 1001 in a
1698 	       *  US locale would write <code>$10.01</code> to @a __s.
1699 	       *
1700 	       *  This function is a hook for derived classes to change the value
1701 	       *  returned.  @see put().
1702 	       *
1703 	       *  @param  __s  The stream to write to.
1704 	       *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1705 	       *  @param  __io  Source of facets and io state.
1706 	       *  @param  __fill  char_type to use for padding.
1707 	       *  @param  __units  Place to store result of parsing.
1708 	       *  @return  Iterator after writing.
1709 	       */
1710 	      // XXX GLIBCXX_ABI Deprecated
1711 	#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
1712 	      && _GLIBCXX_USE_CXX11_ABI == 0
1713 	      virtual iter_type
1714 	      __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1715 		       double __units) const;
1716 	#else
1717 	      virtual iter_type
1718 	      do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1719 		     long double __units) const;
1720 	#endif
1721 	
1722 	      /**
1723 	       *  @brief  Format and output a monetary value.
1724 	       *
1725 	       *  This function formats @a digits as a monetary value
1726 	       *  according to moneypunct and ctype facets retrieved from
1727 	       *  io.getloc(), and writes the resulting characters to @a __s.
1728 	       *  For example, the string <code>1001</code> in a US locale
1729 	       *  would write <code>$10.01</code> to @a __s.
1730 	       *
1731 	       *  This function is a hook for derived classes to change the value
1732 	       *  returned.  @see put().
1733 	       *
1734 	       *  @param  __s  The stream to write to.
1735 	       *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1736 	       *  @param  __io  Source of facets and io state.
1737 	       *  @param  __fill  char_type to use for padding.
1738 	       *  @param  __digits  Place to store result of parsing.
1739 	       *  @return  Iterator after writing.
1740 	       */
1741 	      virtual iter_type
1742 	      do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1743 		     const string_type& __digits) const;
1744 	
1745 	      // XXX GLIBCXX_ABI Deprecated
1746 	#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
1747 	      && _GLIBCXX_USE_CXX11_ABI == 0
1748 	      virtual iter_type
1749 	      do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1750 		     long double __units) const;
1751 	#endif
1752 	
1753 	      template<bool _Intl>
1754 	        iter_type
1755 	        _M_insert(iter_type __s, ios_base& __io, char_type __fill,
1756 			  const string_type& __digits) const;
1757 	    };
1758 	
1759 	  template<typename _CharT, typename _OutIter>
1760 	    locale::id money_put<_CharT, _OutIter>::id;
1761 	
1762 	_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
1763 	
1764 	  /**
1765 	   *  @brief  Messages facet base class providing catalog typedef.
1766 	   *  @ingroup locales
1767 	   */
1768 	  struct messages_base
1769 	  {
1770 	    typedef int catalog;
1771 	  };
1772 	
1773 	_GLIBCXX_BEGIN_NAMESPACE_CXX11
1774 	
1775 	  /**
1776 	   *  @brief  Primary class template messages.
1777 	   *  @ingroup locales
1778 	   *
1779 	   *  This facet encapsulates the code to retrieve messages from
1780 	   *  message catalogs.  The only thing defined by the standard for this facet
1781 	   *  is the interface.  All underlying functionality is
1782 	   *  implementation-defined.
1783 	   *
1784 	   *  This library currently implements 3 versions of the message facet.  The
1785 	   *  first version (gnu) is a wrapper around gettext, provided by libintl.
1786 	   *  The second version (ieee) is a wrapper around catgets.  The final
1787 	   *  version (default) does no actual translation.  These implementations are
1788 	   *  only provided for char and wchar_t instantiations.
1789 	   *
1790 	   *  The messages template uses protected virtual functions to
1791 	   *  provide the actual results.  The public accessors forward the
1792 	   *  call to the virtual functions.  These virtual functions are
1793 	   *  hooks for developers to implement the behavior they require from
1794 	   *  the messages facet.
1795 	  */
1796 	  template<typename _CharT>
1797 	    class messages : public locale::facet, public messages_base
1798 	    {
1799 	    public:
1800 	      // Types:
1801 	      //@{
1802 	      /// Public typedefs
1803 	      typedef _CharT			char_type;
1804 	      typedef basic_string<_CharT>	string_type;
1805 	      //@}
1806 	
1807 	    protected:
1808 	      // Underlying "C" library locale information saved from
1809 	      // initialization, needed by messages_byname as well.
1810 	      __c_locale			_M_c_locale_messages;
1811 	      const char*			_M_name_messages;
1812 	
1813 	    public:
1814 	      /// Numpunct facet id.
1815 	      static locale::id			id;
1816 	
1817 	      /**
1818 	       *  @brief  Constructor performs initialization.
1819 	       *
1820 	       *  This is the constructor provided by the standard.
1821 	       *
1822 	       *  @param __refs  Passed to the base facet class.
1823 	      */
1824 	      explicit
1825 	      messages(size_t __refs = 0);
1826 	
1827 	      // Non-standard.
1828 	      /**
1829 	       *  @brief  Internal constructor.  Not for general use.
1830 	       *
1831 	       *  This is a constructor for use by the library itself to set up new
1832 	       *  locales.
1833 	       *
1834 	       *  @param  __cloc  The C locale.
1835 	       *  @param  __s  The name of a locale.
1836 	       *  @param  __refs  Refcount to pass to the base class.
1837 	       */
1838 	      explicit
1839 	      messages(__c_locale __cloc, const char* __s, size_t __refs = 0);
1840 	
1841 	      /*
1842 	       *  @brief  Open a message catalog.
1843 	       *
1844 	       *  This function opens and returns a handle to a message catalog by
1845 	       *  returning do_open(__s, __loc).
1846 	       *
1847 	       *  @param  __s  The catalog to open.
1848 	       *  @param  __loc  Locale to use for character set conversions.
1849 	       *  @return  Handle to the catalog or value < 0 if open fails.
1850 	      */
1851 	      catalog
1852 	      open(const basic_string<char>& __s, const locale& __loc) const
1853 	      { return this->do_open(__s, __loc); }
1854 	
1855 	      // Non-standard and unorthodox, yet effective.
1856 	      /*
1857 	       *  @brief  Open a message catalog.
1858 	       *
1859 	       *  This non-standard function opens and returns a handle to a message
1860 	       *  catalog by returning do_open(s, loc).  The third argument provides a
1861 	       *  message catalog root directory for gnu gettext and is ignored
1862 	       *  otherwise.
1863 	       *
1864 	       *  @param  __s  The catalog to open.
1865 	       *  @param  __loc  Locale to use for character set conversions.
1866 	       *  @param  __dir  Message catalog root directory.
1867 	       *  @return  Handle to the catalog or value < 0 if open fails.
1868 	      */
1869 	      catalog
1870 	      open(const basic_string<char>&, const locale&, const char*) const;
1871 	
1872 	      /*
1873 	       *  @brief  Look up a string in a message catalog.
1874 	       *
1875 	       *  This function retrieves and returns a message from a catalog by
1876 	       *  returning do_get(c, set, msgid, s).
1877 	       *
1878 	       *  For gnu, @a __set and @a msgid are ignored.  Returns gettext(s).
1879 	       *  For default, returns s. For ieee, returns catgets(c,set,msgid,s).
1880 	       *
1881 	       *  @param  __c  The catalog to access.
1882 	       *  @param  __set  Implementation-defined.
1883 	       *  @param  __msgid  Implementation-defined.
1884 	       *  @param  __s  Default return value if retrieval fails.
1885 	       *  @return  Retrieved message or @a __s if get fails.
1886 	      */
1887 	      string_type
1888 	      get(catalog __c, int __set, int __msgid, const string_type& __s) const
1889 	      { return this->do_get(__c, __set, __msgid, __s); }
1890 	
1891 	      /*
1892 	       *  @brief  Close a message catalog.
1893 	       *
1894 	       *  Closes catalog @a c by calling do_close(c).
1895 	       *
1896 	       *  @param  __c  The catalog to close.
1897 	      */
1898 	      void
1899 	      close(catalog __c) const
1900 	      { return this->do_close(__c); }
1901 	
1902 	    protected:
1903 	      /// Destructor.
1904 	      virtual
1905 	      ~messages();
1906 	
1907 	      /*
1908 	       *  @brief  Open a message catalog.
1909 	       *
1910 	       *  This function opens and returns a handle to a message catalog in an
1911 	       *  implementation-defined manner.  This function is a hook for derived
1912 	       *  classes to change the value returned.
1913 	       *
1914 	       *  @param  __s  The catalog to open.
1915 	       *  @param  __loc  Locale to use for character set conversions.
1916 	       *  @return  Handle to the opened catalog, value < 0 if open failed.
1917 	      */
1918 	      virtual catalog
1919 	      do_open(const basic_string<char>&, const locale&) const;
1920 	
1921 	      /*
1922 	       *  @brief  Look up a string in a message catalog.
1923 	       *
1924 	       *  This function retrieves and returns a message from a catalog in an
1925 	       *  implementation-defined manner.  This function is a hook for derived
1926 	       *  classes to change the value returned.
1927 	       *
1928 	       *  For gnu, @a __set and @a __msgid are ignored.  Returns gettext(s).
1929 	       *  For default, returns s. For ieee, returns catgets(c,set,msgid,s).
1930 	       *
1931 	       *  @param  __c  The catalog to access.
1932 	       *  @param  __set  Implementation-defined.
1933 	       *  @param  __msgid  Implementation-defined.
1934 	       *  @param  __s  Default return value if retrieval fails.
1935 	       *  @return  Retrieved message or @a __s if get fails.
1936 	      */
1937 	      virtual string_type
1938 	      do_get(catalog, int, int, const string_type& __dfault) const;
1939 	
1940 	      /*
1941 	       *  @brief  Close a message catalog.
1942 	       *
1943 	       *  @param  __c  The catalog to close.
1944 	      */
1945 	      virtual void
1946 	      do_close(catalog) const;
1947 	
1948 	      // Returns a locale and codeset-converted string, given a char* message.
1949 	      char*
1950 	      _M_convert_to_char(const string_type& __msg) const
1951 	      {
1952 		// XXX
1953 		return reinterpret_cast<char*>(const_cast<_CharT*>(__msg.c_str()));
1954 	      }
1955 	
1956 	      // Returns a locale and codeset-converted string, given a char* message.
1957 	      string_type
1958 	      _M_convert_from_char(char*) const
1959 	      {
1960 		// XXX
1961 		return string_type();
1962 	      }
1963 	     };
1964 	
1965 	  template<typename _CharT>
1966 	    locale::id messages<_CharT>::id;
1967 	
1968 	  /// Specializations for required instantiations.
1969 	  template<>
1970 	    string
1971 	    messages<char>::do_get(catalog, int, int, const string&) const;
1972 	
1973 	#ifdef _GLIBCXX_USE_WCHAR_T
1974 	  template<>
1975 	    wstring
1976 	    messages<wchar_t>::do_get(catalog, int, int, const wstring&) const;
1977 	#endif
1978 	
1979 	   /// class messages_byname [22.2.7.2].
1980 	   template<typename _CharT>
1981 	    class messages_byname : public messages<_CharT>
1982 	    {
1983 	    public:
1984 	      typedef _CharT			char_type;
1985 	      typedef basic_string<_CharT>	string_type;
1986 	
1987 	      explicit
1988 	      messages_byname(const char* __s, size_t __refs = 0);
1989 	
1990 	#if __cplusplus >= 201103L
1991 	      explicit
1992 	      messages_byname(const string& __s, size_t __refs = 0)
1993 	      : messages_byname(__s.c_str(), __refs) { }
1994 	#endif
1995 	
1996 	    protected:
1997 	      virtual
1998 	      ~messages_byname()
1999 	      { }
2000 	    };
2001 	
2002 	_GLIBCXX_END_NAMESPACE_CXX11
2003 	
2004 	_GLIBCXX_END_NAMESPACE_VERSION
2005 	} // namespace
2006 	
2007 	// Include host and configuration specific messages functions.
2008 	#include <bits/messages_members.h>
2009 	
2010 	// 22.2.1.5  Template class codecvt
2011 	#include <bits/codecvt.h>
2012 	
2013 	#include <bits/locale_facets_nonio.tcc>
2014 	
2015 	#endif
2016