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>,
|
||||
Char> : formatter<std::tm, Char> {
|
||||
FMT_CONSTEXPR formatter() {
|
||||
this->do_parse(default_specs,
|
||||
default_specs + sizeof(default_specs) / sizeof(Char));
|
||||
basic_string_view<Char> default_specs =
|
||||
detail::string_literal<Char, '%', 'F', ' ', '%', 'T'>{};
|
||||
this->do_parse(default_specs.begin(), default_specs.end());
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
@ -2011,18 +2012,8 @@ struct formatter<std::chrono::time_point<std::chrono::system_clock, Duration>,
|
||||
FormatContext& ctx) const -> decltype(ctx.out()) {
|
||||
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> {
|
||||
private:
|
||||
enum class spec {
|
||||
|
@ -249,6 +249,18 @@ FMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) {
|
||||
#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 {
|
||||
private:
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
template <typename T> struct is_tuple_like {
|
||||
|
Loading…
Reference in New Issue
Block a user