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 <simon@rozman.si>
This commit is contained in:
parent
a9d87b4cfd
commit
b99b2fc19e
@ -2383,6 +2383,9 @@ namespace stdex
|
|||||||
socket(_In_ const socket& other);
|
socket(_In_ const socket& other);
|
||||||
socket& operator =(_In_ const socket& other);
|
socket& operator =(_In_ const socket& other);
|
||||||
|
|
||||||
|
// Force use of valid() method when testing handle.
|
||||||
|
operator bool() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
socket(_Inout_ socket&& other) noexcept : m_h(other.m_h)
|
socket(_Inout_ socket&& other) noexcept : m_h(other.m_h)
|
||||||
{
|
{
|
||||||
|
@ -200,6 +200,10 @@ namespace stdex
|
|||||||
///
|
///
|
||||||
operator T() const noexcept { return m_h; }
|
operator T() const noexcept { return m_h; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Force use of valid() method when testing handle.
|
||||||
|
operator bool() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
T m_h;
|
T m_h;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user