Adapt any string-like type to be used by {fmt} just like the standard string types already supported. The adaption is totally non-intrusive.

Signed-off-by: Daniela Engert <dani@ngrt.de>
This commit is contained in:
Daniela Engert
2018-10-08 20:14:39 +02:00
committed by Victor Zverovich
parent 846c644e84
commit 2c81c851b2
6 changed files with 184 additions and 73 deletions

View File

@@ -606,7 +606,7 @@ inline FMT_ENABLE_IF_STRING(S, std::basic_string<FMT_CHAR(S)>)
typedef internal::basic_buffer<FMT_CHAR(S)> buffer;
typedef typename printf_context<buffer>::type context;
format_arg_store<context, Args...> as{ args... };
return vsprintf(internal::to_string_view(format_str),
return vsprintf(to_string_view(format_str),
basic_format_args<context>(as));
}
@@ -637,7 +637,7 @@ inline FMT_ENABLE_IF_STRING(S, int)
typedef internal::basic_buffer<FMT_CHAR(S)> buffer;
typedef typename printf_context<buffer>::type context;
format_arg_store<context, Args...> as{ args... };
return vfprintf(f, internal::to_string_view(format_str),
return vfprintf(f, to_string_view(format_str),
basic_format_args<context>(as));
}
@@ -664,7 +664,7 @@ inline FMT_ENABLE_IF_STRING(S, int)
typedef internal::basic_buffer<FMT_CHAR(S)> buffer;
typedef typename printf_context<buffer>::type context;
format_arg_store<context, Args...> as{ args... };
return vprintf(internal::to_string_view(format_str),
return vprintf(to_string_view(format_str),
basic_format_args<context>(as));
}
@@ -696,7 +696,7 @@ inline FMT_ENABLE_IF_STRING(S, int)
typedef internal::basic_buffer<FMT_CHAR(S)> buffer;
typedef typename printf_context<buffer>::type context;
format_arg_store<context, Args...> as{ args... };
return vfprintf(os, internal::to_string_view(format_str),
return vfprintf(os, to_string_view(format_str),
basic_format_args<context>(as));
}
FMT_END_NAMESPACE