diff --git a/include/stdex/chrono.hpp b/include/stdex/chrono.hpp index 16f9c5886..257bdf1e3 100644 --- a/include/stdex/chrono.hpp +++ b/include/stdex/chrono.hpp @@ -390,7 +390,7 @@ namespace stdex { template, class _Ax = std::allocator> static std::basic_string to_rfc822(_In_ const time_point tp) { - return to_str(tp, "%a, %d %b %Y %H:%M:%S GMT", locale_C); + return to_str(tp, "%a, %d %b %Y %H:%M:%S GMT", locale_C.get()); } }; } diff --git a/include/stdex/string.hpp b/include/stdex/string.hpp index a8ecc0726..5d3b20fd9 100644 --- a/include/stdex/string.hpp +++ b/include/stdex/string.hpp @@ -8,14 +8,32 @@ #include "sal.hpp" #include #include +#include #include #include +#include #include namespace stdex { #ifdef _WIN32 using locale_t = _locale_t; + + /// + /// Deleter for unique_ptr using _free_locale + /// + struct free_locale_delete + { + /// + /// Delete a pointer + /// + void operator()(_In_ locale_t locale) const + { + _free_locale(locale); + } + }; + + static std::unique_ptr<__crt_locale_pointers, free_locale_delete> locale_C(_create_locale(LC_ALL, "C")); #else using locale_t = ::locale_t; #endif