From 5f69684c8fffb0c89266b1219bda26f1885deef5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 7 Dec 2013 19:21:06 +0200 Subject: [PATCH] Revert "SmartPointer: Remove obsolete GCC version checks." This reverts commit 0e6ddb843ed343796fdc5250a25064264ba2f6a7. --- .../boost/smart_ptr/detail/sp_convertible.hpp | 4 +++ include/boost/smart_ptr/intrusive_ptr.hpp | 23 +++++++++++++++ include/boost/smart_ptr/shared_ptr.hpp | 29 +++++++++++++++++-- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/include/boost/smart_ptr/detail/sp_convertible.hpp b/include/boost/smart_ptr/detail/sp_convertible.hpp index 868eba6..00d0b53 100644 --- a/include/boost/smart_ptr/detail/sp_convertible.hpp +++ b/include/boost/smart_ptr/detail/sp_convertible.hpp @@ -21,6 +21,10 @@ # define BOOST_SP_NO_SP_CONVERTIBLE #endif +#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ < 303 ) +# define BOOST_SP_NO_SP_CONVERTIBLE +#endif + #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x630 ) # define BOOST_SP_NO_SP_CONVERTIBLE #endif diff --git a/include/boost/smart_ptr/intrusive_ptr.hpp b/include/boost/smart_ptr/intrusive_ptr.hpp index a855a10..43930a3 100644 --- a/include/boost/smart_ptr/intrusive_ptr.hpp +++ b/include/boost/smart_ptr/intrusive_ptr.hpp @@ -208,6 +208,17 @@ template inline bool operator!=(T * a, intrusive_ptr const return a != b.get(); } +#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 + +// Resolve the ambiguity between our op!= and the one in rel_ops + +template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b) +{ + return a.get() != b.get(); +} + +#endif + #if !defined( BOOST_NO_CXX11_NULLPTR ) template inline bool operator==( intrusive_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT @@ -268,6 +279,16 @@ template intrusive_ptr dynamic_pointer_cast(intrusive_ptr std::ostream & operator<< (std::ostream & os, intrusive_ptr const & p) +{ + os << p.get(); + return os; +} + +#else + // in STLport's no-iostreams mode no iostream symbols can be used #ifndef _STLP_NO_IOSTREAMS @@ -279,6 +300,8 @@ template std::basic_ostream & operator<< (std:: #endif // _STLP_NO_IOSTREAMS +#endif // __GNUC__ < 3 + #endif // !defined(BOOST_NO_IOSTREAM) // hash_value diff --git a/include/boost/smart_ptr/shared_ptr.hpp b/include/boost/smart_ptr/shared_ptr.hpp index a06d9e7..22816df 100644 --- a/include/boost/smart_ptr/shared_ptr.hpp +++ b/include/boost/smart_ptr/shared_ptr.hpp @@ -740,6 +740,17 @@ template inline bool operator!=(shared_ptr const & a, share return a.get() != b.get(); } +#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 + +// Resolve the ambiguity between our op!= and the one in rel_ops + +template inline bool operator!=(shared_ptr const & a, shared_ptr const & b) BOOST_NOEXCEPT +{ + return a.get() != b.get(); +} + +#endif + #if !defined( BOOST_NO_CXX11_NULLPTR ) template inline bool operator==( shared_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT @@ -825,6 +836,16 @@ template inline typename shared_ptr::element_type * get_pointer(shar #if !defined(BOOST_NO_IOSTREAM) +#if ( defined(__GNUC__) && (__GNUC__ < 3) ) + +template std::ostream & operator<< (std::ostream & os, shared_ptr const & p) +{ + os << p.get(); + return os; +} + +#else + // in STLport's no-iostreams mode no iostream symbols can be used #ifndef _STLP_NO_IOSTREAMS @@ -836,6 +857,8 @@ template std::basic_ostream & operator<< (std:: #endif // _STLP_NO_IOSTREAMS +#endif // __GNUC__ < 3 + #endif // !defined(BOOST_NO_IOSTREAM) // get_deleter @@ -843,10 +866,12 @@ template std::basic_ostream & operator<< (std:: namespace detail { -#if ( defined(__EDG_VERSION__) && BOOST_WORKAROUND(__EDG_VERSION__, <= 238) ) || \ +#if ( defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) ) || \ + ( defined(__EDG_VERSION__) && BOOST_WORKAROUND(__EDG_VERSION__, <= 238) ) || \ ( defined(__HP_aCC) && BOOST_WORKAROUND(__HP_aCC, <= 33500) ) -// EDG 2.38 and HP aCC A.03.35 don't allow static_cast(void *) +// g++ 2.9x doesn't allow static_cast(void *) +// apparently EDG 2.38 and HP aCC A.03.35 also don't accept it template D * basic_get_deleter(shared_ptr const & p) {