34 #ifndef _LOCALE_CLASSES_H
35 #define _LOCALE_CLASSES_H 1
37 #ifdef _GLIBCXX_SYSHDR
38 #pragma GCC system_header
46 #ifdef __glibcxx_text_encoding
50 namespace std _GLIBCXX_VISIBILITY(default)
52 _GLIBCXX_BEGIN_NAMESPACE_VERSION
84 template<
typename _Facet>
88 template<
typename _Facet>
92 template<
typename _Facet>
94 __try_use_facet(
const locale&) _GLIBCXX_NOTHROW;
96 template<
typename _Cache>
97 friend struct __use_cache;
164 #if __cplusplus >= 201103L
216 template<
typename _Facet>
231 operator=(const
locale& __other) throw();
245 template<typename _Facet>
255 _GLIBCXX_NODISCARD _GLIBCXX_DEFAULT_ABI_TAG
259 #ifdef __glibcxx_text_encoding
260 # if __CHAR_BIT__ == 8
265 encoding()
const =
delete;
280 #if __cpp_impl_three_way_comparison < 201907L
289 operator!=(
const locale& __other)
const throw()
308 template<
typename _Char,
typename _Traits,
typename _Alloc>
311 operator()(
const basic_string<_Char, _Traits, _Alloc>& __s1,
312 const basic_string<_Char, _Traits, _Alloc>& __s2)
const;
340 static _Impl* _S_classic;
343 static _Impl* _S_global;
349 static const char*
const*
const _S_categories;
361 enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
364 static __gthread_once_t _S_once;
374 _S_initialize_once() throw();
382 #if _GLIBCXX_USE_CXX11_ABI
383 static const id*
const _S_twinned_facets[];
387 #if __cpp_lib_type_trait_variable_templates // C++ >= 17
388 template<
typename _Tp>
389 constexpr
bool __is_facet = is_base_of_v<locale::facet, _Tp>;
390 template<
typename _Tp>
391 constexpr
bool __is_facet<volatile _Tp> =
false;
409 friend class locale::_Impl;
411 mutable _Atomic_word _M_refcount;
414 static __c_locale _S_c_locale;
417 static const char _S_c_name[2];
420 static __gthread_once_t _S_once;
424 _S_initialize_once();
437 facet(
size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
445 _S_create_c_locale(__c_locale& __cloc,
const char* __s,
446 __c_locale __old = 0);
449 _S_clone_c_locale(__c_locale& __cloc)
throw();
452 _S_destroy_c_locale(__c_locale& __cloc);
455 _S_lc_ctype_c_locale(__c_locale __cloc,
const char* __s);
462 _GLIBCXX_CONST
static const char*
463 _S_get_c_name() throw();
465 #if __cplusplus < 201103L
470 operator=(
const facet&);
475 operator=(
const facet&) =
delete;
480 _M_add_reference()
const throw()
481 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
484 _M_remove_reference()
const throw()
487 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
488 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
490 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
498 const facet* _M_sso_shim(
const id*)
const;
499 const facet* _M_cow_shim(
const id*)
const;
521 friend class locale::_Impl;
523 template<
typename _Facet>
527 template<
typename _Facet>
531 template<
typename _Facet>
533 __try_use_facet(
const locale&) _GLIBCXX_NOTHROW;
538 mutable size_t _M_index;
541 static _Atomic_word _S_refcount;
544 operator=(
const id&);
555 _M_id()
const throw();
567 template<
typename _Facet>
571 template<
typename _Facet>
575 template<
typename _Facet>
577 __try_use_facet(
const locale&) _GLIBCXX_NOTHROW;
579 template<
typename _Cache>
580 friend struct __use_cache;
584 _Atomic_word _M_refcount;
585 const facet** _M_facets;
586 size_t _M_facets_size;
587 const facet** _M_caches;
590 static const locale::id*
const _S_id_numeric[];
591 static const locale::id*
const _S_id_collate[];
593 static const locale::id*
const _S_id_monetary[];
594 static const locale::id*
const _S_id_messages[];
595 static const locale::id*
const*
const _S_facet_categories[];
598 _M_add_reference() throw()
599 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
602 _M_remove_reference() throw()
605 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
606 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
608 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
616 _Impl(
const _Impl&,
size_t);
617 _Impl(
const char*,
size_t);
618 _Impl(
size_t)
throw();
625 operator=(const _Impl&);
633 for (
size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
634 __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
639 _M_replace_categories(
const _Impl*,
category);
642 _M_replace_category(
const _Impl*,
const locale::id*
const*);
645 _M_replace_facet(
const _Impl*,
const locale::id*);
648 _M_install_facet(
const locale::id*,
const facet*);
650 template<
typename _Facet>
652 _M_init_facet(_Facet* __facet)
653 { _M_install_facet(&_Facet::id, __facet); }
655 template<
typename _Facet>
657 _M_init_facet_unchecked(_Facet* __facet)
659 __facet->_M_add_reference();
660 _M_facets[_Facet::id._M_id()] = __facet;
664 _M_install_cache(
const facet*,
size_t);
666 void _M_init_extra(facet**);
667 void _M_init_extra(
void*,
void*,
const char*,
const char*);
669 #ifdef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
670 void _M_init_extra_ldbl128(
bool);
687 template<
typename _CharT>
701 __c_locale _M_c_locale_collate;
716 : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
730 : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
746 compare(
const _CharT* __lo1,
const _CharT* __hi1,
747 const _CharT* __lo2,
const _CharT* __hi2)
const
748 {
return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
766 {
return this->do_transform(__lo, __hi); }
779 hash(
const _CharT* __lo,
const _CharT* __hi)
const
780 {
return this->do_hash(__lo, __hi); }
784 _M_compare(
const _CharT*,
const _CharT*)
const throw();
787 _M_transform(_CharT*,
const _CharT*,
size_t)
const throw();
793 { _S_destroy_c_locale(_M_c_locale_collate); }
808 do_compare(
const _CharT* __lo1,
const _CharT* __hi1,
809 const _CharT* __lo2,
const _CharT* __hi2)
const;
822 do_transform(
const _CharT* __lo,
const _CharT* __hi)
const;
835 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const;
838 template<
typename _CharT>
844 collate<char>::_M_compare(
const char*,
const char*)
const throw();
848 collate<char>::_M_transform(
char*,
const char*,
size_t)
const throw();
850 #ifdef _GLIBCXX_USE_WCHAR_T
853 collate<wchar_t>::_M_compare(
const wchar_t*,
const wchar_t*)
const throw();
857 collate<wchar_t>::_M_transform(
wchar_t*,
const wchar_t*,
size_t)
const throw();
861 template<
typename _CharT>
875 if (__builtin_strcmp(__s,
"C") != 0
876 && __builtin_strcmp(__s,
"POSIX") != 0)
878 this->_S_destroy_c_locale(this->_M_c_locale_collate);
879 this->_S_create_c_locale(this->_M_c_locale_collate, __s);
883 #if __cplusplus >= 201103L
891 ~collate_byname() { }
894 _GLIBCXX_END_NAMESPACE_VERSION