Compare commits

..

3 Commits

Author SHA1 Message Date
nobody
0de0d99848 This commit was manufactured by cvs2svn to create tag
'Version_1_30_1'.

[SVN r19444]
2003-08-04 17:55:29 +00:00
nobody
011d6b4faf This commit was manufactured by cvs2svn to create branch 'RC_1_30_0'.
[SVN r19146]
2003-07-16 10:53:07 +00:00
nobody
86ba6efa8f This commit was manufactured by cvs2svn to create branch 'RC_1_30_0'.
[SVN r17693]
2003-03-01 19:43:06 +00:00
40 changed files with 205 additions and 549 deletions

View File

@@ -1,9 +1,12 @@
// Boost scoped_ptr_example implementation file -----------------------------//
// Copyright Beman Dawes 2001.
// See accompanying license for terms and conditions of use.
// (C) Copyright Beman Dawes 2001. Permission to copy,
// use, modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided "as is"
// without express or implied warranty, and with no claim as to its
// suitability for any purpose.
// See http://www.boost.org/libs/smart_ptr for documentation.
// See http://www.boost.org for most recent version including documentation.
#include "scoped_ptr_example.hpp"
#include <iostream>

View File

@@ -1,9 +1,12 @@
// Boost scoped_ptr_example header file ------------------------------------//
// Copyright Beman Dawes 2001.
// See accompanying license for terms and conditions of use.
// (C) Copyright Beman Dawes 2001. Permission to copy,
// use, modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided "as is"
// without express or implied warranty, and with no claim as to its
// suitability for any purpose.
// See http://www.boost.org/libs/smart_ptr for documentation.
// See http://www.boost.org for most recent version including documentation.
#include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp>

View File

@@ -1,9 +1,12 @@
// Boost scoped_ptr_example_test main program -------------------------------//
// Copyright Beman Dawes 2001.
// See accompanying license for terms and conditions of use.
// (C) Copyright Beman Dawes 2001. Permission to copy,
// use, modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided "as is"
// without express or implied warranty, and with no claim as to its
// suitability for any purpose.
// See http://www.boost.org/libs/smart_ptr for documentation.
// See http://www.boost.org for most recent version including documentation.
#include "scoped_ptr_example.hpp"

View File

@@ -1,9 +1,12 @@
// Boost shared_ptr_example.cpp --------------------------------------------//
// Copyright Beman Dawes 2001.
// See accompanying license for terms and conditions of use.
// (C) Copyright Beman Dawes 2001. Permission to copy,
// use, modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided "as is"
// without express or implied warranty, and with no claim as to its
// suitability for any purpose.
// See http://www.boost.org/libs/smart_ptr for documentation.
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 21 May 01 Initial complete version (Beman Dawes)

View File

@@ -1,9 +1,12 @@
// Boost shared_ptr_example2 implementation file -----------------------------//
// Copyright Beman Dawes 2001.
// See accompanying license for terms and conditions of use.
// (C) Copyright Beman Dawes 2001. Permission to copy,
// use, modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided "as is"
// without express or implied warranty, and with no claim as to its
// suitability for any purpose.
// See http://www.boost.org/libs/smart_ptr for documentation.
// See http://www.boost.org for most recent version including documentation.
#include "shared_ptr_example2.hpp"
#include <iostream>

View File

@@ -1,9 +1,12 @@
// Boost shared_ptr_example2 header file -----------------------------------//
// Copyright Beman Dawes 2001.
// See accompanying license for terms and conditions of use.
// (C) Copyright Beman Dawes 2001. Permission to copy,
// use, modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided "as is"
// without express or implied warranty, and with no claim as to its
// suitability for any purpose.
// See http://www.boost.org/libs/smart_ptr for documentation.
// See http://www.boost.org for most recent version including documentation.
#include <boost/shared_ptr.hpp>

View File

@@ -1,9 +1,12 @@
// Boost shared_ptr_example2_test main program ------------------------------//
// Copyright Beman Dawes 2001.
// See accompanying license for terms and conditions of use.
// (C) Copyright Beman Dawes 2001. Permission to copy,
// use, modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided "as is"
// without express or implied warranty, and with no claim as to its
// suitability for any purpose.
// See http://www.boost.org/libs/smart_ptr for documentation.
// See http://www.boost.org for most recent version including documentation.
#include "shared_ptr_example2.hpp"

View File

@@ -1,10 +1,8 @@
#ifndef BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
#define BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#if _MSC_VER >= 1020
#pragma once
#endif
//

View File

