Skip to content

Commit

Permalink
fix gcc <= 7.1 compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Sep 11, 2022
1 parent 94ceb38 commit fbfd2af
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,24 @@ struct scan_handler : error_handler {
scan_ctx_.advance_to(it + size);
}

FMT_CONSTEXPR int on_arg_id() { return on_arg_id(next_arg_id_++); }
FMT_CONSTEXPR int on_arg_id(int id) {
// GCC 7.1.x and below fail to compile if on_arg_id is declared constexpr
#if FMT_GCC_VERSION && (FMT_GCC_VERSION < 720)
# define FMT_CONDITIONAL_CONSTEXPR
#else
# define FMT_CONDITIONAL_CONSTEXPR FMT_CONSTEXPR
#endif

FMT_CONDITIONAL_CONSTEXPR int on_arg_id() { return on_arg_id(next_arg_id_++); }
FMT_CONDITIONAL_CONSTEXPR int on_arg_id(int id) {
if (id >= args_.size) on_error("argument index out of range");
arg_ = args_.data[id];
return id;
}
FMT_CONSTEXPR int on_arg_id(string_view id) {
FMT_CONDITIONAL_CONSTEXPR int on_arg_id(string_view id) {
if (id.data()) on_error("invalid format");
return 0;
}
#undef FMT_CONDITIONAL_CONSTEXPR

void on_replacement_field(int, const char*) {
auto it = scan_ctx_.begin(), end = scan_ctx_.end();
Expand Down

0 comments on commit fbfd2af

Please sign in to comment.