mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-26 20:30:06 +01:00
to_string supports types with format_as
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
committed by
Victor Zverovich
parent
29ce2ff8a8
commit
e150ea0cc2
@@ -4287,7 +4287,8 @@ auto join(Range&& range, string_view sep)
|
||||
std::string answer = fmt::to_string(42);
|
||||
\endrst
|
||||
*/
|
||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
|
||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value &&
|
||||
!detail::has_format_as<T>::value)>
|
||||
inline auto to_string(const T& value) -> std::string {
|
||||
auto buffer = memory_buffer();
|
||||
detail::write<char>(appender(buffer), value);
|
||||
@@ -4312,6 +4313,12 @@ FMT_NODISCARD auto to_string(const basic_memory_buffer<Char, SIZE>& buf)
|
||||
return std::basic_string<Char>(buf.data(), size);
|
||||
}
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value &&
|
||||
detail::has_format_as<T>::value)>
|
||||
inline auto to_string(const T& value) -> std::string {
|
||||
return to_string(format_as(value));
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Char>
|
||||
|
||||
Reference in New Issue
Block a user