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:
parent
ca791f1663
commit
d9a719ddb8
@ -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;
|
||||
}
|
||||
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user