From 7e7902f9ffa652f78540870170c492a67816b731 Mon Sep 17 00:00:00 2001 From: Like Ma Date: Wed, 13 Nov 2019 20:20:47 +0800 Subject: Use unspecified_bool_type instead of bool. --- ACE/ace/Refcounted_Auto_Ptr.h | 6 +++++- ACE/ace/Refcounted_Auto_Ptr.inl | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ACE/ace/Refcounted_Auto_Ptr.h b/ACE/ace/Refcounted_Auto_Ptr.h index 670243dc1b5..aa133352a35 100644 --- a/ACE/ace/Refcounted_Auto_Ptr.h +++ b/ACE/ace/Refcounted_Auto_Ptr.h @@ -44,6 +44,10 @@ template class ACE_Refcounted_Auto_Ptr; template class ACE_Refcounted_Auto_Ptr { + /// Used to define a proper boolean conversion for "if (sp) ..." + static void unspecified_bool(ACE_Refcounted_Auto_Ptr***){}; + typedef void (*unspecified_bool_type)(ACE_Refcounted_Auto_Ptr***); + public: /// Constructor that initializes an ACE_Refcounted_Auto_Ptr to /// the specified pointer value. @@ -86,7 +90,7 @@ public: bool operator !() const; /// Check rep easily. - operator bool () const; + operator unspecified_bool_type() const; /// Releases the reference to the underlying representation object. /// @retval The pointer value prior to releasing it. diff --git a/ACE/ace/Refcounted_Auto_Ptr.inl b/ACE/ace/Refcounted_Auto_Ptr.inl index f495076b153..30f3b2e1b02 100644 --- a/ACE/ace/Refcounted_Auto_Ptr.inl +++ b/ACE/ace/Refcounted_Auto_Ptr.inl @@ -128,9 +128,9 @@ ACE_Refcounted_Auto_Ptr::operator !() const } template inline -ACE_Refcounted_Auto_Ptr::operator bool () const +ACE_Refcounted_Auto_Ptr::operator unspecified_bool_type () const { - return this->rep_->get () != 0; + return this->rep_->get () != 0 ? unspecified_bool : 0; } template inline X* -- cgit v1.2.1