Full merge from trunk at revision 41356 of entire boost-root tree.

[SVN r41369]
This commit is contained in:
Beman Dawes
2007-11-25 18:07:19 +00:00
parent 5ab6b24856
commit d2194e3b24
4 changed files with 94 additions and 16 deletions

View File

@ -105,6 +105,11 @@ public:
return *this;
}
void reset( T * rhs )
{
this_type( rhs ).swap( *this );
}
T * get() const
{
return p_;
@ -112,11 +117,13 @@ public:
T & operator*() const
{
BOOST_ASSERT( p_ != 0 );
return *p_;
}
T * operator->() const
{
BOOST_ASSERT( p_ != 0 );
return p_;
}

View File

@ -103,7 +103,23 @@ public:
return px != 0;
}
#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
#elif defined( _MANAGED )
static void unspecified_bool( this_type*** )
{
}
typedef void (*unspecified_bool_type)( this_type*** );
operator unspecified_bool_type() const // never throws
{
return px == 0? 0: unspecified_bool;
}
#elif \
( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) )
typedef T * (this_type::*unspecified_bool_type)() const;
operator unspecified_bool_type() const // never throws

View File

@ -5,7 +5,7 @@
// shared_ptr.hpp
//
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
// Copyright (c) 2001-2006 Peter Dimov
// Copyright (c) 2001-2007 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@ -88,6 +88,21 @@ template<class T, class Y> void sp_enable_shared_from_this( shared_count const &
if(pe != 0) pe->_internal_weak_this._internal_assign(const_cast<Y*>(px), pn);
}
#ifdef _MANAGED
// Avoid C4793, ... causes native code generation
struct sp_any_pointer
{
template<class T> sp_any_pointer( T* ) {}
};
inline void sp_enable_shared_from_this( shared_count const & /*pn*/, sp_any_pointer, sp_any_pointer )
{
}
#else // _MANAGED
#ifdef sgi
// Turn off: the last argument of the varargs function "sp_enable_shared_from_this" is unnamed
# pragma set woff 3506
@ -101,6 +116,8 @@ inline void sp_enable_shared_from_this( shared_count const & /*pn*/, ... )
# pragma reset woff 3506
#endif
#endif // _MANAGED
#if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( BOOST_NO_AUTO_PTR )
// rvalue auto_ptr support based on a technique by Dave Abrahams
@ -195,6 +212,12 @@ public:
{
}
// aliasing
template< class Y >
shared_ptr( shared_ptr<Y> const & r, T * p ): px( p ), pn( r.pn ) // never throws
{
}
template<class Y>
shared_ptr(shared_ptr<Y> const & r, boost::detail::static_cast_tag): px(static_cast<element_type *>(r.px)), pn(r.pn)
{
@ -236,7 +259,7 @@ public:
#if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
template<class Ap>
explicit shared_ptr( Ap r, typename boost::detail::sp_enable_if_auto_ptr<Ap, int>::type = 0 ): px( r.get() ), pn()
shared_ptr( Ap r, typename boost::detail::sp_enable_if_auto_ptr<Ap, int>::type = 0 ): px( r.get() ), pn()
{
typename Ap::element_type * tmp = r.get();
pn = boost::detail::shared_count( r );
@ -283,6 +306,38 @@ public:
#endif // BOOST_NO_AUTO_PTR
// Move support
#if defined( BOOST_HAS_RVALUE_REFS )
shared_ptr( shared_ptr && r ): px( r.px ), pn() // never throws
{
pn.swap( r.pn );
r.px = 0;
}
template<class Y>
shared_ptr( shared_ptr<Y> && r ): px( r.px ), pn() // never throws
{
pn.swap( r.pn );
r.px = 0;
}
shared_ptr & operator=( shared_ptr && r ) // never throws
{
this_type( static_cast< shared_ptr && >( r ) ).swap( *this );
return *this;
}
template<class Y>
shared_ptr & operator=( shared_ptr<Y> && r ) // never throws
{
this_type( static_cast< shared_ptr<Y> && >( r ) ).swap( *this );
return *this;
}
#endif
void reset() // never throws in 1.30+
{
this_type().swap(*this);
@ -304,6 +359,11 @@ public:
this_type( p, d, a ).swap( *this );
}
template<class Y> void reset( shared_ptr<Y> const & r, T * p )
{
this_type( r, p ).swap( *this );
}
reference operator* () const // never throws
{
BOOST_ASSERT(px != 0);
@ -323,7 +383,7 @@ public:
// implicit conversion to "bool"
#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x580)
#if ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__)
operator bool () const
{
@ -345,7 +405,8 @@ public:
#elif \
( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) )
( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \
( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
typedef T * (this_type::*unspecified_bool_type)() const;
@ -393,9 +454,9 @@ public:
return pn < rhs.pn;
}
void * _internal_get_deleter(std::type_info const & ti) const
void * _internal_get_deleter( detail::sp_typeinfo const & ti ) const
{
return pn.get_deleter(ti);
return pn.get_deleter( ti );
}
// Tasteless as this may seem, making all members public allows member templates
@ -523,7 +584,7 @@ template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::
#endif // __GNUC__ < 3
// get_deleter (experimental)
// get_deleter
#if ( defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) ) || \
( defined(__EDG_VERSION__) && BOOST_WORKAROUND(__EDG_VERSION__, <= 238) ) || \
@ -534,7 +595,7 @@ template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::
template<class D, class T> D * get_deleter(shared_ptr<T> const & p)
{
void const * q = p._internal_get_deleter(typeid(D));
void const * q = p._internal_get_deleter(BOOST_SP_TYPEID(D));
return const_cast<D *>(static_cast<D const *>(q));
}
@ -542,7 +603,7 @@ template<class D, class T> D * get_deleter(shared_ptr<T> const & p)
template<class D, class T> D * get_deleter(shared_ptr<T> const & p)
{
return static_cast<D *>(p._internal_get_deleter(typeid(D)));
return static_cast<D *>(p._internal_get_deleter(BOOST_SP_TYPEID(D)));
}
#endif

View File

@ -179,12 +179,6 @@ template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b)
a.swap(b);
}
// deprecated, provided for backward compatibility
template<class T> shared_ptr<T> make_shared(weak_ptr<T> const & r)
{
return r.lock();
}
} // namespace boost
#ifdef BOOST_MSVC