address requested changes
This commit is contained in:
parent
e1c72c4a88
commit
0a328c0125
@ -96,24 +96,19 @@ TEST(std_test, optional) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// this struct exists only to force a variant to be
|
struct throws_on_move {
|
||||||
// valueless by exception
|
throws_on_move() = default;
|
||||||
// NOLINTNEXTLINE
|
|
||||||
struct throws_on_move_t {
|
|
||||||
throws_on_move_t() = default;
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE
|
[[noreturn]] throws_on_move(throws_on_move&&) {
|
||||||
[[noreturn]] throws_on_move_t(throws_on_move_t&&) {
|
throw std::runtime_error("Thrown by throws_on_move_t");
|
||||||
throw std::runtime_error{"Thrown by throws_on_move_t"};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throws_on_move_t(const throws_on_move_t&) = default;
|
throws_on_move(const throws_on_move&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> struct fmt::formatter<throws_on_move_t> : formatter<string_view> {
|
template <> struct fmt::formatter<throws_on_move> : formatter<string_view> {
|
||||||
template <typename FormatContext>
|
auto format(const throws_on_move&, format_context& ctx) const {
|
||||||
auto format(const throws_on_move_t&, FormatContext& ctx) const {
|
string_view str("<throws_on_move_t>");
|
||||||
string_view str{"<throws_on_move_t>"};
|
|
||||||
return formatter<string_view>::format(str, ctx);
|
return formatter<string_view>::format(str, ctx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -150,13 +145,11 @@ TEST(std_test, variant) {
|
|||||||
volatile int i = 42; // Test compile error before GCC 11 described in #3068.
|
volatile int i = 42; // Test compile error before GCC 11 described in #3068.
|
||||||
EXPECT_EQ(fmt::format("{}", i), "42");
|
EXPECT_EQ(fmt::format("{}", i), "42");
|
||||||
|
|
||||||
using V2 = std::variant<std::monostate, throws_on_move_t>;
|
std::variant<std::monostate, throws_on_move> v6;
|
||||||
|
|
||||||
V2 v6{};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
throws_on_move_t thrower{};
|
throws_on_move thrower;
|
||||||
v6.emplace<throws_on_move_t>(std::move(thrower));
|
v6.emplace<throws_on_move>(std::move(thrower));
|
||||||
} catch (const std::runtime_error&) {
|
} catch (const std::runtime_error&) {
|
||||||
}
|
}
|
||||||
// v6 is now valueless by exception
|
// v6 is now valueless by exception
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user