5#if !defined(__XTD_CORE_INTERNAL__)
6#error "Do not include this file: Internal use only"
14template<
typename enum_t>
15std::string __enum_to_string(enum_t value)
noexcept;
17template<
typename char_t,
typename value_t>
18inline std::basic_string<char_t> __enum_formatter(
const std::basic_string<char_t>& format, value_t value,
const std::locale& loc) {
20 if (fmt.empty()) fmt = {
'G'};
30 case 'X':
return __numeric_formatter(fmt,
static_cast<long long int>(value), loc);
32 case 'G':
return __enum_to_string(value);
33 default: __format_exception(
"Invalid format expression");
return {};
37template<
typename value_t>
38static std::string __to_string_enum(
const value_t& value,
const std::string& fmt,
const std::locale& loc, std::true_type) {
return __enum_formatter(fmt, value, loc);}
40template<
typename value_t>
41static std::string __to_string_enum(
const value_t& value,
const std::string& fmt,
const std::locale& loc, std::false_type) {
42 __format_exception(
typeid(value));
return {};
45template<
typename value_t>
46static std::wstring __to_string_enum(
const value_t& value,
const std::wstring& fmt,
const std::locale& loc, std::true_type) {
return __enum_formatter(fmt, value, loc);}
48template<
typename value_t>
49static std::wstring __to_string_enum(
const value_t& value,
const std::wstring& fmt,
const std::locale& loc, std::false_type) {
50 __format_exception(
typeid(value));
return {};