@@ -1,10 +1,8 @@
#ifndef BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
#define BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#if _MSC_VER >= 1020
#pragma once
#endif
//

View File

@@ -1,16 +1,14 @@
#ifndef BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
#define BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#if _MSC_VER >= 1020
#pragma once
#endif
//
// boost/detail/lightweight_mutex.hpp - lightweight mutex
//
// Copyright (c) 2002, 2003 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
@@ -66,23 +64,15 @@
// shared_ptr_timing_test.cpp will compile succesfully with a stub do-nothing
// pthreads library, since it doesn't create any threads.
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) && !defined(BOOST_LWM_USE_CRITICAL_SECTION) && !defined(BOOST_LWM_USE_PTHREADS)
# define BOOST_LWM_WIN32
#endif
#if !defined(BOOST_HAS_THREADS)
# if defined(BOOST_LWM_WIN32)
# include <boost/detail/lwm_win32_nt.hpp>
# else
# include <boost/detail/lwm_nop.hpp>
# endif
#ifndef BOOST_HAS_THREADS
# include <boost/detail/lwm_nop.hpp>
#elif defined(BOOST_LWM_USE_SPINLOCK) && defined(BOOST_USE_ASM_ATOMIC_H)
# include <boost/detail/lwm_linux.hpp>
#elif defined(BOOST_LWM_USE_CRITICAL_SECTION)
# include <boost/detail/lwm_win32_cs.hpp>
#elif defined(BOOST_LWM_USE_PTHREADS)
# include <boost/detail/lwm_pthreads.hpp>
#elif defined(BOOST_LWM_WIN32)
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
# include <boost/detail/lwm_win32.hpp>
#elif defined(BOOST_LWM_USE_SPINLOCK) && defined(__sgi)
# include <boost/detail/lwm_irix.hpp>

View File

@@ -1,6 +1,10 @@
#ifndef BOOST_DETAIL_LWM_IRIX_HPP_INCLUDED
#define BOOST_DETAIL_LWM_IRIX_HPP_INCLUDED
#if _MSC_VER >= 1020
#pragma once
#endif
//
// boost/detail/lwm_irix.hpp
//

View File

@@ -1,6 +1,10 @@
#ifndef BOOST_DETAIL_LWM_LINUX_HPP_INCLUDED
#define BOOST_DETAIL_LWM_LINUX_HPP_INCLUDED
#if _MSC_VER >= 1020
#pragma once
#endif
//
// boost/detail/lwm_linux.hpp
//

View File

@@ -1,10 +1,8 @@
#ifndef BOOST_DETAIL_LWM_NOP_HPP_INCLUDED
#define BOOST_DETAIL_LWM_NOP_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#if _MSC_VER >= 1020
#pragma once
#endif
//

View File

@@ -1,10 +1,8 @@
#ifndef BOOST_DETAIL_LWM_PTHREADS_HPP_INCLUDED
#define BOOST_DETAIL_LWM_PTHREADS_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#if _MSC_VER >= 1020
#pragma once
#endif
//

View File

@@ -1,10 +1,8 @@
#ifndef BOOST_DETAIL_LWM_WIN32_HPP_INCLUDED
#define BOOST_DETAIL_LWM_WIN32_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#if _MSC_VER >= 1020
#pragma once
#endif
//

View File

@@ -1,10 +1,8 @@
#ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
#define BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#if _MSC_VER >= 1020
#pragma once
#endif
//

View File

