comparison DEPENDENCIES/generic/include/boost/smart_ptr/shared_ptr.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
14 // See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation. 14 // See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation.
15 // 15 //
16 16
17 #include <boost/config.hpp> // for broken compiler workarounds 17 #include <boost/config.hpp> // for broken compiler workarounds
18 18
19 #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
20 #include <boost/smart_ptr/detail/shared_ptr_nmt.hpp>
21 #else
22
23 // In order to avoid circular dependencies with Boost.TR1 19 // In order to avoid circular dependencies with Boost.TR1
24 // we make sure that our include of <memory> doesn't try to 20 // we make sure that our include of <memory> doesn't try to
25 // pull in the TR1 headers: that's why we use this header 21 // pull in the TR1 headers: that's why we use this header
26 // rather than including <memory> directly: 22 // rather than including <memory> directly:
27 #include <boost/config/no_tr1/memory.hpp> // std::auto_ptr 23 #include <boost/config/no_tr1/memory.hpp> // std::auto_ptr
34 #include <boost/smart_ptr/detail/sp_convertible.hpp> 30 #include <boost/smart_ptr/detail/sp_convertible.hpp>
35 #include <boost/smart_ptr/detail/sp_nullptr_t.hpp> 31 #include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
36 32
37 #if !defined(BOOST_SP_NO_ATOMIC_ACCESS) 33 #if !defined(BOOST_SP_NO_ATOMIC_ACCESS)
38 #include <boost/smart_ptr/detail/spinlock_pool.hpp> 34 #include <boost/smart_ptr/detail/spinlock_pool.hpp>
39 #include <boost/memory_order.hpp>
40 #endif 35 #endif
41 36
42 #include <algorithm> // for std::swap 37 #include <algorithm> // for std::swap
43 #include <functional> // for std::less 38 #include <functional> // for std::less
44 #include <typeinfo> // for std::bad_cast 39 #include <typeinfo> // for std::bad_cast
658 typename boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const 653 typename boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const
659 { 654 {
660 BOOST_ASSERT( px != 0 ); 655 BOOST_ASSERT( px != 0 );
661 BOOST_ASSERT( i >= 0 && ( i < boost::detail::sp_extent< T >::value || boost::detail::sp_extent< T >::value == 0 ) ); 656 BOOST_ASSERT( i >= 0 && ( i < boost::detail::sp_extent< T >::value || boost::detail::sp_extent< T >::value == 0 ) );
662 657
663 return px[ i ]; 658 return static_cast< typename boost::detail::sp_array_access< T >::type >( px[ i ] );
664 } 659 }
665 660
666 element_type * get() const BOOST_NOEXCEPT 661 element_type * get() const BOOST_NOEXCEPT
667 { 662 {
668 return px; 663 return px;
896 891
897 class esft2_deleter_wrapper 892 class esft2_deleter_wrapper
898 { 893 {
899 private: 894 private:
900 895
901 shared_ptr<void> deleter_; 896 shared_ptr<void const volatile> deleter_;
902 897
903 public: 898 public:
904 899
905 esft2_deleter_wrapper() 900 esft2_deleter_wrapper()
906 { 901 {
953 { 948 {
954 boost::detail::spinlock_pool<2>::scoped_lock lock( p ); 949 boost::detail::spinlock_pool<2>::scoped_lock lock( p );
955 return *p; 950 return *p;
956 } 951 }
957 952
958 template<class T> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, memory_order /*mo*/ ) 953 template<class T> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ int )
959 { 954 {
960 return atomic_load( p ); 955 return atomic_load( p );
961 } 956 }
962 957
963 template<class T> void atomic_store( shared_ptr<T> * p, shared_ptr<T> r ) 958 template<class T> void atomic_store( shared_ptr<T> * p, shared_ptr<T> r )
964 { 959 {
965 boost::detail::spinlock_pool<2>::scoped_lock lock( p ); 960 boost::detail::spinlock_pool<2>::scoped_lock lock( p );
966 p->swap( r ); 961 p->swap( r );
967 } 962 }
968 963
969 template<class T> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, memory_order /*mo*/ ) 964 template<class T> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int )
970 { 965 {
971 atomic_store( p, r ); // std::move( r ) 966 atomic_store( p, r ); // std::move( r )
972 } 967 }
973 968
974 template<class T> shared_ptr<T> atomic_exchange( shared_ptr<T> * p, shared_ptr<T> r ) 969 template<class T> shared_ptr<T> atomic_exchange( shared_ptr<T> * p, shared_ptr<T> r )
980 sp.unlock(); 975 sp.unlock();
981 976
982 return r; // return std::move( r ) 977 return r; // return std::move( r )
983 } 978 }
984 979
985 template<class T> shared_ptr<T> atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, memory_order /*mo*/ ) 980 template<class T> shared_ptr<T> atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int )
986 { 981 {
987 return atomic_exchange( p, r ); // std::move( r ) 982 return atomic_exchange( p, r ); // std::move( r )
988 } 983 }
989 984
990 template<class T> bool atomic_compare_exchange( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w ) 985 template<class T> bool atomic_compare_exchange( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w )
1010 tmp.swap( *v ); 1005 tmp.swap( *v );
1011 return false; 1006 return false;
1012 } 1007 }
1013 } 1008 }
1014 1009
1015 template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, memory_order /*success*/, memory_order /*failure*/ ) 1010 template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ int, /*memory_order failure*/ int )
1016 { 1011 {
1017 return atomic_compare_exchange( p, v, w ); // std::move( w ) 1012 return atomic_compare_exchange( p, v, w ); // std::move( w )
1018 } 1013 }
1019 1014
1020 #endif // !defined(BOOST_SP_NO_ATOMIC_ACCESS) 1015 #endif // !defined(BOOST_SP_NO_ATOMIC_ACCESS)
1028 return boost::hash< T* >()( p.get() ); 1023 return boost::hash< T* >()( p.get() );
1029 } 1024 }
1030 1025
1031 } // namespace boost 1026 } // namespace boost
1032 1027
1033 #endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
1034
1035 #endif // #ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED 1028 #endif // #ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED