|
|
|
@ -45,6 +45,11 @@ class FormatConversionSpec; |
|
|
|
|
|
|
|
|
|
namespace str_format_internal { |
|
|
|
|
|
|
|
|
|
template <FormatConversionCharSet C> |
|
|
|
|
struct ArgConvertResult { |
|
|
|
|
bool value; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, typename = void> |
|
|
|
|
struct HasUserDefinedConvert : std::false_type {}; |
|
|
|
|
|
|
|
|
@ -71,6 +76,20 @@ auto FormatConvertImpl(const T& v, FormatConversionSpecImpl conv, |
|
|
|
|
return AbslFormatConvert(v, fcs, &fs); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbslStringify(); // Stops the lexical name lookup
|
|
|
|
|
template <typename T> |
|
|
|
|
auto FormatConvertImpl(const T& v, FormatConversionSpecImpl, |
|
|
|
|
FormatSinkImpl* sink) |
|
|
|
|
-> std::enable_if_t<std::is_void<decltype(AbslStringify( |
|
|
|
|
std::declval<FormatSink&>(), v))>::value, |
|
|
|
|
ArgConvertResult<FormatConversionCharSetInternal::v>> { |
|
|
|
|
using FormatSinkT = |
|
|
|
|
absl::enable_if_t<sizeof(const T& (*)()) != 0, FormatSink>; |
|
|
|
|
auto fs = sink->Wrap<FormatSinkT>(); |
|
|
|
|
AbslStringify(fs, v); |
|
|
|
|
return {true}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <typename T> |
|
|
|
|
class StreamedWrapper; |
|
|
|
|
|
|
|
|
@ -95,11 +114,6 @@ struct VoidPtr { |
|
|
|
|
uintptr_t value; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <FormatConversionCharSet C> |
|
|
|
|
struct ArgConvertResult { |
|
|
|
|
bool value; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <FormatConversionCharSet C> |
|
|
|
|
constexpr FormatConversionCharSet ExtractCharSet(FormatConvertResult<C>) { |
|
|
|
|
return C; |
|
|
|
@ -316,11 +330,11 @@ struct FormatArgImplFriend { |
|
|
|
|
|
|
|
|
|
template <typename Arg> |
|
|
|
|
constexpr FormatConversionCharSet ArgumentToConv() { |
|
|
|
|
return absl::str_format_internal::ExtractCharSet( |
|
|
|
|
decltype(str_format_internal::FormatConvertImpl( |
|
|
|
|
std::declval<const Arg&>(), |
|
|
|
|
std::declval<const FormatConversionSpecImpl&>(), |
|
|
|
|
std::declval<FormatSinkImpl*>())){}); |
|
|
|
|
using ConvResult = decltype(str_format_internal::FormatConvertImpl( |
|
|
|
|
std::declval<const Arg&>(), |
|
|
|
|
std::declval<const FormatConversionSpecImpl&>(), |
|
|
|
|
std::declval<FormatSinkImpl*>())); |
|
|
|
|
return absl::str_format_internal::ExtractCharSet(ConvResult{}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// A type-erased handle to a format argument.
|
|
|
|
|