@@ -1,64 +0,0 @@
#ifndef BOOST_DETAIL_LWM_WIN32_NT_HPP_INCLUDED
#define BOOST_DETAIL_LWM_WIN32_NT_HPP_INCLUDED
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/detail/lwm_win32_nt.hpp
//
// Copyright (c) 2002, 2003 Peter Dimov
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// "No threads" version of lwm_win32.hpp; binary compatible but no-op.
//
namespace boost
{
namespace detail
{
class lightweight_mutex
{
private:
long l_;
lightweight_mutex(lightweight_mutex const &);
lightweight_mutex & operator=(lightweight_mutex const &);
public:
lightweight_mutex(): l_(0)
{
}
class scoped_lock;
friend class scoped_lock;
class scoped_lock
{
private:
scoped_lock(scoped_lock const &);
scoped_lock & operator=(scoped_lock const &);
public:
explicit scoped_lock(lightweight_mutex &)
{
}
};
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_DETAIL_LWM_WIN32_NT_HPP_INCLUDED

View File

@@ -1,8 +1,6 @@
#ifndef BOOST_DETAIL_SHARED_COUNT_HPP_INCLUDED
#define BOOST_DETAIL_SHARED_COUNT_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
@@ -117,21 +115,14 @@ public:
virtual void * get_deleter(std::type_info const & ti) = 0;
void add_ref_copy()
void add_ref()
{
#if defined(BOOST_HAS_THREADS)
mutex_type::scoped_lock lock(mtx_);
#endif
if(use_count_ == 0 && weak_count_ != 0) boost::throw_exception(boost::bad_weak_ptr());
++use_count_;
}
void add_ref_lock()
{
#if defined(BOOST_HAS_THREADS)
mutex_type::scoped_lock lock(mtx_);
#endif
if(use_count_ == 0) boost::throw_exception(boost::bad_weak_ptr());
++use_count_;
++weak_count_;
}
void release() // nothrow
@@ -142,7 +133,11 @@ public:
#endif
long new_use_count = --use_count_;
if(new_use_count != 0) return;
if(new_use_count != 0)
{
--weak_count_;
return;
}
}
dispose();
@@ -187,10 +182,12 @@ private:
sp_counted_base(sp_counted_base const &);
sp_counted_base & operator= (sp_counted_base const &);
long use_count_; // #shared
long weak_count_; // #weak + (#shared != 0)
// inv: use_count_ <= weak_count_
#if defined(BOOST_HAS_THREADS) || defined(BOOST_LWM_WIN32)
long use_count_;
long weak_count_;
#if defined(BOOST_HAS_THREADS)
mutable mutex_type mtx_;
#endif
};
@@ -387,7 +384,7 @@ public:
, id_(shared_count_id)
#endif
{
if(pi_ != 0) pi_->add_ref_copy();
if(pi_ != 0) pi_->add_ref();
}
explicit shared_count(weak_count const & r); // throws bad_weak_ptr when r.use_count() == 0
@@ -395,7 +392,7 @@ public:
shared_count & operator= (shared_count const & r) // nothrow
{
sp_counted_base * tmp = r.pi_;
if(tmp != 0) tmp->add_ref_copy();
if(tmp != 0) tmp->add_ref();
if(pi_ != 0) pi_->release();
pi_ = tmp;
@@ -535,7 +532,7 @@ inline shared_count::shared_count(weak_count const & r): pi_(r.pi_)
{
if(pi_ != 0)
{
pi_->add_ref_lock();
pi_->add_ref();
}
else
{

View File

@@ -24,25 +24,6 @@ namespace boost
template<class T> class enable_shared_from_this
{
protected:
enable_shared_from_this()
{
}
enable_shared_from_this(enable_shared_from_this const &)
{
}
enable_shared_from_this & operator=(enable_shared_from_this const &)
{
return *this;
}
~enable_shared_from_this()
{
}
public:
shared_ptr<T> shared_from_this()

View File

@@ -128,21 +128,13 @@ public:
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
#else
typedef T * this_type::*unspecified_bool_type;
typedef T * (intrusive_ptr::*unspecified_bool_type) () const;
operator unspecified_bool_type () const
{
return p_ == 0? 0: &this_type::p_;
return p_ == 0? 0: &intrusive_ptr::get;
}
#endif
@@ -228,11 +220,6 @@ template<class T, class U> intrusive_ptr<T> static_pointer_cast(intrusive_ptr<U>
return static_cast<T *>(p.get());
}
template<class T, class U> intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & p)
{
return const_cast<T *>(p.get());
}
template<class T, class U> intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & p)
{
return dynamic_cast<T *>(p.get());

View File

@@ -93,23 +93,15 @@ public:
return ptr != 0;
}
#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
#else
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

View File

@@ -110,22 +110,15 @@ public:
return ptr != 0;
}
#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
#else
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

View File

@@ -102,23 +102,15 @@ public:
return px != 0;
}
#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
#else
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

View File

@@ -48,7 +48,6 @@ namespace detail
{
struct static_cast_tag {};
struct const_cast_tag {};
struct dynamic_cast_tag {};
struct polymorphic_cast_tag {};
@@ -69,16 +68,6 @@ template<> struct shared_ptr_traits<void const>
typedef void reference;
};
template<> struct shared_ptr_traits<void volatile>
{
typedef void reference;
};
template<> struct shared_ptr_traits<void const volatile>
{
typedef void reference;
};
#endif
// enable_shared_from_this support
@@ -88,7 +77,7 @@ template<class T, class Y> void sp_enable_shared_from_this(boost::enable_shared_
if(pe != 0) pe->_internal_weak_this._internal_assign(px, pn);
}
inline void sp_enable_shared_from_this(void const volatile *, void const volatile *, shared_count const &)
inline void sp_enable_shared_from_this(void const *, void const *, shared_count const &)
{
}
@@ -169,11 +158,6 @@ public:
{
}
template<class Y>
shared_ptr(shared_ptr<Y> const & r, detail::const_cast_tag): px(const_cast<element_type *>(r.px)), pn(r.pn)
{
}
template<class Y>
shared_ptr(shared_ptr<Y> const & r, detail::dynamic_cast_tag): px(dynamic_cast<element_type *>(r.px)), pn(r.pn)
{
@@ -269,23 +253,15 @@ public:
return px != 0;
}
#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
#else
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
@@ -375,11 +351,6 @@ template<class T, class U> shared_ptr<T> static_pointer_cast(shared_ptr<U> const
return shared_ptr<T>(r, detail::static_cast_tag());
}
template<class T, class U> shared_ptr<T> const_pointer_cast(shared_ptr<U> const & r)
{
return shared_ptr<T>(r, detail::const_cast_tag());
}
template<class T, class U> shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const & r)
{
return shared_ptr<T>(r, detail::dynamic_cast_tag());
@@ -443,10 +414,9 @@ template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::
// get_deleter (experimental)
#if (defined(__GNUC__) && (__GNUC__ < 3)) || (defined(__EDG_VERSION__) && (__EDG_VERSION__ <= 238))
#if defined(__GNUC__) && (__GNUC__ < 3)
// g++ 2.9x doesn't allow static_cast<X const *>(void *)
// apparently EDG 2.38 also doesn't accept it
template<class D, class T> D * get_deleter(shared_ptr<T> const & p)
{

View File

@@ -1,11 +1,10 @@
//
// smart_ptr.hpp
//
// For convenience, this header includes the rest of the smart
// pointer library headers.
// For compatibility, this header includes the headers for the four "classic"
// smart pointer class templates.
//
// Copyright (c) 1998-2002 boost.org
// Copyright (c) 2003 Peter Dimov
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
@@ -15,15 +14,7 @@
// http://www.boost.org/libs/smart_ptr/smart_ptr.htm
//
#include <boost/config.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES)
# include <boost/weak_ptr.hpp>
# include <boost/intrusive_ptr.hpp>
# include <boost/enable_shared_from_this.hpp>
#endif

51
index.htm Normal file
View File

@@ -0,0 +1,51 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Boost Smart Pointer Library</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table border="1" bgcolor="#007F7F" cellpadding="2">
<tr>
<td bgcolor="#FFFFFF"><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></td>
<td><a href="../../index.htm"><font face="Arial" color="#FFFFFF"><big>Home</big></font></a></td>
<td><a href="../libraries.htm"><font face="Arial" color="#FFFFFF"><big>Libraries</big></font></a></td>
<td><a href="../../people/people.htm"><font face="Arial" color="#FFFFFF"><big>People</big></font></a></td>
<td><a href="../../more/faq.htm"><font face="Arial" color="#FFFFFF"><big>FAQ</big></font></a></td>
<td><a href="../../more/index.htm"><font face="Arial" color="#FFFFFF"><big>More</big></font></a></td>
</tr>
</table>
<h1>Smart Pointer Library</h1>
<p>The smart pointer library includes five smart pointer class templates. Smart
pointers ease the management of memory dynamically allocated with C++ <b>new</b>
expressions. In addition, <b>scoped_ptr</b> can ease the management of memory
dynamically allocated in other ways.</p>
<ul>
<li>
<a href="smart_ptr.htm">Documentation</a> (HTML).</li>
<li>
Header <a href="../../boost/scoped_ptr.hpp">scoped_ptr.hpp</a>.</li>
<li>
Header <a href="../../boost/scoped_array.hpp">scoped_array.hpp</a>.</li>
<li>
Header <a href="../../boost/shared_ptr.hpp">shared_ptr.hpp</a>.</li>
<li>
Header <a href="../../boost/shared_array.hpp">shared_array.hpp</a>.</li>
<li>
Header <a href="../../boost/weak_ptr.hpp">weak_ptr.hpp</a>.</li>
<li>
Header <a href="../../boost/enable_shared_from_this.hpp">enable_shared_from_this.hpp</a>.</li>
<li>
Header <a href="../../boost/intrusive_ptr.hpp">intrusive_ptr.hpp</a>.</li>
<li>
Test program <a href="test/smart_ptr_test.cpp">smart_ptr_test.cpp</a>.</li>
<li>
Originally submitted by <a href="../../people/greg_colvin.htm">Greg Colvin</a> and
<a href="../../people/beman_dawes.html">Beman Dawes</a>, currently maintained
by <a href="../../people/peter_dimov.htm">Peter Dimov</a> and <a href="../../people/darin_adler.htm">
Darin Adler</a>.</li>
</ul>
<hr>
<p>$Date$</p>
</body>
</html>

View File

@@ -1,9 +0,0 @@
<html>
<head>
<meta http-equiv="refresh" content="0; URL=smart_ptr.htm">
</head>
<body>
Automatic redirection failed, please go to
<a href="smart_ptr.htm">smart_ptr.htm</a>.
</body>
</html>

View File

@@ -100,9 +100,6 @@
template&lt;class T, class U&gt;
intrusive_ptr&lt;T&gt; <A href="#static_pointer_cast" >static_pointer_cast</A>(intrusive_ptr&lt;U&gt; const &amp; r); // never throws
template&lt;class T, class U&gt;
intrusive_ptr&lt;T&gt; <A href="#const_pointer_cast" >const_pointer_cast</A>(intrusive_ptr&lt;U&gt; const &amp; r); // never throws
template&lt;class T, class U&gt;
intrusive_ptr&lt;T&gt; <A href="#dynamic_pointer_cast" >dynamic_pointer_cast</A>(intrusive_ptr&lt;U&gt; const &amp; r); // never throws
@@ -253,13 +250,6 @@ intrusive_ptr &amp; operator=(T * r);</pre>
<P><B>Returns:</B> <code>intrusive_ptr&lt;T&gt;(static_cast&lt;T*&gt;(r.get()))</code>.</P>
<P><B>Throws:</B> nothing.</P>
</BLOCKQUOTE>
<h3><a name="const_pointer_cast">const_pointer_cast</a></h3>
<pre>template&lt;class T, class U&gt;
intrusive_ptr&lt;T&gt; const_pointer_cast(intrusive_ptr&lt;U&gt; const &amp; r); // never throws</pre>
<BLOCKQUOTE>
<P><B>Returns:</B> <code>intrusive_ptr&lt;T&gt;(const_cast&lt;T*&gt;(r.get()))</code>.</P>
<P><B>Throws:</B> nothing.</P>
</BLOCKQUOTE>
<h3><a name="dynamic_pointer_cast">dynamic_pointer_cast</a></h3>
<pre>template&lt;class T, class U&gt;
intrusive_ptr&lt;T&gt; dynamic_pointer_cast(intrusive_ptr&lt;U&gt; const &amp; r);</pre>

View File

@@ -142,9 +142,6 @@ void bad()
template&lt;class T, class U&gt;
shared_ptr&lt;T&gt; <A href="#static_pointer_cast" >static_pointer_cast</A>(shared_ptr&lt;U&gt; const &amp; r); // never throws
template&lt;class T, class U&gt;
shared_ptr&lt;T&gt; <A href="#const_pointer_cast" >const_pointer_cast</A>(shared_ptr&lt;U&gt; const &amp; r); // never throws
template&lt;class T, class U&gt;
shared_ptr&lt;T&gt; <A href="#dynamic_pointer_cast" >dynamic_pointer_cast</A>(shared_ptr&lt;U&gt; const &amp; r); // never throws
@@ -476,21 +473,6 @@ q = p;
<p>will eventually result in undefined behavior, attempting to delete the same
object twice.</p>
</BLOCKQUOTE>
<h3><a name="const_pointer_cast">const_pointer_cast</a></h3>
<pre>template&lt;class T, class U&gt;
shared_ptr&lt;T&gt; const_pointer_cast(shared_ptr&lt;U&gt; const &amp; r); // never throws</pre>
<BLOCKQUOTE>
<P><STRONG>Requires:</STRONG> The expression <code>const_cast&lt;T*&gt;(r.get())</code>
must be well-formed.</P>
<P><B>Returns:</B> If <b>r</b> is <i>empty</i>, an <i>empty</i> <b>shared_ptr&lt;T&gt;</b>;
otherwise, a <STRONG>shared_ptr&lt;T&gt;</STRONG> object that stores a copy of <code>
const_cast&lt;T*&gt;(r.get())</code> and <i>shares ownership</i> with <b>r</b>.</P>
<P><B>Throws:</B> nothing.</P>
<P><B>Notes:</B> the seemingly equivalent expression</P>
<p><code>shared_ptr&lt;T&gt;(const_cast&lt;T*&gt;(r.get()))</code></p>
<p>will eventually result in undefined behavior, attempting to delete the same
object twice.</p>
</BLOCKQUOTE>
<h3><a name="dynamic_pointer_cast">dynamic_pointer_cast</a></h3>
<pre>template&lt;class T, class U&gt;
shared_ptr&lt;T&gt; dynamic_pointer_cast(shared_ptr&lt;U&gt; const &amp; r);</pre>

View File

@@ -11,7 +11,8 @@
subproject libs/smart_ptr/test ;
# bring in rules for testing
import testing ;
SEARCH on testing.jam = $(BOOST_BUILD_PATH) ;
include testing.jam ;
# Make tests run by default.
DEPENDS all : smart_ptr ;

View File

@@ -1,36 +0,0 @@
# Boost.SmartPtr Library test Jamfile
#
# Copyright (c) 2003 Peter Dimov
# Copyright (c) 2003 Dave Abrahams
#
# Permission to copy, use, modify, sell and distribute this software
# is granted provided this copyright notice appears in all copies.
# This software is provided "as is" without express or implied
# warranty, and with no claim as to its suitability for any purpose.
# bring in rules for testing
import testing ;
{
test-suite "smart_ptr"
: [ run smart_ptr_test.cpp ]
[ run shared_ptr_basic_test.cpp : : : <toolset><gcc>:<cxxflags>-Wno-non-virtual-dtor ]
[ run shared_ptr_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ]
[ run weak_ptr_test.cpp ]
[ run shared_from_this_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ]
[ run get_deleter_test.cpp ]
[ run intrusive_ptr_test.cpp ]
[ compile-fail shared_ptr_assign_fail.cpp ]
;
# this one is too slow to run unless explicitly requested, and ALL
# tests are run by default when this file is subincluded from
# boost/status, so it's guarded from that case. It will only be
# built from this directory when the targets "test" (all tests) or
# "shared_ptr_alloc_test" are requested.
#!!!
#if [ in-invocation-subdir ]
#{
# run shared_ptr_alloc_test.cpp ;
#}
}

View File

@@ -1,7 +1,4 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#if defined(_MSC_VER) && !defined(__ICL) && !defined(__COMO__)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
@@ -9,11 +6,6 @@
#pragma warning(disable: 4355) // 'this' : used in base member initializer list
#pragma warning(disable: 4511) // copy constructor could not be generated
#pragma warning(disable: 4512) // assignment operator could not be generated
#if (BOOST_MSVC >= 1310)
#pragma warning(disable: 4675) // resolved overload found with Koenig lookup
#endif
#endif
//

View File

@@ -1,6 +1,4 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#if defined(_MSC_VER) && !defined(__ICL) && !defined(__COMO__)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
@@ -69,20 +67,18 @@ void test()
}
void test2();
void test3();
int main()
{
test();
test2();
test3();
return boost::report_errors();
}
// virtual inheritance to stress the implementation
// (prevents Y* -> impl*, enable_shared_from_this<impl>* -> impl* casts)
// virtual inheritance from Y to stress the implementation
// (prevents Y* -> impl* casts)
class impl: public X, public virtual Y, public virtual boost::enable_shared_from_this<impl>
class impl: public X, public virtual Y, public boost::enable_shared_from_this<impl>
{
public:
@@ -114,41 +110,3 @@ void test2()
{
boost::shared_ptr<Y> pi(static_cast<impl2*>(0));
}
//
struct V: public boost::enable_shared_from_this<V>
{
};
void test3()
{
boost::shared_ptr<V> p(new V);
boost::shared_ptr<V> q = p->shared_from_this();
BOOST_TEST(p == q);
BOOST_TEST(!(p < q) && !(q < p));
V v2(*p);
try
{
boost::shared_ptr<V> r = v2.shared_from_this();
BOOST_ERROR("v2.shared_from_this() failed to throw");
}
catch(boost::bad_weak_ptr const &)
{
}
try
{
*p = V();
boost::shared_ptr<V> r = p->shared_from_this();
BOOST_TEST(p == r);
BOOST_TEST(!(p < r) && !(r < p));
}
catch(boost::bad_weak_ptr const &)
{
BOOST_ERROR("p->shared_from_this() threw bad_weak_ptr after *p = V()");
}
}

View File

@@ -1,6 +1,4 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#if defined(_MSC_VER) && !defined(__ICL)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion

View File

@@ -1,19 +1,3 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#pragma warning(disable: 4355) // 'this' : used in base member initializer list
#if (BOOST_MSVC >= 1310)
#pragma warning(disable: 4675) // resolved overload found with Koenig lookup
#endif
#endif
//
// shared_ptr_basic_test.cpp
//

View File

@@ -1,6 +1,4 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#if defined(_MSC_VER) && !defined(__ICL) && !defined(__COMO__)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion

View File

@@ -1,17 +1,9 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#if defined(_MSC_VER) && !defined(__ICL) && !defined(__COMO__)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#pragma warning(disable: 4355) // 'this' : used in base member initializer list
#if (BOOST_MSVC >= 1310)
#pragma warning(disable: 4675) // resolved overload found with Koenig lookup
#endif
#endif
//
@@ -131,31 +123,10 @@ private:
long Y::instances = 0;
template<class T> void pc0_test(T * p)
{
BOOST_TEST(p == 0);
boost::shared_ptr<T> pt(p);
BOOST_TEST(pt? false: true);
BOOST_TEST(!pt);
BOOST_TEST(pt.get() == 0);
BOOST_TEST(pt.use_count() == 1);
BOOST_TEST(pt.unique());
}
void pointer_constructor()
{
pc0_test(static_cast<int*>(0));
#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1300)
pc0_test(static_cast<int const*>(0));
pc0_test(static_cast<int volatile*>(0));
pc0_test(static_cast<int const volatile*>(0));
#endif
{
boost::shared_ptr<int const> pi(static_cast<int*>(0));
boost::shared_ptr<int> pi(static_cast<int*>(0));
BOOST_TEST(pi? false: true);
BOOST_TEST(!pi);
BOOST_TEST(pi.get() == 0);
@@ -164,7 +135,7 @@ void pointer_constructor()
}
{
boost::shared_ptr<int volatile> pi(static_cast<int*>(0));
boost::shared_ptr<int const> pi(static_cast<int*>(0));
BOOST_TEST(pi? false: true);
BOOST_TEST(!pi);
BOOST_TEST(pi.get() == 0);
@@ -190,10 +161,14 @@ void pointer_constructor()
BOOST_TEST(pv.unique());
}
pc0_test(static_cast<X*>(0));
pc0_test(static_cast<X const*>(0));
pc0_test(static_cast<X volatile*>(0));
pc0_test(static_cast<X const volatile*>(0));
{
boost::shared_ptr<X> px(static_cast<X*>(0));
BOOST_TEST(px? false: true);
BOOST_TEST(!px);
BOOST_TEST(px.get() == 0);
BOOST_TEST(px.use_count() == 1);
BOOST_TEST(px.unique());
}
{
boost::shared_ptr<X const> px(static_cast<X*>(0));
@@ -842,10 +817,6 @@ void weak_ptr_constructor()
}
}
#if defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB < 306)
# define BOOST_OLD_AUTO_PTR
#endif
void auto_ptr_constructor()
{
{
@@ -969,7 +940,7 @@ void auto_ptr_constructor()
BOOST_TEST(pi.unique());
BOOST_TEST(*pi == 7);
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p.get() == 0);
#endif
}
@@ -985,7 +956,7 @@ void auto_ptr_constructor()
BOOST_TEST(pi.unique());
BOOST_TEST(*pi == 7);
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p.get() == 0);
#endif
}
@@ -1000,7 +971,7 @@ void auto_ptr_constructor()
BOOST_TEST(pv.use_count() == 1);
BOOST_TEST(pv.unique());
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p.get() == 0);
#endif
}
@@ -1015,7 +986,7 @@ void auto_ptr_constructor()
BOOST_TEST(pv.use_count() == 1);
BOOST_TEST(pv.unique());
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p.get() == 0);
#endif
}
@@ -1033,7 +1004,7 @@ void auto_ptr_constructor()
BOOST_TEST(px.unique());
BOOST_TEST(X::instances == 1);
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p.get() == 0);
#endif
}
@@ -1051,7 +1022,7 @@ void auto_ptr_constructor()
BOOST_TEST(px.unique());
BOOST_TEST(X::instances == 1);
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p.get() == 0);
#endif
}
@@ -1069,7 +1040,7 @@ void auto_ptr_constructor()
BOOST_TEST(pv.unique());
BOOST_TEST(X::instances == 1);
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p.get() == 0);
#endif
}
@@ -1087,7 +1058,7 @@ void auto_ptr_constructor()
BOOST_TEST(pv.unique());
BOOST_TEST(X::instances == 1);
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p.get() == 0);
#endif
}
@@ -1107,7 +1078,7 @@ void auto_ptr_constructor()
BOOST_TEST(X::instances == 1);
BOOST_TEST(Y::instances == 1);
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p.get() == 0);
#endif
}
@@ -1127,7 +1098,7 @@ void auto_ptr_constructor()
BOOST_TEST(X::instances == 1);
BOOST_TEST(Y::instances == 1);
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p.get() == 0);
#endif
}
@@ -1436,7 +1407,7 @@ void auto_ptr_assignment()
BOOST_TEST(p1.get() == p);
BOOST_TEST(p1.use_count() == 1);
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p3.get() == 0);
#endif
@@ -1465,7 +1436,7 @@ void auto_ptr_assignment()
BOOST_TEST(p1.get() == p);
BOOST_TEST(p1.use_count() == 1);
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p3.get() == 0);
#endif
@@ -1502,7 +1473,7 @@ void auto_ptr_assignment()
BOOST_TEST(X::instances == 1);
BOOST_TEST(Y::instances == 1);
#if !defined(BOOST_OLD_AUTO_PTR)
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
BOOST_TEST(p3.get() == 0);
#endif
@@ -2400,57 +2371,6 @@ void test()
} // namespace n_static_cast
namespace n_const_cast
{
struct X;
void test()
{
{
boost::shared_ptr<void const volatile> px;
boost::shared_ptr<void> px2 = boost::const_pointer_cast<void>(px);
BOOST_TEST(px2.get() == 0);
}
{
boost::shared_ptr<int const volatile> px;
boost::shared_ptr<int> px2 = boost::const_pointer_cast<int>(px);
BOOST_TEST(px2.get() == 0);
}
{
boost::shared_ptr<X const volatile> px;
boost::shared_ptr<X> px2 = boost::const_pointer_cast<X>(px);
BOOST_TEST(px2.get() == 0);
}
{
boost::shared_ptr<void const volatile> px(new int);
boost::shared_ptr<void> px2 = boost::const_pointer_cast<void>(px);
BOOST_TEST(px.get() == px2.get());
BOOST_TEST(!(px < px2 || px2 < px));
BOOST_TEST(px.use_count() == 2);
BOOST_TEST(px2.use_count() == 2);
}
{
boost::shared_ptr<int const volatile> px(new int);
boost::shared_ptr<int> px2 = boost::const_pointer_cast<int>(px);
BOOST_TEST(px.get() == px2.get());
BOOST_TEST(!(px < px2 || px2 < px));
BOOST_TEST(px.use_count() == 2);
BOOST_TEST(px2.use_count() == 2);
}
}
} // namespace n_const_cast
namespace n_dynamic_cast
{
@@ -3217,7 +3137,6 @@ int main()
n_swap::test();
n_comparison::test();
n_static_cast::test();
n_const_cast::test();
n_dynamic_cast::test();
n_map::test();

View File

@@ -1,6 +1,4 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#if defined(_MSC_VER) && !defined(__ICL) && !defined(__COMO__)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion

View File

@@ -1,9 +1,20 @@
#if defined(_MSC_VER) && !defined(__ICL) && !defined(__COMO__)
# pragma warning(disable: 4786) // identifier truncated in debug info
# pragma warning(disable: 4710) // function not inlined
# pragma warning(disable: 4711) // function selected for automatic inline expansion
# pragma warning(disable: 4514) // unreferenced inline removed
#endif
#ifdef __BORLANDC__
# pragma warn -8092 // template argument passed to 'find' is not an iterator
#endif
// smart pointer test program ----------------------------------------------//
// Copyright Beman Dawes 1998, 1999.
// See accompanying license for terms and conditions of use.
// See http://www.boost.org/libs/smart_ptr for documentation.
// (C) Copyright Beman Dawes 1998, 1999. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright notice
// appears in all copies. This software is provided "as is" without express or
// implied warranty, and with no claim as to its suitability for any purpose.
// Revision History
// 24 May 01 use Boost test library for error detection, reporting, add tests
@@ -13,25 +24,6 @@
// 20 Jul 99 header name changed to .hpp
// 20 Apr 99 additional error tests added.
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
# pragma warning(disable: 4786) // identifier truncated in debug info
# pragma warning(disable: 4710) // function not inlined
# pragma warning(disable: 4711) // function selected for automatic inline expansion
# pragma warning(disable: 4514) // unreferenced inline removed
#if (BOOST_MSVC >= 1310)
# pragma warning(disable: 4675) // resolved overload found with Koenig lookup
#endif
#endif
#ifdef __BORLANDC__
# pragma warn -8092 // template argument passed to 'find' is not an iterator
#endif
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <boost/shared_ptr.hpp>

View File

@@ -1,17 +1,9 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#if defined(_MSC_VER) && !defined(__ICL) && !defined(__COMO__)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#pragma warning(disable: 4355) // 'this' : used in base member initializer list
#if (BOOST_MSVC >= 1310)
#pragma warning(disable: 4675) // resolved overload found with Koenig lookup
#endif
#endif
//