From 496dc9cb348821077a5712ec21dfca0403502903 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 27 May 2025 10:22:07 +0200 Subject: [PATCH] Revise ternary operators Where test expression is already or almost boolean type, using ternery operator is excessive and possibly more difficult to read. Signed-off-by: Simon Rozman --- include/stdex/parser.hpp | 8 ++++---- include/stdex/stream.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/stdex/parser.hpp b/include/stdex/parser.hpp index c9fcc1753..4caffa9d6 100644 --- a/include/stdex/parser.hpp +++ b/include/stdex/parser.hpp @@ -875,7 +875,7 @@ namespace stdex { stdex_assert(text || start >= end); const wchar_t* str = m_str.data(); - const bool case_insensitive = flags & match_case_insensitive ? true : false; + const bool case_insensitive = (flags & match_case_insensitive) != 0; const auto& ctype = std::use_facet>(m_locale); for (this->interval.end = start;;) { if (!*str) { @@ -4670,7 +4670,7 @@ namespace stdex { stdex_assert(text || start >= end); const auto& ctype = std::use_facet>(this->m_locale); - const bool case_insensitive = flags & match_case_insensitive ? true : false; + const bool case_insensitive = (flags & match_case_insensitive) != 0; struct country_t { T country[2]; T check_digits[2]; @@ -4956,7 +4956,7 @@ namespace stdex { stdex_assert(text || start >= end); const auto& ctype = std::use_facet>(this->m_locale); - const bool case_insensitive = flags & match_case_insensitive ? true : false; + const bool case_insensitive = (flags & match_case_insensitive) != 0; size_t n, available, next; uint32_t nominator; @@ -5196,7 +5196,7 @@ namespace stdex { stdex_assert(text || start >= end); const auto& ctype = std::use_facet>(this->m_locale); - const bool case_insensitive = flags & match_case_insensitive ? true : false; + const bool case_insensitive = (flags & match_case_insensitive) != 0; this->interval.end = start; if (this->interval.end >= end || this->interval.end + 1 >= end || diff --git a/include/stdex/stream.hpp b/include/stdex/stream.hpp index ba816d914..a1ecd1905 100644 --- a/include/stdex/stream.hpp +++ b/include/stdex/stream.hpp @@ -2764,7 +2764,7 @@ namespace stdex if (mode & share_deleting) dwShareMode |= FILE_SHARE_DELETE; SECURITY_ATTRIBUTES sa = { sizeof(SECURITY_ATTRIBUTES) }; - sa.bInheritHandle = mode & inherit_handle ? true : false; + sa.bInheritHandle = mode & inherit_handle ? TRUE : FALSE; DWORD dwCreationDisposition; switch (mode & mode_disposition_mask) {