mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-09 07:04:27 +02:00
add missing throws in format.h; undo change to core.h
This commit is contained in:
@@ -38,7 +38,7 @@
|
|||||||
UNITS_DIAGNOSTIC_PUSH
|
UNITS_DIAGNOSTIC_PUSH
|
||||||
UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE
|
UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE
|
||||||
UNITS_DIAGNOSTIC_IGNORE_SHADOW
|
UNITS_DIAGNOSTIC_IGNORE_SHADOW
|
||||||
#include <fmt/core.h>
|
#include <fmt/format.h>
|
||||||
UNITS_DIAGNOSTIC_POP
|
UNITS_DIAGNOSTIC_POP
|
||||||
|
|
||||||
#define STD_FMT fmt
|
#define STD_FMT fmt
|
||||||
|
@@ -126,7 +126,7 @@ constexpr const It parse_units_rep(It begin, S end, Handler&& handler, bool trea
|
|||||||
if (treat_as_floating_point) {
|
if (treat_as_floating_point) {
|
||||||
begin = parse_precision(begin, end, handler);
|
begin = parse_precision(begin, end, handler);
|
||||||
} else
|
} else
|
||||||
throw STD_FMT::format_error("precision not allowed for integral quantity representation");
|
FMT_THROW(STD_FMT::format_error("precision not allowed for integral quantity representation"));
|
||||||
if (begin == end) return begin;
|
if (begin == end) return begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ constexpr It parse_units_format(It begin, S end, Handler&& handler)
|
|||||||
}
|
}
|
||||||
if (begin != ptr) handler.on_text(begin, ptr);
|
if (begin != ptr) handler.on_text(begin, ptr);
|
||||||
begin = ++ptr; // consume '%'
|
begin = ++ptr; // consume '%'
|
||||||
if (ptr == end) throw STD_FMT::format_error("invalid format");
|
if (ptr == end) FMT_THROW(STD_FMT::format_error("invalid format"));
|
||||||
c = *ptr++;
|
c = *ptr++;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@@ -177,7 +177,7 @@ constexpr It parse_units_format(It begin, S end, Handler&& handler)
|
|||||||
default:
|
default:
|
||||||
constexpr auto units_types = std::string_view{"Qq"};
|
constexpr auto units_types = std::string_view{"Qq"};
|
||||||
const auto new_end = std::find_first_of(begin, end, units_types.begin(), units_types.end());
|
const auto new_end = std::find_first_of(begin, end, units_types.begin(), units_types.end());
|
||||||
if (new_end == end) throw STD_FMT::format_error("invalid format");
|
if (new_end == end) FMT_THROW(STD_FMT::format_error("invalid format"));
|
||||||
if (*new_end == 'Q') {
|
if (*new_end == 'Q') {
|
||||||
handler.on_quantity_value(begin, new_end); // Edit `on_quantity_value` to add rep modifiers
|
handler.on_quantity_value(begin, new_end); // Edit `on_quantity_value` to add rep modifiers
|
||||||
} else {
|
} else {
|
||||||
@@ -331,7 +331,7 @@ private:
|
|||||||
if (valid_rep_types.find(type) != std::string_view::npos) {
|
if (valid_rep_types.find(type) != std::string_view::npos) {
|
||||||
f.specs.rep.type = type;
|
f.specs.rep.type = type;
|
||||||
} else {
|
} else {
|
||||||
throw STD_FMT::format_error("invalid quantity type specifier");
|
FMT_THROW(STD_FMT::format_error("invalid quantity type specifier"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ private:
|
|||||||
if (valid_modifiers.find(mod) != std::string_view::npos) {
|
if (valid_modifiers.find(mod) != std::string_view::npos) {
|
||||||
f.specs.unit.ascii_only = true;
|
f.specs.unit.ascii_only = true;
|
||||||
} else {
|
} else {
|
||||||
throw STD_FMT::format_error("invalid unit modifier specified");
|
FMT_THROW(STD_FMT::format_error("invalid unit modifier specified"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user