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 <simon@rozman.si>
This commit is contained in:
Simon Rozman 2025-06-09 22:35:56 +02:00
parent ca791f1663
commit d9a719ddb8

View File

@ -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;
}
///