OSDN Git Service

PR c++/28145
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / bits / locale_classes.h
1 // Locale support -*- C++ -*-
2
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 // 2006, 2007
5 // Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library.  This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 2, or (at your option)
11 // any later version.
12
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING.  If not, write to the Free
20 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // USA.
22
23 // As a special exception, you may use this file as part of a free software
24 // library without restriction.  Specifically, if other files instantiate
25 // templates or use macros or inline functions from this file, or you compile
26 // this file and link it with other files to produce an executable, this
27 // file does not by itself cause the resulting executable to be covered by
28 // the GNU General Public License.  This exception does not however
29 // invalidate any other reasons why the executable file might be covered by
30 // the GNU General Public License.
31
32 /** @file locale_classes.h
33  *  This is an internal header file, included by other library headers.
34  *  You should not attempt to use it directly.
35  */
36
37 //
38 // ISO C++ 14882: 22.1  Locales
39 //
40
41 #ifndef _LOCALE_CLASSES_H
42 #define _LOCALE_CLASSES_H 1
43
44 #pragma GCC system_header
45
46 #include <bits/localefwd.h>
47 #include <cstring>              // For strcmp.
48 #include <string>
49 #include <ext/atomicity.h>
50
51 _GLIBCXX_BEGIN_NAMESPACE(std)
52
53   // 22.1.1 Class locale
54   /**
55    *  @brief  Container class for localization functionality.
56    *
57    *  The locale class is first a class wrapper for C library locales.  It is
58    *  also an extensible container for user-defined localization.  A locale is
59    *  a collection of facets that implement various localization features such
60    *  as money, time, and number printing.
61    *
62    *  Constructing C++ locales does not change the C library locale.
63    *
64    *  This library supports efficient construction and copying of locales
65    *  through a reference counting implementation of the locale class.
66   */
67   class locale
68   {
69   public:
70     // Types:
71     /// Definition of locale::category.
72     typedef int category;
73
74     // Forward decls and friends:
75     class facet;
76     class id;
77     class _Impl;
78
79     friend class facet;
80     friend class _Impl;
81
82     template<typename _Facet>
83       friend bool
84       has_facet(const locale&) throw();
85
86     template<typename _Facet>
87       friend const _Facet&
88       use_facet(const locale&);
89
90     template<typename _Cache>
91       friend struct __use_cache;
92
93     //@{
94     /**
95      *  @brief  Category values.
96      *
97      *  The standard category values are none, ctype, numeric, collate, time,
98      *  monetary, and messages.  They form a bitmask that supports union and
99      *  intersection.  The category all is the union of these values.
100      *
101      *  @if maint
102      *  NB: Order must match _S_facet_categories definition in locale.cc
103      *  @endif
104     */
105     static const category none          = 0;
106     static const category ctype         = 1L << 0;
107     static const category numeric       = 1L << 1;
108     static const category collate       = 1L << 2;
109     static const category time          = 1L << 3;
110     static const category monetary      = 1L << 4;
111     static const category messages      = 1L << 5;
112     static const category all           = (ctype | numeric | collate |
113                                            time  | monetary | messages);
114     //@}
115
116     // Construct/copy/destroy:
117
118     /**
119      *  @brief  Default constructor.
120      *
121      *  Constructs a copy of the global locale.  If no locale has been
122      *  explicitly set, this is the "C" locale.
123     */
124     locale() throw();
125
126     /**
127      *  @brief  Copy constructor.
128      *
129      *  Constructs a copy of @a other.
130      *
131      *  @param  other  The locale to copy.
132     */
133     locale(const locale& __other) throw();
134
135     /**
136      *  @brief  Named locale constructor.
137      *
138      *  Constructs a copy of the named C library locale.
139      *
140      *  @param  s  Name of the locale to construct.
141      *  @throw  std::runtime_error if s is null or an undefined locale.
142     */
143     explicit
144     locale(const char* __s);
145
146     /**
147      *  @brief  Construct locale with facets from another locale.
148      *
149      *  Constructs a copy of the locale @a base.  The facets specified by @a
150      *  cat are replaced with those from the locale named by @a s.  If base is
151      *  named, this locale instance will also be named.
152      *
153      *  @param  base  The locale to copy.
154      *  @param  s  Name of the locale to use facets from.
155      *  @param  cat  Set of categories defining the facets to use from s.
156      *  @throw  std::runtime_error if s is null or an undefined locale.
157     */
158     locale(const locale& __base, const char* __s, category __cat);
159
160     /**
161      *  @brief  Construct locale with facets from another locale.
162      *
163      *  Constructs a copy of the locale @a base.  The facets specified by @a
164      *  cat are replaced with those from the locale @a add.  If @a base and @a
165      *  add are named, this locale instance will also be named.
166      *
167      *  @param  base  The locale to copy.
168      *  @param  add  The locale to use facets from.
169      *  @param  cat  Set of categories defining the facets to use from add.
170     */
171     locale(const locale& __base, const locale& __add, category __cat);
172
173     /**
174      *  @brief  Construct locale with another facet.
175      *
176      *  Constructs a copy of the locale @a other.  The facet @f is added to
177      *  @other, replacing an existing facet of type Facet if there is one.  If
178      *  @f is null, this locale is a copy of @a other.
179      *
180      *  @param  other  The locale to copy.
181      *  @param  f  The facet to add in.
182     */
183     template<typename _Facet>
184       locale(const locale& __other, _Facet* __f);
185
186     /// Locale destructor.
187     ~locale() throw();
188
189     /**
190      *  @brief  Assignment operator.
191      *
192      *  Set this locale to be a copy of @a other.
193      *
194      *  @param  other  The locale to copy.
195      *  @return  A reference to this locale.
196     */
197     const locale&
198     operator=(const locale& __other) throw();
199
200     /**
201      *  @brief  Construct locale with another facet.
202      *
203      *  Constructs and returns a new copy of this locale.  Adds or replaces an
204      *  existing facet of type Facet from the locale @a other into the new
205      *  locale.
206      *
207      *  @param  Facet  The facet type to copy from other
208      *  @param  other  The locale to copy from.
209      *  @return  Newly constructed locale.
210      *  @throw  std::runtime_error if other has no facet of type Facet.
211     */
212     template<typename _Facet>
213       locale
214       combine(const locale& __other) const;
215
216     // Locale operations:
217     /**
218      *  @brief  Return locale name.
219      *  @return  Locale name or "*" if unnamed.
220     */
221     string
222     name() const;
223
224     /**
225      *  @brief  Locale equality.
226      *
227      *  @param  other  The locale to compare against.
228      *  @return  True if other and this refer to the same locale instance, are
229      *           copies, or have the same name.  False otherwise.
230     */
231     bool
232     operator==(const locale& __other) const throw ();
233
234     /**
235      *  @brief  Locale inequality.
236      *
237      *  @param  other  The locale to compare against.
238      *  @return  ! (*this == other)
239     */
240     bool
241     operator!=(const locale& __other) const throw ()
242     { return !(this->operator==(__other)); }
243
244     /**
245      *  @brief  Compare two strings according to collate.
246      *
247      *  Template operator to compare two strings using the compare function of
248      *  the collate facet in this locale.  One use is to provide the locale to
249      *  the sort function.  For example, a vector v of strings could be sorted
250      *  according to locale loc by doing:
251      *  @code
252      *  std::sort(v.begin(), v.end(), loc);
253      *  @endcode
254      *
255      *  @param  s1  First string to compare.
256      *  @param  s2  Second string to compare.
257      *  @return  True if collate<Char> facet compares s1 < s2, else false.
258     */
259     template<typename _Char, typename _Traits, typename _Alloc>
260       bool
261       operator()(const basic_string<_Char, _Traits, _Alloc>& __s1,
262                  const basic_string<_Char, _Traits, _Alloc>& __s2) const;
263
264     // Global locale objects:
265     /**
266      *  @brief  Set global locale
267      *
268      *  This function sets the global locale to the argument and returns a
269      *  copy of the previous global locale.  If the argument has a name, it
270      *  will also call std::setlocale(LC_ALL, loc.name()).
271      *
272      *  @param  locale  The new locale to make global.
273      *  @return  Copy of the old global locale.
274     */
275     static locale
276     global(const locale&);
277
278     /**
279      *  @brief  Return reference to the "C" locale.
280     */
281     static const locale&
282     classic();
283
284   private:
285     // The (shared) implementation
286     _Impl*              _M_impl;
287
288     // The "C" reference locale
289     static _Impl*       _S_classic;
290
291     // Current global locale
292     static _Impl*       _S_global;
293
294     // Names of underlying locale categories.
295     // NB: locale::global() has to know how to modify all the
296     // underlying categories, not just the ones required by the C++
297     // standard.
298     static const char* const* const _S_categories;
299
300     // Number of standard categories. For C++, these categories are
301     // collate, ctype, monetary, numeric, time, and messages. These
302     // directly correspond to ISO C99 macros LC_COLLATE, LC_CTYPE,
303     // LC_MONETARY, LC_NUMERIC, and LC_TIME. In addition, POSIX (IEEE
304     // 1003.1-2001) specifies LC_MESSAGES.
305     // In addition to the standard categories, the underlying
306     // operating system is allowed to define extra LC_*
307     // macros. For GNU systems, the following are also valid:
308     // LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT,
309     // and LC_IDENTIFICATION.
310     enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
311
312 #ifdef __GTHREADS
313     static __gthread_once_t _S_once;
314 #endif
315
316     explicit
317     locale(_Impl*) throw();
318
319     static void
320     _S_initialize();
321
322     static void
323     _S_initialize_once();
324
325     static category
326     _S_normalize_category(category);
327
328     void
329     _M_coalesce(const locale& __base, const locale& __add, category __cat);
330   };
331
332
333   // 22.1.1.1.2  Class locale::facet
334   /**
335    *  @brief  Localization functionality base class.
336    *
337    *  The facet class is the base class for a localization feature, such as
338    *  money, time, and number printing.  It provides common support for facets
339    *  and reference management.
340    *
341    *  Facets may not be copied or assigned.
342   */
343   class locale::facet
344   {
345   private:
346     friend class locale;
347     friend class locale::_Impl;
348
349     mutable _Atomic_word                _M_refcount;
350
351     // Contains data from the underlying "C" library for the classic locale.
352     static __c_locale                   _S_c_locale;
353
354     // String literal for the name of the classic locale.
355     static const char                   _S_c_name[2];
356
357 #ifdef __GTHREADS
358     static __gthread_once_t             _S_once;
359 #endif
360
361     static void
362     _S_initialize_once();
363
364   protected:
365     /**
366      *  @brief  Facet constructor.
367      *
368      *  This is the constructor provided by the standard.  If refs is 0, the
369      *  facet is destroyed when the last referencing locale is destroyed.
370      *  Otherwise the facet will never be destroyed.
371      *
372      *  @param refs  The initial value for reference count.
373     */
374     explicit
375     facet(size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
376     { }
377
378     /// Facet destructor.
379     virtual
380     ~facet();
381
382     static void
383     _S_create_c_locale(__c_locale& __cloc, const char* __s,
384                        __c_locale __old = 0);
385
386     static __c_locale
387     _S_clone_c_locale(__c_locale& __cloc);
388
389     static void
390     _S_destroy_c_locale(__c_locale& __cloc);
391
392     // Returns data from the underlying "C" library data for the
393     // classic locale.
394     static __c_locale
395     _S_get_c_locale();
396
397     static const char*
398     _S_get_c_name();
399
400   private:
401     void
402     _M_add_reference() const throw()
403     { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
404
405     void
406     _M_remove_reference() const throw()
407     {
408       if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
409         {
410           try
411             { delete this; }
412           catch(...)
413             { }
414         }
415     }
416
417     facet(const facet&);  // Not defined.
418
419     facet&
420     operator=(const facet&);  // Not defined.
421   };
422
423
424   // 22.1.1.1.3 Class locale::id
425   /**
426    *  @brief  Facet ID class.
427    *
428    *  The ID class provides facets with an index used to identify them.
429    *  Every facet class must define a public static member locale::id, or be
430    *  derived from a facet that provides this member, otherwise the facet
431    *  cannot be used in a locale.  The locale::id ensures that each class
432    *  type gets a unique identifier.
433   */
434   class locale::id
435   {
436   private:
437     friend class locale;
438     friend class locale::_Impl;
439
440     template<typename _Facet>
441       friend const _Facet&
442       use_facet(const locale&);
443
444     template<typename _Facet>
445       friend bool
446       has_facet(const locale&) throw ();
447
448     // NB: There is no accessor for _M_index because it may be used
449     // before the constructor is run; the effect of calling a member
450     // function (even an inline) would be undefined.
451     mutable size_t              _M_index;
452
453     // Last id number assigned.
454     static _Atomic_word         _S_refcount;
455
456     void
457     operator=(const id&);  // Not defined.
458
459     id(const id&);  // Not defined.
460
461   public:
462     // NB: This class is always a static data member, and thus can be
463     // counted on to be zero-initialized.
464     /// Constructor.
465     id() { }
466
467     size_t
468     _M_id() const;
469   };
470
471
472   // Implementation object for locale.
473   class locale::_Impl
474   {
475   public:
476     // Friends.
477     friend class locale;
478     friend class locale::facet;
479
480     template<typename _Facet>
481       friend bool
482       has_facet(const locale&) throw();
483
484     template<typename _Facet>
485       friend const _Facet&
486       use_facet(const locale&);
487
488     template<typename _Cache>
489       friend struct __use_cache;
490
491   private:
492     // Data Members.
493     _Atomic_word                        _M_refcount;
494     const facet**                       _M_facets;
495     size_t                              _M_facets_size;
496     const facet**                       _M_caches;
497     char**                              _M_names;
498     static const locale::id* const      _S_id_ctype[];
499     static const locale::id* const      _S_id_numeric[];
500     static const locale::id* const      _S_id_collate[];
501     static const locale::id* const      _S_id_time[];
502     static const locale::id* const      _S_id_monetary[];
503     static const locale::id* const      _S_id_messages[];
504     static const locale::id* const* const _S_facet_categories[];
505
506     void
507     _M_add_reference() throw()
508     { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
509
510     void
511     _M_remove_reference() throw()
512     {
513       if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
514         {
515           try
516             { delete this; }
517           catch(...)
518             { }
519         }
520     }
521
522     _Impl(const _Impl&, size_t);
523     _Impl(const char*, size_t);
524     _Impl(size_t) throw();
525
526    ~_Impl() throw();
527
528     _Impl(const _Impl&);  // Not defined.
529
530     void
531     operator=(const _Impl&);  // Not defined.
532
533     bool
534     _M_check_same_name()
535     {
536       bool __ret = true;
537       if (_M_names[1])
538         // We must actually compare all the _M_names: can be all equal!
539         for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
540           __ret = std::strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
541       return __ret;
542     }
543
544     void
545     _M_replace_categories(const _Impl*, category);
546
547     void
548     _M_replace_category(const _Impl*, const locale::id* const*);
549
550     void
551     _M_replace_facet(const _Impl*, const locale::id*);
552
553     void
554     _M_install_facet(const locale::id*, const facet*);
555
556     template<typename _Facet>
557       void
558       _M_init_facet(_Facet* __facet)
559       { _M_install_facet(&_Facet::id, __facet); }
560
561     void
562     _M_install_cache(const facet*, size_t);
563   };
564
565
566   /**
567    *  @brief  Test for the presence of a facet.
568    *
569    *  has_facet tests the locale argument for the presence of the facet type
570    *  provided as the template parameter.  Facets derived from the facet
571    *  parameter will also return true.
572    *
573    *  @param  Facet  The facet type to test the presence of.
574    *  @param  locale  The locale to test.
575    *  @return  true if locale contains a facet of type Facet, else false.
576   */
577   template<typename _Facet>
578     inline bool
579     has_facet(const locale& __loc) throw()
580     {
581       const size_t __i = _Facet::id._M_id();
582       const locale::facet** __facets = __loc._M_impl->_M_facets;
583       return (__i < __loc._M_impl->_M_facets_size && __facets[__i]);
584     }
585
586   /**
587    *  @brief  Return a facet.
588    *
589    *  use_facet looks for and returns a reference to a facet of type Facet
590    *  where Facet is the template parameter.  If has_facet(locale) is true,
591    *  there is a suitable facet to return.  It throws std::bad_cast if the
592    *  locale doesn't contain a facet of type Facet.
593    *
594    *  @param  Facet  The facet type to access.
595    *  @param  locale  The locale to use.
596    *  @return  Reference to facet of type Facet.
597    *  @throw  std::bad_cast if locale doesn't contain a facet of type Facet.
598   */
599   template<typename _Facet>
600     inline const _Facet&
601     use_facet(const locale& __loc)
602     {
603       const size_t __i = _Facet::id._M_id();
604       const locale::facet** __facets = __loc._M_impl->_M_facets;
605       if (!(__i < __loc._M_impl->_M_facets_size && __facets[__i]))
606         __throw_bad_cast();
607       return static_cast<const _Facet&>(*__facets[__i]);
608     }
609
610
611   /**
612    *  @brief  Facet for localized string comparison.
613    *
614    *  This facet encapsulates the code to compare strings in a localized
615    *  manner.
616    *
617    *  The collate template uses protected virtual functions to provide
618    *  the actual results.  The public accessors forward the call to
619    *  the virtual functions.  These virtual functions are hooks for
620    *  developers to implement the behavior they require from the
621    *  collate facet.
622   */
623   template<typename _CharT>
624     class collate : public locale::facet
625     {
626     public:
627       // Types:
628       //@{
629       /// Public typedefs
630       typedef _CharT                    char_type;
631       typedef basic_string<_CharT>      string_type;
632       //@}
633
634     protected:
635       // Underlying "C" library locale information saved from
636       // initialization, needed by collate_byname as well.
637       __c_locale                        _M_c_locale_collate;
638
639     public:
640       /// Numpunct facet id.
641       static locale::id                 id;
642
643       /**
644        *  @brief  Constructor performs initialization.
645        *
646        *  This is the constructor provided by the standard.
647        *
648        *  @param refs  Passed to the base facet class.
649       */
650       explicit
651       collate(size_t __refs = 0)
652       : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
653       { }
654
655       /**
656        *  @brief  Internal constructor. Not for general use.
657        *
658        *  This is a constructor for use by the library itself to set up new
659        *  locales.
660        *
661        *  @param cloc  The "C" locale.
662        *  @param refs  Passed to the base facet class.
663       */
664       explicit
665       collate(__c_locale __cloc, size_t __refs = 0)
666       : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
667       { }
668
669       /**
670        *  @brief  Compare two strings.
671        *
672        *  This function compares two strings and returns the result by calling
673        *  collate::do_compare().
674        *
675        *  @param lo1  Start of string 1.
676        *  @param hi1  End of string 1.
677        *  @param lo2  Start of string 2.
678        *  @param hi2  End of string 2.
679        *  @return  1 if string1 > string2, -1 if string1 < string2, else 0.
680       */
681       int
682       compare(const _CharT* __lo1, const _CharT* __hi1,
683               const _CharT* __lo2, const _CharT* __hi2) const
684       { return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
685
686       /**
687        *  @brief  Transform string to comparable form.
688        *
689        *  This function is a wrapper for strxfrm functionality.  It takes the
690        *  input string and returns a modified string that can be directly
691        *  compared to other transformed strings.  In the "C" locale, this
692        *  function just returns a copy of the input string.  In some other
693        *  locales, it may replace two chars with one, change a char for
694        *  another, etc.  It does so by returning collate::do_transform().
695        *
696        *  @param lo  Start of string.
697        *  @param hi  End of string.
698        *  @return  Transformed string_type.
699       */
700       string_type
701       transform(const _CharT* __lo, const _CharT* __hi) const
702       { return this->do_transform(__lo, __hi); }
703
704       /**
705        *  @brief  Return hash of a string.
706        *
707        *  This function computes and returns a hash on the input string.  It
708        *  does so by returning collate::do_hash().
709        *
710        *  @param lo  Start of string.
711        *  @param hi  End of string.
712        *  @return  Hash value.
713       */
714       long
715       hash(const _CharT* __lo, const _CharT* __hi) const
716       { return this->do_hash(__lo, __hi); }
717
718       // Used to abstract out _CharT bits in virtual member functions, below.
719       int
720       _M_compare(const _CharT*, const _CharT*) const;
721
722       size_t
723       _M_transform(_CharT*, const _CharT*, size_t) const;
724
725   protected:
726       /// Destructor.
727       virtual
728       ~collate()
729       { _S_destroy_c_locale(_M_c_locale_collate); }
730
731       /**
732        *  @brief  Compare two strings.
733        *
734        *  This function is a hook for derived classes to change the value
735        *  returned.  @see compare().
736        *
737        *  @param lo1  Start of string 1.
738        *  @param hi1  End of string 1.
739        *  @param lo2  Start of string 2.
740        *  @param hi2  End of string 2.
741        *  @return  1 if string1 > string2, -1 if string1 < string2, else 0.
742       */
743       virtual int
744       do_compare(const _CharT* __lo1, const _CharT* __hi1,
745                  const _CharT* __lo2, const _CharT* __hi2) const;
746
747       /**
748        *  @brief  Transform string to comparable form.
749        *
750        *  This function is a hook for derived classes to change the value
751        *  returned.
752        *
753        *  @param lo1  Start of string 1.
754        *  @param hi1  End of string 1.
755        *  @param lo2  Start of string 2.
756        *  @param hi2  End of string 2.
757        *  @return  1 if string1 > string2, -1 if string1 < string2, else 0.
758       */
759       virtual string_type
760       do_transform(const _CharT* __lo, const _CharT* __hi) const;
761
762       /**
763        *  @brief  Return hash of a string.
764        *
765        *  This function computes and returns a hash on the input string.  This
766        *  function is a hook for derived classes to change the value returned.
767        *
768        *  @param lo  Start of string.
769        *  @param hi  End of string.
770        *  @return  Hash value.
771       */
772       virtual long
773       do_hash(const _CharT* __lo, const _CharT* __hi) const;
774     };
775
776   template<typename _CharT>
777     locale::id collate<_CharT>::id;
778
779   // Specializations.
780   template<>
781     int
782     collate<char>::_M_compare(const char*, const char*) const;
783
784   template<>
785     size_t
786     collate<char>::_M_transform(char*, const char*, size_t) const;
787
788 #ifdef _GLIBCXX_USE_WCHAR_T
789   template<>
790     int
791     collate<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const;
792
793   template<>
794     size_t
795     collate<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const;
796 #endif
797
798   /// @brief  class collate_byname [22.2.4.2].
799   template<typename _CharT>
800     class collate_byname : public collate<_CharT>
801     {
802     public:
803       //@{
804       /// Public typedefs
805       typedef _CharT               char_type;
806       typedef basic_string<_CharT> string_type;
807       //@}
808
809       explicit
810       collate_byname(const char* __s, size_t __refs = 0)
811       : collate<_CharT>(__refs)
812       {
813         if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
814           {
815             this->_S_destroy_c_locale(this->_M_c_locale_collate);
816             this->_S_create_c_locale(this->_M_c_locale_collate, __s);
817           }
818       }
819
820     protected:
821       virtual
822       ~collate_byname() { }
823     };
824
825 _GLIBCXX_END_NAMESPACE
826
827 #ifndef _GLIBCXX_EXPORT_TEMPLATE
828 # include <bits/locale_classes.tcc>
829 #endif
830
831 #endif