Reuse detail::string_literal in the chrono formatter
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
parent
6c9304b2c2
commit
36a25d75b4
@ -2002,8 +2002,9 @@ template <typename Char, typename Duration>
|
|||||||
struct formatter<std::chrono::time_point<std::chrono::system_clock, Duration>,
|
struct formatter<std::chrono::time_point<std::chrono::system_clock, Duration>,
|
||||||
Char> : formatter<std::tm, Char> {
|
Char> : formatter<std::tm, Char> {
|
||||||
FMT_CONSTEXPR formatter() {
|
FMT_CONSTEXPR formatter() {
|
||||||
this->do_parse(default_specs,
|
basic_string_view<Char> default_specs =
|
||||||
default_specs + sizeof(default_specs) / sizeof(Char));
|
detail::string_literal<Char, '%', 'F', ' ', '%', 'T'>{};
|
||||||
|
this->do_parse(default_specs.begin(), default_specs.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FormatContext>
|
template <typename FormatContext>
|
||||||
@ -2011,18 +2012,8 @@ struct formatter<std::chrono::time_point<std::chrono::system_clock, Duration>,
|
|||||||
FormatContext& ctx) const -> decltype(ctx.out()) {
|
FormatContext& ctx) const -> decltype(ctx.out()) {
|
||||||
return formatter<std::tm, Char>::format(localtime(val), ctx);
|
return formatter<std::tm, Char>::format(localtime(val), ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EDG frontend (Intel, NVHPC compilers) can't determine array length.
|
|
||||||
static constexpr const Char default_specs[5] = {'%', 'F', ' ', '%', 'T'};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#if FMT_CPLUSPLUS < 201703L
|
|
||||||
template <typename Char, typename Duration>
|
|
||||||
constexpr const Char
|
|
||||||
formatter<std::chrono::time_point<std::chrono::system_clock, Duration>,
|
|
||||||
Char>::default_specs[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <typename Char> struct formatter<std::tm, Char> {
|
template <typename Char> struct formatter<std::tm, Char> {
|
||||||
private:
|
private:
|
||||||
enum class spec {
|
enum class spec {
|
||||||
|
@ -249,6 +249,18 @@ FMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename CharT, CharT... C> struct string_literal {
|
||||||
|
static constexpr CharT value[sizeof...(C)] = {C...};
|
||||||
|
constexpr operator basic_string_view<CharT>() const {
|
||||||
|
return {value, sizeof...(C)};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#if FMT_CPLUSPLUS < 201703L
|
||||||
|
template <typename CharT, CharT... C>
|
||||||
|
constexpr CharT string_literal<CharT, C...>::value[sizeof...(C)];
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename Streambuf> class formatbuf : public Streambuf {
|
template <typename Streambuf> class formatbuf : public Streambuf {
|
||||||
private:
|
private:
|
||||||
using char_type = typename Streambuf::char_type;
|
using char_type = typename Streambuf::char_type;
|
||||||
|
@ -309,16 +309,6 @@ OutputIt write_range_entry(OutputIt out, const Arg& v) {
|
|||||||
return write<Char>(out, v);
|
return write<Char>(out, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename CharT, CharT... C> struct string_literal {
|
|
||||||
static constexpr CharT value[sizeof...(C)] = {C...};
|
|
||||||
constexpr operator basic_string_view<CharT>() const {
|
|
||||||
return {value, sizeof...(C)};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename CharT, CharT... C>
|
|
||||||
constexpr CharT string_literal<CharT, C...>::value[sizeof...(C)];
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <typename T> struct is_tuple_like {
|
template <typename T> struct is_tuple_like {
|
||||||
|
Loading…
Reference in New Issue
Block a user