fix for empty format string

This commit is contained in:
Alexey Ochapov 2020-12-02 21:35:40 +03:00
parent 855e4887b3
commit 6ea2ca8ff4
No known key found for this signature in database
GPG Key ID: 9DC52E8F031B8DA8

View File

@ -45,7 +45,7 @@ struct is_compiled_string : std::is_base_of<compiled_string, S> {};
#ifdef FMT_USE_NONTYPE_TEMPLATE_PARAMETERS #ifdef FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
template <typename Char, size_t N> struct fixed_string { template <typename Char, size_t N> struct fixed_string {
constexpr fixed_string(const Char (&str)[N + 1]) { constexpr fixed_string(const Char (&str)[N]) {
copy_str<Char, const Char*, Char*>(static_cast<const Char*>(str), str + N, copy_str<Char, const Char*, Char*>(static_cast<const Char*>(str), str + N,
data); data);
} }
@ -53,13 +53,13 @@ template <typename Char, size_t N> struct fixed_string {
}; };
template <typename Char, size_t N> template <typename Char, size_t N>
fixed_string(const Char (&str)[N]) -> fixed_string<Char, N - 1>; fixed_string(const Char (&str)[N]) -> fixed_string<Char, N>;
template <typename Char, size_t N, fixed_string<Char, N> Str> template <typename Char, size_t N, fixed_string<Char, N> Str>
struct udl_compiled_string : compiled_string { struct udl_compiled_string : compiled_string {
using char_type = Char; using char_type = Char;
constexpr operator basic_string_view<char_type>() const { constexpr operator basic_string_view<char_type>() const {
return {Str.data, N}; return {Str.data, N - 1};
} }
}; };
#endif #endif