Add copy constructor/assignment - in C++0x, move disables implicit copy.

[SVN r73202]
This commit is contained in:
Peter Dimov
2011-07-17 20:35:44 +00:00
parent b4b415553c
commit 7e9664396a
3 changed files with 47 additions and 3 deletions

View File

@ -69,7 +69,25 @@ public:
{
}
// generated copy constructor, assignment, destructor are fine
// generated copy constructor, destructor are fine...
#if defined( BOOST_HAS_RVALUE_REFS )
// ... except in C++0x, move disables the implicit copy
shared_array( shared_array const & r ): px( r.px ), pn( r.pn ) // never throws
{
}
#endif
// assignment
shared_array & operator=( shared_array const & r ) // never throws
{
this_type( r ).swap( *this );
return *this;
}
void reset(T * p = 0)
{

View File

@ -197,7 +197,17 @@ public:
boost::detail::sp_enable_shared_from_this( this, p, p );
}
// generated copy constructor, destructor are fine
// generated copy constructor, destructor are fine...
#if defined( BOOST_HAS_RVALUE_REFS )
// ... except in C++0x, move disables the implicit copy
shared_ptr( shared_ptr const & r ): px( r.px ), pn( r.pn ) // never throws
{
}
#endif
template<class Y>
explicit shared_ptr(weak_ptr<Y> const & r): pn(r.pn) // may throw

View File

@ -40,8 +40,24 @@ public:
{
}
// generated copy constructor, assignment, destructor are fine
// generated copy constructor, assignment, destructor are fine...
#if defined( BOOST_HAS_RVALUE_REFS )
// ... except in C++0x, move disables the implicit copy
weak_ptr( weak_ptr const & r ): px( r.px ), pn( r.pn ) // never throws
{
}
weak_ptr & operator=( weak_ptr const & r ) // never throws
{
px = r.px;
pn = r.pn;
return *this;
}
#endif
//
// The "obvious" converting constructor implementation: