diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2020-08-26 17:00:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-26 17:00:24 +0200 |
commit | 75f62ae39027c656a5c4a936ecd2be10b0ac0293 (patch) | |
tree | 3211d05591c38ba840d585b798359d7b342fda1d | |
parent | 8b02c0495ec5d3fae0ab8de6985701337eb8eec6 (diff) | |
parent | 6fdc79c928bc388be70ccf9f1e371648cdf70ef3 (diff) | |
download | ATCD-75f62ae39027c656a5c4a936ecd2be10b0ac0293.tar.gz |
Merge pull request #1224 from jwillemsen/likema-unspecified-bool-type
Use unspecified_bool_type instead of bool
-rw-r--r-- | ACE/ace/Intrusive_Auto_Ptr.h | 9 | ||||
-rw-r--r-- | ACE/ace/Intrusive_Auto_Ptr.inl | 13 | ||||
-rw-r--r-- | ACE/ace/Refcounted_Auto_Ptr.h | 6 | ||||
-rw-r--r-- | ACE/ace/Refcounted_Auto_Ptr.inl | 4 |
4 files changed, 14 insertions, 18 deletions
diff --git a/ACE/ace/Intrusive_Auto_Ptr.h b/ACE/ace/Intrusive_Auto_Ptr.h index 2a6955f129b..36ff94901b8 100644 --- a/ACE/ace/Intrusive_Auto_Ptr.h +++ b/ACE/ace/Intrusive_Auto_Ptr.h @@ -47,20 +47,17 @@ template <class X> class ACE_Intrusive_Auto_Ptr { protected: - - /// Used to define a proper boolean conversion for "if (sp) ..." + /// Used to define a proper boolean conversion for "if (sp) ..." static void unspecified_bool(ACE_Intrusive_Auto_Ptr<X>***){}; typedef void (*unspecified_bool_type)(ACE_Intrusive_Auto_Ptr<X>***); public: - /// Enables "if (sp) ..." operator unspecified_bool_type() const { return rep_ == 0 ? 0: unspecified_bool; } - /// Constructor that initializes an ACE_Intrusive_Auto_Ptr to /// the specified pointer value. ACE_Intrusive_Auto_Ptr (X *p = 0, bool addref = true); @@ -103,14 +100,10 @@ public: /// Get the reference count value. long count (void) const; - /// Returns @c true if this object does not contain a valid pointer. - // bool null (void) const; - /// Declare the dynamic allocation hooks. ACE_ALLOC_HOOK_DECLARE; protected: - /// Protect operations on the ACE_Intrusive_Auto_Ptr. X *rep_; }; diff --git a/ACE/ace/Intrusive_Auto_Ptr.inl b/ACE/ace/Intrusive_Auto_Ptr.inl index 7d353e316c9..a37f2f3b25b 100644 --- a/ACE/ace/Intrusive_Auto_Ptr.inl +++ b/ACE/ace/Intrusive_Auto_Ptr.inl @@ -114,31 +114,30 @@ template<class T, class U> ACE_INLINE bool operator==(ACE_Intrusive_Auto_Ptr<T> return a.get() == b.get(); } - /// Inequality operator, which is the opposite of equality. - template<class T, class U> ACE_INLINE bool operator!=(ACE_Intrusive_Auto_Ptr<T> const & a, ACE_Intrusive_Auto_Ptr<U> const & b) +/// Inequality operator, which is the opposite of equality. +template<class T, class U> ACE_INLINE bool operator!=(ACE_Intrusive_Auto_Ptr<T> const & a, ACE_Intrusive_Auto_Ptr<U> const & b) { return a.get() != b.get(); } - template<class T, class U> ACE_INLINE bool operator==(ACE_Intrusive_Auto_Ptr<T> const & a, U * b) +template<class T, class U> ACE_INLINE bool operator==(ACE_Intrusive_Auto_Ptr<T> const & a, U * b) { return a.get() == b; } - template<class T, class U> ACE_INLINE bool operator!=(ACE_Intrusive_Auto_Ptr<T> & a, U * b) +template<class T, class U> ACE_INLINE bool operator!=(ACE_Intrusive_Auto_Ptr<T> & a, U * b) { return a.get() != b; } - template<class T, class U> ACE_INLINE bool operator==(T * a, ACE_Intrusive_Auto_Ptr<U> const & b) +template<class T, class U> ACE_INLINE bool operator==(T * a, ACE_Intrusive_Auto_Ptr<U> const & b) { return a == b.get(); } - template<class T, class U> ACE_INLINE bool operator!=(T * a, ACE_Intrusive_Auto_Ptr<U> const & b) +template<class T, class U> ACE_INLINE bool operator!=(T * a, ACE_Intrusive_Auto_Ptr<U> const & b) { return a != b.get(); } - ACE_END_VERSIONED_NAMESPACE_DECL 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 X, class ACE_LOCK> class ACE_Refcounted_Auto_Ptr; template <class X, class ACE_LOCK> class ACE_Refcounted_Auto_Ptr { + /// Used to define a proper boolean conversion for "if (sp) ..." + static void unspecified_bool(ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>***){}; + typedef void (*unspecified_bool_type)(ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>***); + 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<X, ACE_LOCK>::operator !() const } template<class X, class ACE_LOCK> inline -ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>::operator bool () const +ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>::operator unspecified_bool_type () const { - return this->rep_->get () != 0; + return this->rep_->get () != 0 ? unspecified_bool : 0; } template <class X, class ACE_LOCK> inline X* |