Convert to bool by casting, rather than double negation (#480)
Co-authored-by: kitegi <>
diff --git a/doctest/doctest.h b/doctest/doctest.h
index 64a78d7..cf3103f 100644
--- a/doctest/doctest.h
+++ b/doctest/doctest.h
@@ -1184,7 +1184,7 @@
, m_at(at) {}
DOCTEST_NOINLINE operator Result() {
- bool res = !!lhs;
+ bool res = static_cast<bool>(lhs);
if(m_at & assertType::is_false) //!OCLINT bitwise operator in conditional
res = !res;
@@ -6088,7 +6088,7 @@
#define DOCTEST_PARSE_AS_BOOL_OR_FLAG(name, sname, var, default) \
if(parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", option_bool, intRes) || \
parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", option_bool, intRes)) \
- p->var = !!intRes; \
+ p->var = static_cast<bool>(intRes); \
else if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name) || \
parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname)) \
p->var = true; \
diff --git a/doctest/parts/doctest.cpp b/doctest/parts/doctest.cpp
index 986dce4..9da6a97 100644
--- a/doctest/parts/doctest.cpp
+++ b/doctest/parts/doctest.cpp
@@ -3421,7 +3421,7 @@
#define DOCTEST_PARSE_AS_BOOL_OR_FLAG(name, sname, var, default) \
if(parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", option_bool, intRes) || \
parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", option_bool, intRes)) \
- p->var = !!intRes; \
+ p->var = static_cast<bool>(intRes); \
else if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name) || \
parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname)) \
p->var = true; \
diff --git a/doctest/parts/doctest_fwd.h b/doctest/parts/doctest_fwd.h
index 2b926a0..2a9805b 100644
--- a/doctest/parts/doctest_fwd.h
+++ b/doctest/parts/doctest_fwd.h
@@ -1181,7 +1181,7 @@
, m_at(at) {}
DOCTEST_NOINLINE operator Result() {
- bool res = !!lhs;
+ bool res = static_cast<bool>(lhs);
if(m_at & assertType::is_false) //!OCLINT bitwise operator in conditional
res = !res;