summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/Boost/src/boost/smart_ptr/shared_array.hpp')
-rw-r--r--3rdParty/Boost/src/boost/smart_ptr/shared_array.hpp169
1 files changed, 143 insertions, 26 deletions
diff --git a/3rdParty/Boost/src/boost/smart_ptr/shared_array.hpp b/3rdParty/Boost/src/boost/smart_ptr/shared_array.hpp
index 36799e6..fd58071 100644
--- a/3rdParty/Boost/src/boost/smart_ptr/shared_array.hpp
+++ b/3rdParty/Boost/src/boost/smart_ptr/shared_array.hpp
@@ -5,7 +5,7 @@
// shared_array.hpp
//
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
-// Copyright (c) 2001, 2002 Peter Dimov
+// Copyright (c) 2001, 2002, 2012 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -16,16 +16,14 @@
#include <boost/config.hpp> // for broken compiler workarounds
-#if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
-#include <boost/smart_ptr/detail/shared_array_nmt.hpp>
-#else
-
#include <memory> // TR1 cyclic inclusion fix
#include <boost/assert.hpp>
#include <boost/checked_delete.hpp>
+#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/shared_count.hpp>
+#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/detail/workaround.hpp>
#include <cstddef> // for std::ptrdiff_t
@@ -55,8 +53,22 @@ public:
typedef T element_type;
- explicit shared_array(T * p = 0): px(p), pn(p, deleter())
+ shared_array() BOOST_NOEXCEPT : px( 0 ), pn()
+ {
+ }
+
+#if !defined( BOOST_NO_CXX11_NULLPTR )
+
+ shared_array( boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT : px( 0 ), pn()
+ {
+ }
+
+#endif
+
+ template<class Y>
+ explicit shared_array( Y * p ): px( p ), pn( p, checked_array_deleter<Y>() )
{
+ boost::detail::sp_assert_convertible< Y[], T[] >();
}
//
@@ -65,49 +77,130 @@ public:
// shared_array will release p by calling d(p)
//
- template<class D> shared_array(T * p, D d): px(p), pn(p, d)
+ template<class Y, class D> shared_array( Y * p, D d ): px( p ), pn( p, d )
+ {
+ boost::detail::sp_assert_convertible< Y[], T[] >();
+ }
+
+ // As above, but with allocator. A's copy constructor shall not throw.
+
+ template<class Y, class D, class A> shared_array( Y * p, D d, A a ): px( p ), pn( p, d, a )
{
+ boost::detail::sp_assert_convertible< Y[], T[] >();
}
// generated copy constructor, destructor are fine...
-#if defined( BOOST_HAS_RVALUE_REFS )
+#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
// ... except in C++0x, move disables the implicit copy
- shared_array( shared_array const & r ): px( r.px ), pn( r.pn ) // never throws
+ shared_array( shared_array const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
{
}
+ shared_array( shared_array && r ) BOOST_NOEXCEPT : px( r.px ), pn()
+ {
+ pn.swap( r.pn );
+ r.px = 0;
+ }
+
#endif
+ // conversion
+
+ template<class Y>
+#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
+
+ shared_array( shared_array<Y> const & r, typename boost::detail::sp_enable_if_convertible< Y[], T[] >::type = boost::detail::sp_empty() )
+
+#else
+
+ shared_array( shared_array<Y> const & r )
+
+#endif
+ BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) // never throws
+ {
+ boost::detail::sp_assert_convertible< Y[], T[] >();
+ }
+
+ // aliasing
+
+ template< class Y >
+ shared_array( shared_array<Y> const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn )
+ {
+ }
+
// assignment
- shared_array & operator=( shared_array const & r ) // never throws
+ shared_array & operator=( shared_array const & r ) BOOST_NOEXCEPT
{
this_type( r ).swap( *this );
return *this;
}
- void reset(T * p = 0)
+#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400)
+
+ template<class Y>
+ shared_array & operator=( shared_array<Y> const & r ) BOOST_NOEXCEPT
{
- BOOST_ASSERT(p == 0 || p != px);
- this_type(p).swap(*this);
+ this_type( r ).swap( *this );
+ return *this;
}
- template <class D> void reset(T * p, D d)
+#endif
+
+#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
+
+ shared_array & operator=( shared_array && r ) BOOST_NOEXCEPT
{
- this_type(p, d).swap(*this);
+ this_type( static_cast< shared_array && >( r ) ).swap( *this );
+ return *this;
}
- T & operator[] (std::ptrdiff_t i) const // never throws
+ template<class Y>
+ shared_array & operator=( shared_array<Y> && r ) BOOST_NOEXCEPT
+ {
+ this_type( static_cast< shared_array<Y> && >( r ) ).swap( *this );
+ return *this;
+ }
+
+#endif
+
+ void reset() BOOST_NOEXCEPT
+ {
+ this_type().swap( *this );
+ }
+
+ template<class Y> void reset( Y * p ) // Y must be complete
+ {
+ BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors
+ this_type( p ).swap( *this );
+ }
+
+ template<class Y, class D> void reset( Y * p, D d )
+ {
+ this_type( p, d ).swap( *this );
+ }
+
+ template<class Y, class D, class A> void reset( Y * p, D d, A a )
+ {
+ this_type( p, d, a ).swap( *this );
+ }
+
+ template<class Y> void reset( shared_array<Y> const & r, element_type * p )
+ {
+ this_type( r, p ).swap( *this );
+ }
+
+ T & operator[] (std::ptrdiff_t i) const // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
{
BOOST_ASSERT(px != 0);
BOOST_ASSERT(i >= 0);
return px[i];
}
- T * get() const // never throws
+ T * get() const BOOST_NOEXCEPT
{
return px;
}
@@ -115,17 +208,17 @@ public:
// implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp>
- bool unique() const // never throws
+ bool unique() const BOOST_NOEXCEPT
{
return pn.unique();
}
- long use_count() const // never throws
+ long use_count() const BOOST_NOEXCEPT
{
return pn.use_count();
}
- void swap(shared_array<T> & other) // never throws
+ void swap(shared_array<T> & other) BOOST_NOEXCEPT
{
std::swap(px, other.px);
pn.swap(other.pn);
@@ -138,27 +231,53 @@ public:
private:
+ template<class Y> friend class shared_array;
+
T * px; // contained pointer
detail::shared_count pn; // reference counter
}; // shared_array
-template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) // never throws
+template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT
{
return a.get() == b.get();
}
-template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) // never throws
+template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT
{
return a.get() != b.get();
}
-template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) // never throws
+#if !defined( BOOST_NO_CXX11_NULLPTR )
+
+template<class T> inline bool operator==( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
+{
+ return p.get() == 0;
+}
+
+template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_NOEXCEPT
+{
+ return p.get() == 0;
+}
+
+template<class T> inline bool operator!=( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
+{
+ return p.get() != 0;
+}
+
+template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_NOEXCEPT
+{
+ return p.get() != 0;
+}
+
+#endif
+
+template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT
{
return std::less<T*>()(a.get(), b.get());
}
-template<class T> void swap(shared_array<T> & a, shared_array<T> & b) // never throws
+template<class T> void swap(shared_array<T> & a, shared_array<T> & b) BOOST_NOEXCEPT
{
a.swap(b);
}
@@ -170,6 +289,4 @@ template< class D, class T > D * get_deleter( shared_array<T> const & p )
} // namespace boost
-#endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
-
#endif // #ifndef BOOST_SMART_PTR_SHARED_ARRAY_HPP_INCLUDED