forked from boostorg/smart_ptr
New smart pointer documentation. Related clean-up of the smart pointer
library. Changing includes to include the new individual smart pointer headers. Replacing old smart pointer library with an include of the new smart pointer headers. Simplify ifdefs that involve the member templates macros now that BOOST_MSVC6_MEMBER_TEMPLATES is also guaranteed to bet set for platforms that have full member templates. [SVN r12647]
This commit is contained in:
1 parent
d3c76575f9
commit
1a7cd887e4
21 files changed
+1367
-1425
No files matched your search
@@ -35,49 +35,49 @@ public:
|
||||
|
||||
typedef T element_type;
|
||||
|
||||
explicit scoped_array( T* p = 0 ): ptr(p) // never throws
|
||||
explicit scoped_array(T * p = 0) : ptr(p) // never throws
|
||||
{
|
||||
}
|
||||
|
||||
~scoped_array()
|
||||
~scoped_array() // never throws
|
||||
{
|
||||
typedef char type_must_be_complete[sizeof(T)];
|
||||
delete [] ptr;
|
||||
}
|
||||
|
||||
void reset( T* p = 0 )
|
||||
void reset(T * p = 0) // never throws
|
||||
{
|
||||
typedef char type_must_be_complete[sizeof(T)];
|
||||
|
||||
if ( ptr != p )
|
||||
if (ptr != p)
|
||||
{
|
||||
delete [] ptr;
|
||||
ptr = p;
|
||||
}
|
||||
}
|
||||
|
||||
T& operator[](std::ptrdiff_t i) const // never throws
|
||||
T& operator[](std::ptrdiff_t i) const // never throws
|
||||
{
|
||||
BOOST_ASSERT(ptr != 0);
|
||||
BOOST_ASSERT(i >= 0);
|
||||
return ptr[i];
|
||||
}
|
||||
|
||||
T* get() const // never throws
|
||||
T* get() const // never throws
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void swap(scoped_array & rhs)
|
||||
void swap(scoped_array & b) // never throws
|
||||
{
|
||||
T * tmp = rhs.ptr;
|
||||
rhs.ptr = ptr;
|
||||
T * tmp = b.ptr;
|
||||
b.ptr = ptr;
|
||||
ptr = tmp;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b)
|
||||
template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) // never throws
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user