cmUVHandlePtr: Fix conversion to bool on Oracle Studio compiler
The operator added by commit 17690558c3
(cmUVHandlePtr: Add explicit
conversion to bool, 2023-10-26) works in direct expressions like
`if(foo)` but not compound expressions like `if(foo && ...)`.
Drop the `explicit` mark when compiling with Oracle Studio so we
can at least compile valid code.
This commit is contained in:
parent
0e11e24ecd
commit
47fbb29ad7
@ -132,7 +132,15 @@ 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(); }
|
||||||
|
|
||||||
|
#if defined(__SUNPRO_CC)
|
||||||
|
// The Oracle Studio compiler recognizes 'explicit operator bool()' in
|
||||||
|
// 'if(foo)' but not 'if(foo && ...)'. The purpose of 'explicit' here
|
||||||
|
// is to avoid accidental conversion in non-boolean contexts. Just
|
||||||
|
// leave it out on this compiler so we can compile valid code.
|
||||||
|
operator bool() const;
|
||||||
|
#else
|
||||||
explicit operator bool() const;
|
explicit operator bool() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
@ -7,6 +7,21 @@
|
|||||||
#include "cmGetPipes.h"
|
#include "cmGetPipes.h"
|
||||||
#include "cmUVHandlePtr.h"
|
#include "cmUVHandlePtr.h"
|
||||||
|
|
||||||
|
static bool testBool()
|
||||||
|
{
|
||||||
|
cm::uv_async_ptr async;
|
||||||
|
cm::uv_handle_ptr handle;
|
||||||
|
cm::uv_idle_ptr idle;
|
||||||
|
cm::uv_pipe_ptr pipe;
|
||||||
|
cm::uv_process_ptr process;
|
||||||
|
cm::uv_signal_ptr signal;
|
||||||
|
cm::uv_stream_ptr stream;
|
||||||
|
cm::uv_timer_ptr timer;
|
||||||
|
cm::uv_tty_ptr tty;
|
||||||
|
return !async && !handle && !idle && !pipe && !process && !signal &&
|
||||||
|
!stream && !timer && !tty;
|
||||||
|
}
|
||||||
|
|
||||||
static bool testIdle()
|
static bool testIdle()
|
||||||
{
|
{
|
||||||
bool idled = false;
|
bool idled = false;
|
||||||
@ -130,6 +145,7 @@ static bool testWriteCallback()
|
|||||||
int testUVHandlePtr(int, char** const)
|
int testUVHandlePtr(int, char** const)
|
||||||
{
|
{
|
||||||
bool passed = true;
|
bool passed = true;
|
||||||
|
passed = testBool() && passed;
|
||||||
passed = testIdle() && passed;
|
passed = testIdle() && passed;
|
||||||
passed = testTimer() && passed;
|
passed = testTimer() && passed;
|
||||||
passed = testWriteCallback() && passed;
|
passed = testWriteCallback() && passed;
|
||||||
|
Loading…
Reference in New Issue
Block a user