1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-20 12:53:55 +08:00

cmUVHandlePtr: Add explicit conversion to bool

This commit is contained in:
Brad King
2023-10-26 17:08:55 -04:00
parent cd2894a089
commit 17690558c3
3 changed files with 11 additions and 3 deletions

View File

@@ -96,6 +96,12 @@ void uv_handle_ptr_base_<T>::allocate(void* data)
this->handle->data = 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()
{

View File

@@ -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
*/

View File

@@ -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;