34#ifndef _LOCALE_CLASSES_TCC
35#define _LOCALE_CLASSES_TCC 1
37#pragma GCC system_header
39namespace std _GLIBCXX_VISIBILITY(default)
41_GLIBCXX_BEGIN_NAMESPACE_VERSION
43 template<
typename _Facet>
47 _M_impl =
new _Impl(*__other._M_impl, 1);
50 { _M_impl->_M_install_facet(&_Facet::id, __f); }
53 _M_impl->_M_remove_reference();
54 __throw_exception_again;
56 delete [] _M_impl->_M_names[0];
57 _M_impl->_M_names[0] = 0;
60 template<
typename _Facet>
65 _Impl* __tmp =
new _Impl(*_M_impl, 1);
68 __tmp->_M_replace_facet(__other._M_impl, &_Facet::id);
72 __tmp->_M_remove_reference();
73 __throw_exception_again;
78 template<
typename _CharT,
typename _Traits,
typename _Alloc>
85 const __collate_type& __collate = use_facet<__collate_type>(*
this);
86 return (__collate.compare(__s1.
data(), __s1.
data() + __s1.
length(),
102 template<
typename _Facet>
106 if _GLIBCXX17_CONSTEXPR (__is_same(_Facet,
ctype<char>)
110#ifdef _GLIBCXX_USE_WCHAR_T
117 const size_t __i = _Facet::id._M_id();
119 return (__i < __loc._M_impl->_M_facets_size
121 &&
dynamic_cast<const _Facet*
>(__facets[__i]));
123 &&
static_cast<const _Facet*
>(__facets[__i]));
141 template<
typename _Facet>
145 const size_t __i = _Facet::id._M_id();
148 if _GLIBCXX17_CONSTEXPR (__is_same(_Facet,
ctype<char>)
151 return static_cast<const _Facet&
>(*__facets[__i]);
152#ifdef _GLIBCXX_USE_WCHAR_T
156 return static_cast<const _Facet&
>(*__facets[__i]);
159 if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i])
162 return dynamic_cast<const _Facet&
>(*__facets[__i]);
164 return static_cast<const _Facet&
>(*__facets[__i]);
170 template<
typename _CharT>
176 template<
typename _CharT>
178 collate<_CharT>::_M_transform(_CharT*,
const _CharT*,
size_t)
const throw ()
181 template<
typename _CharT>
184 do_compare(
const _CharT* __lo1,
const _CharT* __hi1,
185 const _CharT* __lo2,
const _CharT* __hi2)
const
192 const _CharT* __p = __one.
c_str();
193 const _CharT* __pend = __one.
data() + __one.
length();
194 const _CharT* __q = __two.
c_str();
195 const _CharT* __qend = __two.
data() + __two.
length();
202 const int __res = _M_compare(__p, __q);
208 if (__p == __pend && __q == __qend)
210 else if (__p == __pend)
212 else if (__q == __qend)
220 template<
typename _CharT>
223 do_transform(
const _CharT* __lo,
const _CharT* __hi)
const
230 const _CharT* __p = __str.
c_str();
231 const _CharT* __pend = __str.
data() + __str.
length();
233 size_t __len = (__hi - __lo) * 2;
235 _CharT* __c =
new _CharT[__len];
245 size_t __res = _M_transform(__c, __p, __len);
251 delete [] __c, __c = 0;
252 __c =
new _CharT[__len];
253 __res = _M_transform(__c, __p, __len);
268 __throw_exception_again;
276 template<
typename _CharT>
279 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const
281 unsigned long __val = 0;
282 for (; __lo < __hi; ++__lo)
284 *__lo + ((__val << 7)
285 | (__val >> (__gnu_cxx::__numeric_traits<unsigned long>::
287 return static_cast<long>(__val);
292#if _GLIBCXX_EXTERN_TEMPLATE
298 use_facet<collate<char> >(
const locale&);
302 has_facet<collate<char> >(
const locale&);
304#ifdef _GLIBCXX_USE_WCHAR_T
310 use_facet<collate<wchar_t> >(
const locale&);
314 has_facet<collate<wchar_t> >(
const locale&);
318_GLIBCXX_END_NAMESPACE_VERSION
bool has_facet(const locale &__loc)
Test for the presence of a facet.
const _Facet & use_facet(const locale &__loc)
Return a facet.
ISO C++ entities toplevel namespace is std.
Basis for explicit traits specializations.
Managing sequences of characters and character-like objects.
void push_back(_CharT __c)
Append a single character.
const _CharT * data() const noexcept
Return const pointer to contents.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & append(const basic_string &__str)
Append a string to this string.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
Container class for localization functionality.
locale combine(const locale &__other) const
Construct locale with another facet.
bool operator()(const basic_string< _Char, _Traits, _Alloc > &__s1, const basic_string< _Char, _Traits, _Alloc > &__s2) const
Compare two strings according to collate.
locale()
Default constructor.
Localization functionality base class.
Facet for localized string comparison.
virtual long do_hash(const _CharT *__lo, const _CharT *__hi) const
Return hash of a string.
virtual string_type do_transform(const _CharT *__lo, const _CharT *__hi) const
Transform string to comparable form.
virtual int do_compare(const _CharT *__lo1, const _CharT *__hi1, const _CharT *__lo2, const _CharT *__hi2) const
Compare two strings.
class collate_byname [22.2.4.2].
Primary class template ctype facet.
Primary class template num_get.
Primary class template num_put.