From a4f853bfbc4b035701947ccf15b36f3a0cb691da Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 7 Dec 2013 19:25:05 +0200 Subject: [PATCH] Revert "SmartPtr: Remove obsolete MSVC version checks." This reverts commit 7d1c527ac010fa1e443ee8c63065b208fe9fb05d. --- include/boost/smart_ptr/detail/shared_count.hpp | 7 +++++++ .../boost/smart_ptr/detail/sp_counted_base_w32.hpp | 12 ++++++++++++ include/boost/smart_ptr/detail/spinlock_w32.hpp | 2 +- include/boost/smart_ptr/detail/yield_k.hpp | 2 +- include/boost/smart_ptr/intrusive_ptr.hpp | 6 ++++++ include/boost/smart_ptr/shared_ptr.hpp | 6 ++++++ include/boost/smart_ptr/weak_ptr.hpp | 4 ++++ 7 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/boost/smart_ptr/detail/shared_count.hpp b/include/boost/smart_ptr/detail/shared_count.hpp index 2b48cec..8e1dd48 100644 --- a/include/boost/smart_ptr/detail/shared_count.hpp +++ b/include/boost/smart_ptr/detail/shared_count.hpp @@ -148,11 +148,18 @@ public: #endif } +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) + template shared_count( Y * p, D d ): pi_(0) +#else template shared_count( P p, D d ): pi_(0) +#endif #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) , id_(shared_count_id) #endif { +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) + typedef Y* P; +#endif #ifndef BOOST_NO_EXCEPTIONS try diff --git a/include/boost/smart_ptr/detail/sp_counted_base_w32.hpp b/include/boost/smart_ptr/detail/sp_counted_base_w32.hpp index 109deb5..ff394dc 100644 --- a/include/boost/smart_ptr/detail/sp_counted_base_w32.hpp +++ b/include/boost/smart_ptr/detail/sp_counted_base_w32.hpp @@ -80,7 +80,19 @@ public: { long tmp = static_cast< long const volatile& >( use_count_ ); if( tmp == 0 ) return false; + +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1200 ) + + // work around a code generation bug + + long tmp2 = tmp + 1; + if( BOOST_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp2, tmp ) == tmp2 - 1 ) return true; + +#else + if( BOOST_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp + 1, tmp ) == tmp ) return true; + +#endif } } diff --git a/include/boost/smart_ptr/detail/spinlock_w32.hpp b/include/boost/smart_ptr/detail/spinlock_w32.hpp index 57c85e1..fb97629 100644 --- a/include/boost/smart_ptr/detail/spinlock_w32.hpp +++ b/include/boost/smart_ptr/detail/spinlock_w32.hpp @@ -24,7 +24,7 @@ #define BOOST_COMPILER_FENCE __memory_barrier(); -#elif defined( _MSC_VER ) +#elif defined( _MSC_VER ) && _MSC_VER >= 1310 extern "C" void _ReadWriteBarrier(); #pragma intrinsic( _ReadWriteBarrier ) diff --git a/include/boost/smart_ptr/detail/yield_k.hpp b/include/boost/smart_ptr/detail/yield_k.hpp index 686d1f0..14af524 100644 --- a/include/boost/smart_ptr/detail/yield_k.hpp +++ b/include/boost/smart_ptr/detail/yield_k.hpp @@ -27,7 +27,7 @@ // BOOST_SMT_PAUSE -#if defined(_MSC_VER) && ( defined(_M_IX86) || defined(_M_X64) ) +#if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) ) extern "C" void _mm_pause(); diff --git a/include/boost/smart_ptr/intrusive_ptr.hpp b/include/boost/smart_ptr/intrusive_ptr.hpp index 3cd3dc7..b6f5bcd 100644 --- a/include/boost/smart_ptr/intrusive_ptr.hpp +++ b/include/boost/smart_ptr/intrusive_ptr.hpp @@ -292,7 +292,13 @@ template std::ostream & operator<< (std::ostream & os, intrusive_ptr // in STLport's no-iostreams mode no iostream symbols can be used #ifndef _STLP_NO_IOSTREAMS +# if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300 && __SGI_STL_PORT) +// MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL +using std::basic_ostream; +template basic_ostream & operator<< (basic_ostream & os, intrusive_ptr const & p) +# else template std::basic_ostream & operator<< (std::basic_ostream & os, intrusive_ptr const & p) +# endif { os << p.get(); return os; diff --git a/include/boost/smart_ptr/shared_ptr.hpp b/include/boost/smart_ptr/shared_ptr.hpp index 106e349..9259ca0 100644 --- a/include/boost/smart_ptr/shared_ptr.hpp +++ b/include/boost/smart_ptr/shared_ptr.hpp @@ -849,7 +849,13 @@ template std::ostream & operator<< (std::ostream & os, shared_ptr co // in STLport's no-iostreams mode no iostream symbols can be used #ifndef _STLP_NO_IOSTREAMS +# if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300 && __SGI_STL_PORT) +// MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL +using std::basic_ostream; +template basic_ostream & operator<< (basic_ostream & os, shared_ptr const & p) +# else template std::basic_ostream & operator<< (std::basic_ostream & os, shared_ptr const & p) +# endif { os << p.get(); return os; diff --git a/include/boost/smart_ptr/weak_ptr.hpp b/include/boost/smart_ptr/weak_ptr.hpp index cc0cdca..e3e9ad9 100644 --- a/include/boost/smart_ptr/weak_ptr.hpp +++ b/include/boost/smart_ptr/weak_ptr.hpp @@ -136,6 +136,8 @@ public: boost::detail::sp_assert_convertible< Y, T >(); } +#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300) + template weak_ptr & operator=( weak_ptr const & r ) BOOST_NOEXCEPT { @@ -169,6 +171,8 @@ public: return *this; } +#endif + shared_ptr lock() const BOOST_NOEXCEPT { return shared_ptr( *this, boost::detail::sp_nothrow_tag() );