From d9a719ddb8d0212bd942c78a325cb01e388126ea Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 9 Jun 2025 22:35:56 +0200 Subject: [PATCH] Common: Require explicit handle validation Using operator bool() hid ambiguity when handle was polymorfic with bool. Using operator!() reqired !! to test for validity which results in awkward code. Signed-off-by: Simon Rozman --- include/WinStd/Common.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/WinStd/Common.h b/include/WinStd/Common.h index 528d63b6..dcebc37b 100644 --- a/include/WinStd/Common.h +++ b/include/WinStd/Common.h @@ -987,18 +987,17 @@ namespace winstd } /// - /// Tests if the object handle is invalid. + /// Tests if the object handle is valid. /// /// \return - /// - Non zero when object handle is invalid; + /// - Non zero when object handle is valid; /// - Zero otherwise. /// /// \note Implementing `operator bool() const` would be correct C++ approach here. Unfortunately, it would produce ambiguities where `bool` and `handle_type` are polymorphed. - /// Use `!!` to test if the object handle is valid. /// - bool operator!() const + bool valid() const { - return m_h == invalid; + return m_h != invalid; } ///