diff --git a/include/stdex/stream.hpp b/include/stdex/stream.hpp index 4bc3c2438..6e23c87be 100644 --- a/include/stdex/stream.hpp +++ b/include/stdex/stream.hpp @@ -2383,6 +2383,9 @@ namespace stdex socket(_In_ const socket& other); socket& operator =(_In_ const socket& other); + // Force use of valid() method when testing handle. + operator bool() const; + public: socket(_Inout_ socket&& other) noexcept : m_h(other.m_h) { diff --git a/include/stdex/system.hpp b/include/stdex/system.hpp index 43e64bdff..fa7aca56b 100644 --- a/include/stdex/system.hpp +++ b/include/stdex/system.hpp @@ -200,6 +200,10 @@ namespace stdex /// operator T() const noexcept { return m_h; } + private: + // Force use of valid() method when testing handle. + operator bool() const; + protected: T m_h; };