From bc00d5fa1a3ddc39d85393ac20b22fcdb97db7f4 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 16 May 2003 12:11:17 +0000 Subject: [PATCH] Fixed bool conversions for Sun 5.3 [SVN r18419] --- include/boost/intrusive_ptr.hpp | 17 +++++++++++++++++ include/boost/scoped_array.hpp | 20 ++++++++++++++++++++ include/boost/scoped_ptr.hpp | 18 ++++++++++++++++++ include/boost/shared_array.hpp | 18 ++++++++++++++++++ include/boost/shared_ptr.hpp | 17 +++++++++++++++++ 5 files changed, 90 insertions(+) diff --git a/include/boost/intrusive_ptr.hpp b/include/boost/intrusive_ptr.hpp index 3b988a8..57e8c87 100644 --- a/include/boost/intrusive_ptr.hpp +++ b/include/boost/intrusive_ptr.hpp @@ -119,6 +119,21 @@ public: return p_; } +#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530) + + operator bool () const + { + return p_ != 0; + } + +private: + + operator int () const; + +public: + +#else + typedef T * (intrusive_ptr::*unspecified_bool_type) () const; operator unspecified_bool_type () const @@ -126,6 +141,8 @@ public: return p_ == 0? 0: &intrusive_ptr::get; } +#endif + // operator! is a Borland-specific workaround bool operator! () const { diff --git a/include/boost/scoped_array.hpp b/include/boost/scoped_array.hpp index abd75ad..fd770bc 100644 --- a/include/boost/scoped_array.hpp +++ b/include/boost/scoped_array.hpp @@ -15,6 +15,9 @@ #include #include #include // in case ptrdiff_t not in std + +#include + #include // for std::ptrdiff_t namespace boost @@ -83,6 +86,21 @@ public: // implicit conversion to "bool" +#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530) + + operator bool () const + { + return ptr != 0; + } + +private: + + operator int () const; + +public: + +#else + typedef T * (this_type::*unspecified_bool_type)() const; operator unspecified_bool_type() const // never throws @@ -90,6 +108,8 @@ public: return ptr == 0? 0: &this_type::get; } +#endif + bool operator! () const // never throws { return ptr == 0; diff --git a/include/boost/scoped_ptr.hpp b/include/boost/scoped_ptr.hpp index 19396a5..5c07ebd 100644 --- a/include/boost/scoped_ptr.hpp +++ b/include/boost/scoped_ptr.hpp @@ -14,6 +14,7 @@ #include #include +#include #ifndef BOOST_NO_AUTO_PTR # include // for std::auto_ptr @@ -102,6 +103,21 @@ public: // implicit conversion to "bool" +#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530) + + operator bool () const + { + return ptr != 0; + } + +private: + + operator int () const; + +public: + +#else + typedef T * (this_type::*unspecified_bool_type)() const; operator unspecified_bool_type() const // never throws @@ -109,6 +125,8 @@ public: return ptr == 0? 0: &this_type::get; } +#endif + bool operator! () const // never throws { return ptr == 0; diff --git a/include/boost/shared_array.hpp b/include/boost/shared_array.hpp index 992bdee..68420a2 100644 --- a/include/boost/shared_array.hpp +++ b/include/boost/shared_array.hpp @@ -25,6 +25,7 @@ #include #include +#include #include // for std::ptrdiff_t #include // for std::swap @@ -94,6 +95,21 @@ public: // implicit conversion to "bool" +#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530) + + operator bool () const + { + return px != 0; + } + +private: + + operator int () const; + +public: + +#else + typedef T * (this_type::*unspecified_bool_type)() const; operator unspecified_bool_type() const // never throws @@ -101,6 +117,8 @@ public: return px == 0? 0: &this_type::get; } +#endif + bool operator! () const // never throws { return px == 0; diff --git a/include/boost/shared_ptr.hpp b/include/boost/shared_ptr.hpp index e66373a..0040fb4 100644 --- a/include/boost/shared_ptr.hpp +++ b/include/boost/shared_ptr.hpp @@ -246,6 +246,21 @@ public: // implicit conversion to "bool" +#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530) + + operator bool () const + { + return px != 0; + } + +private: + + operator int () const; + +public: + +#else + typedef T * (this_type::*unspecified_bool_type)() const; operator unspecified_bool_type() const // never throws @@ -253,6 +268,8 @@ public: return px == 0? 0: &this_type::get; } +#endif + // operator! is redundant, but some compilers need it bool operator! () const // never throws