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:40:25 +02:00
parent a04c27a14e
commit 8ed062347e

View File

@ -173,18 +173,17 @@ namespace macstd
}
///
/// 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 `T` are polymorphed.
/// Use `!!` to test if the object handle is valid.
///
bool operator!() const
bool valid() const
{
return m_h == INVAL;
return m_h != INVAL;
}
///