From e4f28df310d379cd8e02eceb53d85a96cf51624d Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 8 Jul 2025 11:18:21 +0200 Subject: [PATCH] Common: Enforce explicit handle validation Some invalid handle values are -1 or INVALID_HANDLE_VALUE, hence our handle template has a specific invalid handle value parameter we should always test against. Time and again, I find my code simply comparing handle against zero. Signed-off-by: Simon Rozman --- include/MacStd/common.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/MacStd/common.hpp b/include/MacStd/common.hpp index 00d340a..497e804 100644 --- a/include/MacStd/common.hpp +++ b/include/MacStd/common.hpp @@ -323,6 +323,10 @@ namespace macstd } } + private: + // Force use of valid() method when testing handle. + operator bool() const; + protected: T m_h; ///< Object handle };