mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-26 12:35:32 +00:00
Workaround msvc constexpr issues
This commit is contained in:
parent
8c1b22ba6d
commit
ed2a6377e7
@ -87,7 +87,7 @@
|
|||||||
// GCC doesn't allow throw in constexpr until version 6 (bug 67371).
|
// GCC doesn't allow throw in constexpr until version 6 (bug 67371).
|
||||||
#ifndef FMT_USE_CONSTEXPR
|
#ifndef FMT_USE_CONSTEXPR
|
||||||
# define FMT_USE_CONSTEXPR \
|
# define FMT_USE_CONSTEXPR \
|
||||||
(FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VER >= 1920 || \
|
(FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VER >= 1910 || \
|
||||||
(FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L)) && \
|
(FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L)) && \
|
||||||
!FMT_NVCC && !FMT_ICC_VERSION
|
!FMT_NVCC && !FMT_ICC_VERSION
|
||||||
#endif
|
#endif
|
||||||
@ -1581,7 +1581,7 @@ template <typename OutputIt, typename Char> class basic_format_context {
|
|||||||
FMT_CONSTEXPR auto arg(basic_string_view<char_type> name) -> format_arg {
|
FMT_CONSTEXPR auto arg(basic_string_view<char_type> name) -> format_arg {
|
||||||
return args_.get(name);
|
return args_.get(name);
|
||||||
}
|
}
|
||||||
auto arg_id(basic_string_view<char_type> name) -> int {
|
FMT_CONSTEXPR auto arg_id(basic_string_view<char_type> name) -> int {
|
||||||
return args_.get_id(name);
|
return args_.get_id(name);
|
||||||
}
|
}
|
||||||
auto args() const -> const basic_format_args<basic_format_context>& {
|
auto args() const -> const basic_format_args<basic_format_context>& {
|
||||||
@ -2179,7 +2179,7 @@ FMT_CONSTEXPR auto parse_width(const Char* begin, const Char* end,
|
|||||||
handler.on_dynamic_width(id);
|
handler.on_dynamic_width(id);
|
||||||
}
|
}
|
||||||
FMT_CONSTEXPR void on_error(const char* message) {
|
FMT_CONSTEXPR void on_error(const char* message) {
|
||||||
handler.on_error(message);
|
if (message) handler.on_error(message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2209,7 +2209,7 @@ FMT_CONSTEXPR auto parse_precision(const Char* begin, const Char* end,
|
|||||||
handler.on_dynamic_precision(id);
|
handler.on_dynamic_precision(id);
|
||||||
}
|
}
|
||||||
FMT_CONSTEXPR void on_error(const char* message) {
|
FMT_CONSTEXPR void on_error(const char* message) {
|
||||||
handler.on_error(message);
|
if (message) handler.on_error(message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2310,7 +2310,7 @@ FMT_CONSTEXPR auto parse_replacement_field(const Char* begin, const Char* end,
|
|||||||
arg_id = handler.on_arg_id(id);
|
arg_id = handler.on_arg_id(id);
|
||||||
}
|
}
|
||||||
FMT_CONSTEXPR void on_error(const char* message) {
|
FMT_CONSTEXPR void on_error(const char* message) {
|
||||||
handler.on_error(message);
|
if (message) handler.on_error(message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2659,9 +2659,11 @@ void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
|
|||||||
context.advance_to(write<Char>(context.out(), text));
|
context.advance_to(write<Char>(context.out(), text));
|
||||||
}
|
}
|
||||||
|
|
||||||
int on_arg_id() { return parse_context.next_arg_id(); }
|
FMT_CONSTEXPR int on_arg_id() { return parse_context.next_arg_id(); }
|
||||||
int on_arg_id(int id) { return parse_context.check_arg_id(id), id; }
|
FMT_CONSTEXPR int on_arg_id(int id) {
|
||||||
int on_arg_id(basic_string_view<Char> id) {
|
return parse_context.check_arg_id(id), id;
|
||||||
|
}
|
||||||
|
FMT_CONSTEXPR int on_arg_id(basic_string_view<Char> id) {
|
||||||
int arg_id = context.arg_id(id);
|
int arg_id = context.arg_id(id);
|
||||||
if (arg_id < 0) on_error("argument not found");
|
if (arg_id < 0) on_error("argument not found");
|
||||||
return arg_id;
|
return arg_id;
|
||||||
|
@ -169,13 +169,16 @@ struct scan_handler : error_handler {
|
|||||||
scan_ctx_.advance_to(it + size);
|
scan_ctx_.advance_to(it + size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int on_arg_id() { return on_arg_id(next_arg_id_++); }
|
FMT_CONSTEXPR int on_arg_id() { return on_arg_id(next_arg_id_++); }
|
||||||
int on_arg_id(int id) {
|
FMT_CONSTEXPR int on_arg_id(int id) {
|
||||||
if (id >= args_.size) on_error("argument index out of range");
|
if (id >= args_.size) on_error("argument index out of range");
|
||||||
arg_ = args_.data[id];
|
arg_ = args_.data[id];
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
int on_arg_id(string_view) { return on_error("invalid format"), 0; }
|
FMT_CONSTEXPR int on_arg_id(string_view id) {
|
||||||
|
if (id.data()) on_error("invalid format");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void on_replacement_field(int, const char*) {
|
void on_replacement_field(int, const char*) {
|
||||||
auto it = scan_ctx_.begin(), end = scan_ctx_.end();
|
auto it = scan_ctx_.begin(), end = scan_ctx_.end();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user