|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51518 - in trunk/boost/smart_ptr: . detail
From: pdimov_at_[hidden]
Date: 2009-03-01 13:42:45
Author: pdimov
Date: 2009-03-01 13:42:44 EST (Sun, 01 Mar 2009)
New Revision: 51518
URL: http://svn.boost.org/trac/boost/changeset/51518
Log:
Refs #2814 (fixed in trunk.)
Added:
trunk/boost/smart_ptr/detail/operator_bool.hpp (contents, props changed)
Text files modified:
trunk/boost/smart_ptr/intrusive_ptr.hpp | 67 +++++++++++----------------------------
trunk/boost/smart_ptr/scoped_array.hpp | 61 ++++++++---------------------------
trunk/boost/smart_ptr/scoped_ptr.hpp | 65 ++++++++++----------------------------
trunk/boost/smart_ptr/shared_array.hpp | 50 +----------------------------
trunk/boost/smart_ptr/shared_ptr.hpp | 53 +------------------------------
5 files changed, 56 insertions(+), 240 deletions(-)
Added: trunk/boost/smart_ptr/detail/operator_bool.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/smart_ptr/detail/operator_bool.hpp 2009-03-01 13:42:44 EST (Sun, 01 Mar 2009)
@@ -0,0 +1,56 @@
+// This header intentionally has no include guards.
+//
+// Copyright (c) 2001-2009 Peter Dimov
+//
+// Distributed under the Boost Software License, Version 1.0.
+// See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt
+
+#if ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__)
+
+ operator bool () const
+ {
+ return px != 0;
+ }
+
+#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) ) || \
+ ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
+
+ typedef T * (this_type::*unspecified_bool_type)() const;
+
+ operator unspecified_bool_type() const // never throws
+ {
+ return px == 0? 0: &this_type::get;
+ }
+
+#else
+
+ typedef T * this_type::*unspecified_bool_type;
+
+ operator unspecified_bool_type() const // never throws
+ {
+ return px == 0? 0: &this_type::px;
+ }
+
+#endif
+
+ // operator! is redundant, but some compilers need it
+ bool operator! () const // never throws
+ {
+ return px == 0;
+ }
Modified: trunk/boost/smart_ptr/intrusive_ptr.hpp
==============================================================================
--- trunk/boost/smart_ptr/intrusive_ptr.hpp (original)
+++ trunk/boost/smart_ptr/intrusive_ptr.hpp 2009-03-01 13:42:44 EST (Sun, 01 Mar 2009)
@@ -63,13 +63,13 @@
typedef T element_type;
- intrusive_ptr(): p_(0)
+ intrusive_ptr(): px( 0 )
{
}
- intrusive_ptr(T * p, bool add_ref = true): p_(p)
+ intrusive_ptr( T * p, bool add_ref = true ): px( p )
{
- if(p_ != 0 && add_ref) intrusive_ptr_add_ref(p_);
+ if( px != 0 && add_ref ) intrusive_ptr_add_ref( px );
}
#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES)
@@ -84,21 +84,21 @@
intrusive_ptr( intrusive_ptr<U> const & rhs )
#endif
- : p_( rhs.get() )
+ : px( rhs.get() )
{
- if( p_ != 0 ) intrusive_ptr_add_ref( p_ );
+ if( px != 0 ) intrusive_ptr_add_ref( px );
}
#endif
- intrusive_ptr(intrusive_ptr const & rhs): p_(rhs.p_)
+ intrusive_ptr(intrusive_ptr const & rhs): px( rhs.px )
{
- if(p_ != 0) intrusive_ptr_add_ref(p_);
+ if( px != 0 ) intrusive_ptr_add_ref( px );
}
~intrusive_ptr()
{
- if(p_ != 0) intrusive_ptr_release(p_);
+ if( px != 0 ) intrusive_ptr_release( px );
}
#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES)
@@ -135,63 +135,34 @@
T * get() const
{
- return p_;
+ return px;
}
T & operator*() const
{
- BOOST_ASSERT( p_ != 0 );
- return *p_;
+ BOOST_ASSERT( px != 0 );
+ return *px;
}
T * operator->() const
{
- BOOST_ASSERT( p_ != 0 );
- return p_;
+ BOOST_ASSERT( px != 0 );
+ return px;
}
-#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530)
-
- operator bool () const
- {
- return p_ != 0;
- }
-
-#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
- typedef T * (this_type::*unspecified_bool_type)() const;
-
- operator unspecified_bool_type() const // never throws
- {
- return p_ == 0? 0: &this_type::get;
- }
-
-#else
-
- typedef T * this_type::*unspecified_bool_type;
-
- operator unspecified_bool_type () const
- {
- return p_ == 0? 0: &this_type::p_;
- }
-
-#endif
-
- // operator! is a Borland-specific workaround
- bool operator! () const
- {
- return p_ == 0;
- }
+// implicit conversion to "bool"
+#include <boost/smart_ptr/detail/operator_bool.hpp>
void swap(intrusive_ptr & rhs)
{
- T * tmp = p_;
- p_ = rhs.p_;
- rhs.p_ = tmp;
+ T * tmp = px;
+ px = rhs.px;
+ rhs.px = tmp;
}
private:
- T * p_;
+ T * px;
};
template<class T, class U> inline bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b)
Modified: trunk/boost/smart_ptr/scoped_array.hpp
==============================================================================
--- trunk/boost/smart_ptr/scoped_array.hpp (original)
+++ trunk/boost/smart_ptr/scoped_array.hpp 2009-03-01 13:42:44 EST (Sun, 01 Mar 2009)
@@ -39,7 +39,7 @@
{
private:
- T * ptr;
+ T * px;
scoped_array(scoped_array const &);
scoped_array & operator=(scoped_array const &);
@@ -53,79 +53,48 @@
typedef T element_type;
- explicit scoped_array(T * p = 0) : ptr(p) // never throws
+ explicit scoped_array( T * p = 0 ) : px( p ) // never throws
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- boost::sp_array_constructor_hook(ptr);
+ boost::sp_array_constructor_hook( px );
#endif
}
~scoped_array() // never throws
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- boost::sp_array_destructor_hook(ptr);
+ boost::sp_array_destructor_hook( px );
#endif
- boost::checked_array_delete(ptr);
+ boost::checked_array_delete( px );
}
void reset(T * p = 0) // never throws
{
- BOOST_ASSERT(p == 0 || p != ptr); // catch self-reset errors
+ BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors
this_type(p).swap(*this);
}
T & operator[](std::ptrdiff_t i) const // never throws
{
- BOOST_ASSERT(ptr != 0);
- BOOST_ASSERT(i >= 0);
- return ptr[i];
+ BOOST_ASSERT( px != 0 );
+ BOOST_ASSERT( i >= 0 );
+ return px[i];
}
T * get() const // never throws
{
- return ptr;
+ return px;
}
- // implicit conversion to "bool"
-
-#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530)
-
- operator bool () const
- {
- return ptr != 0;
- }
-
-#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
- typedef T * (this_type::*unspecified_bool_type)() const;
-
- operator unspecified_bool_type() const // never throws
- {
- return ptr == 0? 0: &this_type::get;
- }
-
-#else
-
- typedef T * this_type::*unspecified_bool_type;
-
- operator unspecified_bool_type() const // never throws
- {
- return ptr == 0? 0: &this_type::ptr;
- }
-
-#endif
-
- bool operator! () const // never throws
- {
- return ptr == 0;
- }
+// implicit conversion to "bool"
+#include <boost/smart_ptr/detail/operator_bool.hpp>
void swap(scoped_array & b) // never throws
{
- T * tmp = b.ptr;
- b.ptr = ptr;
- ptr = tmp;
+ T * tmp = b.px;
+ b.px = px;
+ px = tmp;
}
-
};
template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) // never throws
Modified: trunk/boost/smart_ptr/scoped_ptr.hpp
==============================================================================
--- trunk/boost/smart_ptr/scoped_ptr.hpp (original)
+++ trunk/boost/smart_ptr/scoped_ptr.hpp 2009-03-01 13:42:44 EST (Sun, 01 Mar 2009)
@@ -40,7 +40,7 @@
{
private:
- T * ptr;
+ T * px;
scoped_ptr(scoped_ptr const &);
scoped_ptr & operator=(scoped_ptr const &);
@@ -54,19 +54,19 @@
typedef T element_type;
- explicit scoped_ptr(T * p = 0): ptr(p) // never throws
+ explicit scoped_ptr( T * p = 0 ): px( p ) // never throws
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- boost::sp_scalar_constructor_hook(ptr);
+ boost::sp_scalar_constructor_hook( px );
#endif
}
#ifndef BOOST_NO_AUTO_PTR
- explicit scoped_ptr(std::auto_ptr<T> p): ptr(p.release()) // never throws
+ explicit scoped_ptr( std::auto_ptr<T> p ): px( p.release() ) // never throws
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- boost::sp_scalar_constructor_hook(ptr);
+ boost::sp_scalar_constructor_hook( px );
#endif
}
@@ -75,71 +75,42 @@
~scoped_ptr() // never throws
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- boost::sp_scalar_destructor_hook(ptr);
+ boost::sp_scalar_destructor_hook( px );
#endif
- boost::checked_delete(ptr);
+ boost::checked_delete( px );
}
void reset(T * p = 0) // never throws
{
- BOOST_ASSERT(p == 0 || p != ptr); // catch self-reset errors
+ BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors
this_type(p).swap(*this);
}
T & operator*() const // never throws
{
- BOOST_ASSERT(ptr != 0);
- return *ptr;
+ BOOST_ASSERT( px != 0 );
+ return *px;
}
T * operator->() const // never throws
{
- BOOST_ASSERT(ptr != 0);
- return ptr;
+ BOOST_ASSERT( px != 0 );
+ return px;
}
T * get() const // never throws
{
- return ptr;
+ return px;
}
- // implicit conversion to "bool"
-
-#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530)
-
- operator bool () const
- {
- return ptr != 0;
- }
-
-#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
- typedef T * (this_type::*unspecified_bool_type)() const;
-
- operator unspecified_bool_type() const // never throws
- {
- return ptr == 0? 0: &this_type::get;
- }
-
-#else
- typedef T * this_type::*unspecified_bool_type;
-
- operator unspecified_bool_type() const // never throws
- {
- return ptr == 0? 0: &this_type::ptr;
- }
-
-#endif
-
- bool operator! () const // never throws
- {
- return ptr == 0;
- }
+// implicit conversion to "bool"
+#include <boost/smart_ptr/detail/operator_bool.hpp>
void swap(scoped_ptr & b) // never throws
{
- T * tmp = b.ptr;
- b.ptr = ptr;
- ptr = tmp;
+ T * tmp = b.px;
+ b.px = px;
+ px = tmp;
}
};
Modified: trunk/boost/smart_ptr/shared_array.hpp
==============================================================================
--- trunk/boost/smart_ptr/shared_array.hpp (original)
+++ trunk/boost/smart_ptr/shared_array.hpp 2009-03-01 13:42:44 EST (Sun, 01 Mar 2009)
@@ -94,54 +94,8 @@
return px;
}
- // implicit conversion to "bool"
-
-#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530)
-
- operator bool () const
- {
- return px != 0;
- }
-
-#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
- {
- return px == 0? 0: &this_type::get;
- }
-
-#else
-
- typedef T * this_type::*unspecified_bool_type;
-
- operator unspecified_bool_type() const // never throws
- {
- return px == 0? 0: &this_type::px;
- }
-
-#endif
-
- bool operator! () const // never throws
- {
- return px == 0;
- }
+// implicit conversion to "bool"
+#include <boost/smart_ptr/detail/operator_bool.hpp>
bool unique() const // never throws
{
Modified: trunk/boost/smart_ptr/shared_ptr.hpp
==============================================================================
--- trunk/boost/smart_ptr/shared_ptr.hpp (original)
+++ trunk/boost/smart_ptr/shared_ptr.hpp 2009-03-01 13:42:44 EST (Sun, 01 Mar 2009)
@@ -425,57 +425,8 @@
return px;
}
- // implicit conversion to "bool"
-
-#if ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__)
-
- operator bool () const
- {
- return px != 0;
- }
-
-#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) ) || \
- ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
-
- typedef T * (this_type::*unspecified_bool_type)() const;
-
- operator unspecified_bool_type() const // never throws
- {
- return px == 0? 0: &this_type::get;
- }
-
-#else
-
- typedef T * this_type::*unspecified_bool_type;
-
- operator unspecified_bool_type() const // never throws
- {
- return px == 0? 0: &this_type::px;
- }
-
-#endif
-
- // operator! is redundant, but some compilers need it
-
- bool operator! () const // never throws
- {
- return px == 0;
- }
+// implicit conversion to "bool"
+#include <boost/smart_ptr/detail/operator_bool.hpp>
bool unique() const // never throws
{
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk