diff options
-rw-r--r-- | Source/cmUVHandlePtr.cxx | 6 | ||||
-rw-r--r-- | Source/cmUVHandlePtr.h | 2 | ||||
-rw-r--r-- | Tests/CMakeLib/testUVRAII.cxx | 6 |
3 files changed, 11 insertions, 3 deletions
diff --git a/Source/cmUVHandlePtr.cxx b/Source/cmUVHandlePtr.cxx index fd109a5..0e169df 100644 --- a/Source/cmUVHandlePtr.cxx +++ b/Source/cmUVHandlePtr.cxx @@ -97,6 +97,12 @@ void uv_handle_ptr_base_<T>::allocate(void* data) } template <typename T> +uv_handle_ptr_base_<T>::operator bool() const +{ + return this->handle.get(); +} + +template <typename T> void uv_handle_ptr_base_<T>::reset() { this->handle.reset(); diff --git a/Source/cmUVHandlePtr.h b/Source/cmUVHandlePtr.h index afb7658..f5e2097 100644 --- a/Source/cmUVHandlePtr.h +++ b/Source/cmUVHandlePtr.h @@ -130,6 +130,8 @@ public: uv_handle_ptr_base_(std::nullptr_t) {} ~uv_handle_ptr_base_() { this->reset(); } + explicit operator bool() const; + /** * Properly close the handle if needed and sets the inner handle to nullptr */ diff --git a/Tests/CMakeLib/testUVRAII.cxx b/Tests/CMakeLib/testUVRAII.cxx index 0bdd44c..ce11761 100644 --- a/Tests/CMakeLib/testUVRAII.cxx +++ b/Tests/CMakeLib/testUVRAII.cxx @@ -37,7 +37,7 @@ static bool testAsyncShutdown() return false; } - if (signal.get()) { + if (signal) { std::cerr << "Loop exited with signal not being cleaned up" << std::endl; return false; } @@ -125,13 +125,13 @@ static bool testCrossAssignment() pipe.init(Loop, 0); cm::uv_stream_ptr stream = std::move(pipe); - if (pipe.get()) { + if (pipe) { std::cerr << "Move should be sure to invalidate the previous ptr" << std::endl; return false; } cm::uv_handle_ptr handle = std::move(stream); - if (stream.get()) { + if (stream) { std::cerr << "Move should be sure to invalidate the previous ptr" << std::endl; return false; |