mirror of
https://github.com/nlohmann/json.git
synced 2026-10-06 06:30:31 +00:00
Avoid MSVC 2015's C4800 for enums with underlying type bool
MSVC 2015 warns about any conversion to bool (C4800), even with an explicit cast, so the enum conversions from #5754 (#5671) failed the AppVeyor build with /WX. Convert to bool by comparing with zero via the new detail::bool_aware_static_cast, and keep doctest from printing the enum in the test. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -191,8 +191,10 @@ TEST_CASE("value conversion")
|
||||
{
|
||||
enum class bool_enum : bool { off, on };
|
||||
|
||||
CHECK(json(bool_enum::off).get<bool_enum>() == bool_enum::off);
|
||||
CHECK(json(bool_enum::on).get<bool_enum>() == bool_enum::on);
|
||||
// the extra parentheses keep doctest from printing the enum via its
|
||||
// underlying type, which MSVC 2015 reports as C4800
|
||||
CHECK((json(bool_enum::off).get<bool_enum>() == bool_enum::off));
|
||||
CHECK((json(bool_enum::on).get<bool_enum>() == bool_enum::on));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user