Fix test build failures due to missing noexcept (gcc-12)

* alt_string has multiple member functions that should be marked noexcept.
* nlohmann::ordered_map constructors can be noexcept.

Compilation failures result from the warning flag -Werror=noexcept and
gcc-12.
This commit is contained in:
Florian Albrechtskirchinger 2022-03-05 23:20:01 +01:00
parent 575be1a7fe
commit c21ed8aabe
4 changed files with 7 additions and 5 deletions

View File

@ -30,7 +30,8 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
// Explicit constructors instead of `using Container::Container` // Explicit constructors instead of `using Container::Container`
// otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4)
ordered_map(const Allocator& alloc = Allocator()) : Container{alloc} {} ordered_map() noexcept(noexcept(Container())) : Container{} {}
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {}
template <class It> template <class It>
ordered_map(It first, It last, const Allocator& alloc = Allocator()) ordered_map(It first, It last, const Allocator& alloc = Allocator())
: Container{first, last, alloc} {} : Container{first, last, alloc} {}

View File

@ -17066,7 +17066,8 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
// Explicit constructors instead of `using Container::Container` // Explicit constructors instead of `using Container::Container`
// otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4)
ordered_map(const Allocator& alloc = Allocator()) : Container{alloc} {} ordered_map() noexcept(noexcept(Container())) : Container{} {}
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {}
template <class It> template <class It>
ordered_map(It first, It last, const Allocator& alloc = Allocator()) ordered_map(It first, It last, const Allocator& alloc = Allocator())
: Container{first, last, alloc} {} : Container{first, last, alloc} {}

View File

@ -104,12 +104,12 @@ class alt_string
} }
template <typename op_type> template <typename op_type>
bool operator<(const op_type& op) const bool operator<(const op_type& op) const noexcept
{ {
return str_impl < op; return str_impl < op;
} }
bool operator<(const alt_string& op) const bool operator<(const alt_string& op) const noexcept
{ {
return str_impl < op.str_impl; return str_impl < op.str_impl;
} }

View File

@ -341,7 +341,7 @@ TEST_CASE("regression tests 2")
] ]
})"; })";
json::parser_callback_t cb = [&](int /*level*/, json::parse_event_t event, json & parsed) json::parser_callback_t cb = [&](int /*level*/, json::parse_event_t event, json & parsed) noexcept
{ {
// skip uninteresting events // skip uninteresting events
if (event == json::parse_event_t::value && !parsed.is_primitive()) if (event == json::parse_event_t::value && !parsed.is_primitive())