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:
@@ -96,6 +96,12 @@ void uv_handle_ptr_base_<T>::allocate(void* data)
|
|||||||
this->handle->data = data;
|
this->handle->data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
uv_handle_ptr_base_<T>::operator bool() const
|
||||||
|
{
|
||||||
|
return this->handle.get();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void uv_handle_ptr_base_<T>::reset()
|
void uv_handle_ptr_base_<T>::reset()
|
||||||
{
|
{
|
||||||
|
@@ -130,6 +130,8 @@ public:
|
|||||||
uv_handle_ptr_base_(std::nullptr_t) {}
|
uv_handle_ptr_base_(std::nullptr_t) {}
|
||||||
~uv_handle_ptr_base_() { this->reset(); }
|
~uv_handle_ptr_base_() { this->reset(); }
|
||||||
|
|
||||||
|
explicit operator bool() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Properly close the handle if needed and sets the inner handle to nullptr
|
* Properly close the handle if needed and sets the inner handle to nullptr
|
||||||
*/
|
*/
|
||||||
|
@@ -37,7 +37,7 @@ static bool testAsyncShutdown()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signal.get()) {
|
if (signal) {
|
||||||
std::cerr << "Loop exited with signal not being cleaned up" << std::endl;
|
std::cerr << "Loop exited with signal not being cleaned up" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -125,13 +125,13 @@ static bool testCrossAssignment()
|
|||||||
pipe.init(Loop, 0);
|
pipe.init(Loop, 0);
|
||||||
|
|
||||||
cm::uv_stream_ptr stream = std::move(pipe);
|
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::cerr << "Move should be sure to invalidate the previous ptr"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cm::uv_handle_ptr handle = std::move(stream);
|
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::cerr << "Move should be sure to invalidate the previous ptr"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user