13#pragma GCC diagnostic push
14#pragma GCC diagnostic ignored "-Wexit-time-destructors"
20 using locale_t = _locale_t;
22 inline locale_t create_locale(_In_
int category, _In_z_
const char* locale) {
return _create_locale(category, locale); }
23 inline locale_t create_locale(_In_
int category, _In_z_
const wchar_t* locale) {
return _wcreate_locale(category, locale); }
24 inline void free_locale(_In_opt_ locale_t locale) { _free_locale(locale); }
26 using locale_t = ::locale_t;
28 inline locale_t create_locale(_In_
int category, _In_z_
const char* locale)
32 case LC_ALL : mask = LC_ALL_MASK ;
break;
33 case LC_COLLATE : mask = LC_COLLATE_MASK ;
break;
34 case LC_CTYPE : mask = LC_CTYPE_MASK ;
break;
35 case LC_MESSAGES: mask = LC_MESSAGES_MASK;
break;
36 case LC_MONETARY: mask = LC_MONETARY_MASK;
break;
37 case LC_NUMERIC : mask = LC_NUMERIC_MASK ;
break;
38 case LC_TIME : mask = LC_TIME_MASK ;
break;
40 return newlocale(mask, locale, LC_GLOBAL_LOCALE);
43 inline void free_locale(_In_opt_ locale_t locale) { freelocale(locale); }
62 using _locale_t_ref = __crt_locale_pointers;
63#elif defined(__APPLE__)
64 using _locale_t_ref =
struct _xlocale;
66 using _locale_t_ref =
struct __locale_struct;
73 class locale :
public std::unique_ptr<_locale_t_ref, free_locale_delete>
78 locale(_In_ locale_t ptr) :
79 std::unique_ptr<_locale_t_ref, free_locale_delete>(ptr)
87 locale(_In_
int category, _In_z_
const wchar_t*
locale) :
92 operator locale_t()
const {
return get(); }
98 const inline locale locale_C(create_locale(LC_ALL,
"C"));
103 const inline locale locale_utf8(create_locale(LC_ALL,
".UTF-8"));
108 inline locale locale_default(
nullptr);
112#pragma GCC diagnostic pop
locale_t helper class to free_locale when going out of scope.
Definition locale.hpp:74
Deleter for unique_ptr using free_locale.
Definition locale.hpp:50
void operator()(locale_t locale) const
Delete a pointer.
Definition locale.hpp:54