From 23b856f2e694dc87fbafe411ed5e37d4648c6b23 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 8 Jul 2025 10:38:40 +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/WinStd/Common.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/WinStd/Common.h b/include/WinStd/Common.h index dcebc37b..df028a1b 100644 --- a/include/WinStd/Common.h +++ b/include/WinStd/Common.h @@ -914,6 +914,9 @@ namespace winstd handle(_In_ const handle &h) noexcept {}; handle& operator=(_In_ const handle &h) noexcept {}; + // Force use of valid() method when testing handle. + operator bool() const; + public: /// /// Attaches already available object handle.