mirror of
https://github.com/boostorg/intrusive.git
synced 2025-08-03 22:44:43 +02:00
Changes introduced by the new intrusive version.
[SVN r39551]
This commit is contained in:
@@ -16,12 +16,24 @@ doxygen autodoc
|
||||
[ glob ../../../boost/intrusive/*.hpp ]
|
||||
:
|
||||
<doxygen:param>HIDE_UNDOC_MEMBERS=YES
|
||||
<doxygen:param>HIDE_UNDOC_MEMBERS=YES
|
||||
<doxygen:param>HIDE_UNDOC_CLASSES=YES
|
||||
<doxygen:param>EXTRACT_PRIVATE=NO
|
||||
<doxygen:param>ENABLE_PREPROCESSING=YES
|
||||
<doxygen:param>MACRO_EXPANSION=YES
|
||||
<doxygen:param>EXPAND_ONLY_PREDEF=YES
|
||||
<doxygen:param>SEARCH_INCLUDES=YES
|
||||
# <doxygen:param>EXPAND_ONLY_PREDEF=YES
|
||||
# <doxygen:param>SEARCH_INCLUDES=YES
|
||||
# <doxygen:param>INCLUDE_PATH=$(BOOST_ROOT)
|
||||
<doxygen:param>"PREDEFINED=\"BOOST_INTRUSIVE_DOXYGEN_INVOKED\" \\
|
||||
\"list_impl=list\" \\
|
||||
\"slist_impl=slist\" \\
|
||||
\"set_impl=set\" \\
|
||||
\"multiset_impl=multiset\" \\
|
||||
\"rbtree_impl=rbtree\" \\
|
||||
\"unordered_set_impl=unordered_set\" \\
|
||||
\"unordered_multiset_impl=unordered_multiset\" \\
|
||||
\"hashtable_impl=hashtable\" \\
|
||||
"
|
||||
;
|
||||
|
||||
xml intrusive : intrusive.qbk ;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -14,27 +14,31 @@
|
||||
#define BOOST_INTRUSIVE_TEST_COMMON_FUNCTORS_HPP
|
||||
|
||||
#include<boost/intrusive/detail/utilities.hpp>
|
||||
#include<boost/intrusive/detail/mpl.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace intrusive {
|
||||
namespace test {
|
||||
|
||||
template<class T>
|
||||
class delete_disposer
|
||||
{
|
||||
public:
|
||||
public:
|
||||
template <class Pointer>
|
||||
void operator()(Pointer p)
|
||||
{
|
||||
typedef typename std::iterator_traits<Pointer>::value_type value_type;
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(( detail::is_same<T, value_type>::value ));
|
||||
delete detail::get_pointer(p);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class new_cloner
|
||||
{
|
||||
public:
|
||||
template<class Type>
|
||||
Type *operator()(const Type &t)
|
||||
{ return new Type(t); }
|
||||
public:
|
||||
T *operator()(const T &t)
|
||||
{ return new T(t); }
|
||||
};
|
||||
|
||||
} //namespace test {
|
||||
|
@@ -10,67 +10,136 @@
|
||||
// See http://www.boost.org/libs/intrusive for documentation.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BOOST_INTRUSIVE_ITESTVALUE
|
||||
#define BOOST_INTRUSIVE_ITESTVALUE
|
||||
#ifndef BOOST_INTRUSIVE_DETAIL_ITESTVALUE_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_ITESTVALUE_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/intrusive/set_hook.hpp>
|
||||
#include <boost/intrusive/list_hook.hpp>
|
||||
#include <boost/intrusive/slist_hook.hpp>
|
||||
#include <boost/intrusive/unordered_set_hook.hpp>
|
||||
#include <boost/intrusive/options.hpp>
|
||||
#include "smart_ptr.hpp"
|
||||
|
||||
namespace boost{
|
||||
namespace intrusive{
|
||||
|
||||
struct my_tag;
|
||||
|
||||
template<class VoidPointer>
|
||||
struct set_base_hook_type
|
||||
{ typedef set_base_hook<void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct set_auto_base_hook_type
|
||||
{ typedef set_base_hook<link_mode<auto_unlink>, void_pointer<VoidPointer>, tag<my_tag> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct set_member_hook_type
|
||||
{ typedef set_member_hook<void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct set_auto_member_hook_type
|
||||
{ typedef set_member_hook<link_mode<auto_unlink>, void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct list_base_hook_type
|
||||
{ typedef list_base_hook<void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct list_auto_base_hook_type
|
||||
{ typedef list_base_hook<link_mode<auto_unlink>, void_pointer<VoidPointer>, tag<my_tag> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct list_member_hook_type
|
||||
{ typedef list_member_hook<void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct list_auto_member_hook_type
|
||||
{ typedef list_member_hook<link_mode<auto_unlink>, void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct slist_base_hook_type
|
||||
{ typedef slist_base_hook<void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct slist_auto_base_hook_type
|
||||
{ typedef slist_base_hook<link_mode<auto_unlink>, void_pointer<VoidPointer>, tag<my_tag> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct slist_member_hook_type
|
||||
{ typedef slist_member_hook<void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct slist_auto_member_hook_type
|
||||
{ typedef slist_member_hook<link_mode<auto_unlink>, void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct uset_base_hook_type
|
||||
{ typedef unordered_set_base_hook<void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct uset_auto_base_hook_type
|
||||
{ typedef unordered_set_base_hook<link_mode<auto_unlink>, void_pointer<VoidPointer>, tag<my_tag> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct uset_member_hook_type
|
||||
{ typedef unordered_set_member_hook<void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer>
|
||||
struct uset_auto_member_hook_type
|
||||
{ typedef unordered_set_member_hook<link_mode<auto_unlink>, void_pointer<VoidPointer> > type; };
|
||||
|
||||
template<class VoidPointer, bool ConstantTimeSize>
|
||||
struct testvalue
|
||||
: set_base_hook<tag, safe_link, VoidPointer>
|
||||
, set_base_hook<tag, auto_unlink, VoidPointer>
|
||||
, unordered_set_base_hook<tag, safe_link, VoidPointer>
|
||||
, unordered_set_base_hook<tag, auto_unlink, VoidPointer>
|
||||
, list_base_hook<tag, safe_link, VoidPointer>
|
||||
, list_base_hook<tag, auto_unlink, VoidPointer>
|
||||
, slist_base_hook<tag, safe_link, VoidPointer>
|
||||
, slist_base_hook<tag, auto_unlink, VoidPointer>
|
||||
: set_base_hook_type<VoidPointer>::type
|
||||
, set_auto_base_hook_type<VoidPointer>::type
|
||||
, list_base_hook_type<VoidPointer>::type
|
||||
, list_auto_base_hook_type<VoidPointer>::type
|
||||
, slist_base_hook_type<VoidPointer>::type
|
||||
, slist_auto_base_hook_type<VoidPointer>::type
|
||||
, uset_base_hook_type<VoidPointer>::type
|
||||
, uset_auto_base_hook_type<VoidPointer>::type
|
||||
{
|
||||
typedef set_base_hook<tag, auto_unlink, VoidPointer> set_auto_base_hook_t;
|
||||
typedef set_base_hook<tag, safe_link, VoidPointer> set_base_hook_t;
|
||||
typedef set_member_hook<auto_unlink, VoidPointer> set_auto_member_hook_t;
|
||||
typedef set_member_hook<safe_link, VoidPointer> set_member_hook_t;
|
||||
typedef typename set_auto_base_hook_type<VoidPointer>::type set_auto_base_hook_t;
|
||||
typedef typename set_base_hook_type<VoidPointer>::type set_base_hook_t;
|
||||
typedef typename set_auto_member_hook_type<VoidPointer>::type set_auto_member_hook_t;
|
||||
typedef typename set_member_hook_type<VoidPointer>::type set_member_hook_t;
|
||||
|
||||
typedef unordered_set_base_hook<tag, auto_unlink, VoidPointer> unordered_set_auto_base_hook_t;
|
||||
typedef unordered_set_base_hook<tag, safe_link, VoidPointer> unordered_set_base_hook_t;
|
||||
typedef unordered_set_member_hook<auto_unlink, VoidPointer> unordered_set_auto_member_hook_t;
|
||||
typedef unordered_set_member_hook<safe_link, VoidPointer> unordered_set_member_hook_t;
|
||||
typedef typename uset_auto_base_hook_type<VoidPointer>::type unordered_set_auto_base_hook_t;
|
||||
typedef typename uset_base_hook_type<VoidPointer>::type unordered_set_base_hook_t;
|
||||
typedef typename uset_auto_member_hook_type<VoidPointer>::type unordered_set_auto_member_hook_t;
|
||||
typedef typename uset_member_hook_type<VoidPointer>::type unordered_set_member_hook_t;
|
||||
|
||||
typedef list_base_hook<tag, auto_unlink, VoidPointer> list_auto_base_hook_t;
|
||||
typedef list_base_hook<tag, safe_link, VoidPointer> list_base_hook_t;
|
||||
typedef list_member_hook<auto_unlink, VoidPointer> list_auto_member_hook_t;
|
||||
typedef list_member_hook<safe_link, VoidPointer> list_member_hook_t;
|
||||
typedef typename list_auto_base_hook_type<VoidPointer>::type list_auto_base_hook_t;
|
||||
typedef typename list_base_hook_type<VoidPointer>::type list_base_hook_t;
|
||||
typedef typename list_auto_member_hook_type<VoidPointer>::type list_auto_member_hook_t;
|
||||
typedef typename list_member_hook_type<VoidPointer>::type list_member_hook_t;
|
||||
|
||||
typedef slist_base_hook<tag, auto_unlink, VoidPointer> slist_auto_base_hook_t;
|
||||
typedef slist_base_hook<tag, safe_link, VoidPointer> slist_base_hook_t;
|
||||
typedef slist_member_hook<auto_unlink, VoidPointer> slist_auto_member_hook_t;
|
||||
typedef slist_member_hook<safe_link, VoidPointer> slist_member_hook_t;
|
||||
typedef typename slist_auto_base_hook_type<VoidPointer>::type slist_auto_base_hook_t;
|
||||
typedef typename slist_base_hook_type<VoidPointer>::type slist_base_hook_t;
|
||||
typedef typename slist_auto_member_hook_type<VoidPointer>::type slist_auto_member_hook_t;
|
||||
typedef typename slist_member_hook_type<VoidPointer>::type slist_member_hook_t;
|
||||
|
||||
//Set members
|
||||
set_member_hook_t set_node_;
|
||||
set_auto_member_hook_t set_auto_node_;
|
||||
unordered_set_member_hook_t unordered_set_node_;
|
||||
set_member_hook_t set_node_;
|
||||
set_auto_member_hook_t set_auto_node_;
|
||||
|
||||
//Unordered set members
|
||||
unordered_set_member_hook_t unordered_set_node_;
|
||||
unordered_set_auto_member_hook_t unordered_set_auto_node_;
|
||||
|
||||
//List members
|
||||
list_member_hook_t list_node_;
|
||||
list_auto_member_hook_t list_auto_node_;
|
||||
list_member_hook_t list_node_;
|
||||
list_auto_member_hook_t list_auto_node_;
|
||||
|
||||
//Slist members
|
||||
slist_member_hook_t slist_node_;
|
||||
slist_auto_member_hook_t slist_auto_node_;
|
||||
slist_member_hook_t slist_node_;
|
||||
slist_auto_member_hook_t slist_auto_node_;
|
||||
|
||||
int value_;
|
||||
|
||||
enum{ constant_time_size = ConstantTimeSize };
|
||||
static const bool constant_time_size = ConstantTimeSize;
|
||||
|
||||
testvalue()
|
||||
{}
|
||||
@@ -89,44 +158,53 @@ struct testvalue
|
||||
testvalue & operator= (const testvalue& src)
|
||||
{
|
||||
set_base_hook_t::operator=(src);
|
||||
this->set_node_ = src.set_node_;
|
||||
set_auto_base_hook_t::operator=(src);
|
||||
this->set_node_ = src.set_node_;
|
||||
this->set_auto_node_ = src.set_auto_node_;
|
||||
|
||||
unordered_set_base_hook_t::operator=(src);
|
||||
this->unordered_set_node_ = src.unordered_set_node_;
|
||||
unordered_set_auto_base_hook_t::operator=(src);
|
||||
this->unordered_set_node_ = src.unordered_set_node_;
|
||||
this->unordered_set_auto_node_ = src.unordered_set_auto_node_;
|
||||
|
||||
list_base_hook_t::operator=(src);
|
||||
this->list_node_ = src.list_node_;
|
||||
list_auto_base_hook_t::operator=(src);
|
||||
this->list_node_ = src.list_node_;
|
||||
this->list_auto_node_ = src.list_auto_node_;
|
||||
|
||||
slist_base_hook_t::operator=(src);
|
||||
this->slist_node_ = src.slist_node_;
|
||||
slist_auto_base_hook_t::operator=(src);
|
||||
this->slist_node_ = src.slist_node_;
|
||||
this->slist_auto_node_ = src.slist_auto_node_;
|
||||
|
||||
value_ = src.value_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap_nodes(testvalue &other)
|
||||
{
|
||||
//Set has no swapping
|
||||
//Set
|
||||
set_base_hook_t::swap_nodes(other);
|
||||
set_auto_base_hook_t::swap_nodes(other);
|
||||
set_node_.swap_nodes(other.set_node_);
|
||||
set_auto_node_.swap_nodes(other.set_auto_node_);
|
||||
|
||||
//...
|
||||
//Unordered set
|
||||
unordered_set_base_hook_t::swap_nodes(other);
|
||||
unordered_set_auto_base_hook_t::swap_nodes(other);
|
||||
unordered_set_node_.swap_nodes(other.unordered_set_node_);
|
||||
unordered_set_auto_node_.swap_nodes(other.unordered_set_auto_node_);
|
||||
|
||||
//List
|
||||
list_base_hook_t::swap_nodes(other);
|
||||
list_node_.swap_nodes(other.list_node_);
|
||||
list_auto_base_hook_t::swap_nodes(other);
|
||||
list_node_.swap_nodes(other.list_node_);
|
||||
list_auto_node_.swap_nodes(other.list_auto_node_);
|
||||
|
||||
//Slist
|
||||
slist_base_hook_t::swap_nodes(other);
|
||||
slist_node_.swap_nodes(other.slist_node_);
|
||||
slist_auto_base_hook_t::swap_nodes(other);
|
||||
slist_node_.swap_nodes(other.slist_node_);
|
||||
slist_auto_node_.swap_nodes(other.slist_auto_node_);
|
||||
}
|
||||
|
||||
@@ -178,159 +256,6 @@ struct even_odd
|
||||
}
|
||||
};
|
||||
|
||||
typedef testvalue<void *, false> value_r_f;
|
||||
typedef testvalue<smart_ptr<void>, false> value_s_f;
|
||||
typedef testvalue<void *, true> value_r_t;
|
||||
typedef testvalue<smart_ptr<void>, true> value_s_t;
|
||||
|
||||
//Typedefs
|
||||
typedef value_r_f::set_base_hook_t::
|
||||
value_traits<value_r_f > set_base_raw;
|
||||
|
||||
typedef value_r_f::set_member_hook_t::
|
||||
value_traits<value_r_f, &value_r_f::set_node_> set_member_raw;
|
||||
|
||||
typedef value_r_f::set_auto_base_hook_t::
|
||||
value_traits<value_r_f> set_auto_base_raw;
|
||||
|
||||
typedef value_r_f::set_auto_member_hook_t::
|
||||
value_traits<value_r_f, &value_r_f::set_auto_node_> set_auto_member_raw;
|
||||
|
||||
|
||||
typedef value_s_f::set_base_hook_t::
|
||||
value_traits<value_s_f > set_base_smart;
|
||||
|
||||
typedef value_s_f::set_member_hook_t::
|
||||
value_traits<value_s_f, &value_s_f::set_node_> set_member_smart;
|
||||
|
||||
typedef value_s_f::set_auto_base_hook_t::
|
||||
value_traits<value_s_f> set_auto_base_smart;
|
||||
|
||||
typedef value_s_f::set_auto_member_hook_t::
|
||||
value_traits<value_s_f, &value_s_f::set_auto_node_> set_auto_member_smart;
|
||||
|
||||
typedef value_r_t::set_base_hook_t::
|
||||
value_traits<value_r_t > set_base_raw_t;
|
||||
|
||||
typedef value_r_t::set_member_hook_t::
|
||||
value_traits<value_r_t, &value_r_t::set_node_> set_member_raw_t;
|
||||
|
||||
typedef value_s_t::set_base_hook_t::
|
||||
value_traits<value_s_t > set_base_smart_t;
|
||||
|
||||
typedef value_s_t::set_member_hook_t::
|
||||
value_traits<value_s_t, &value_s_t::set_node_> set_member_smart_t;
|
||||
|
||||
//Typedefs
|
||||
typedef value_r_f::unordered_set_base_hook_t::
|
||||
value_traits<value_r_f > unordered_set_base_raw;
|
||||
|
||||
typedef value_r_f::unordered_set_member_hook_t::
|
||||
value_traits<value_r_f, &value_r_f::unordered_set_node_> unordered_set_member_raw;
|
||||
|
||||
typedef value_r_f::unordered_set_auto_base_hook_t::
|
||||
value_traits<value_r_f> unordered_set_auto_base_raw;
|
||||
|
||||
typedef value_r_f::unordered_set_auto_member_hook_t::
|
||||
value_traits<value_r_f, &value_r_f::unordered_set_auto_node_> unordered_set_auto_member_raw;
|
||||
|
||||
typedef value_s_f::unordered_set_base_hook_t::
|
||||
value_traits<value_s_f > unordered_set_base_smart;
|
||||
|
||||
typedef value_s_f::unordered_set_member_hook_t::
|
||||
value_traits<value_s_f, &value_s_f::unordered_set_node_> unordered_set_member_smart;
|
||||
|
||||
typedef value_s_f::unordered_set_auto_base_hook_t::
|
||||
value_traits<value_s_f> unordered_set_auto_base_smart;
|
||||
|
||||
typedef value_s_f::unordered_set_auto_member_hook_t::
|
||||
value_traits<value_s_f, &value_s_f::unordered_set_auto_node_> unordered_set_auto_member_smart;
|
||||
|
||||
typedef value_r_t::unordered_set_base_hook_t::
|
||||
value_traits<value_r_t > unordered_set_base_raw_t;
|
||||
|
||||
typedef value_r_t::unordered_set_member_hook_t::
|
||||
value_traits<value_r_t, &value_r_t::unordered_set_node_> unordered_set_member_raw_t;
|
||||
|
||||
typedef value_s_t::unordered_set_base_hook_t::
|
||||
value_traits<value_s_t > unordered_set_base_smart_t;
|
||||
|
||||
typedef value_s_t::unordered_set_member_hook_t::
|
||||
value_traits<value_s_t, &value_s_t::unordered_set_node_> unordered_set_member_smart_t;
|
||||
|
||||
//Explicit instantiations
|
||||
typedef value_r_f::list_base_hook_t::
|
||||
value_traits<value_r_f> list_base_raw;
|
||||
|
||||
typedef value_r_f::list_member_hook_t::
|
||||
value_traits<value_r_f, &value_r_f::list_node_> list_member_raw;
|
||||
|
||||
typedef value_r_f::list_auto_base_hook_t::
|
||||
value_traits<value_r_f> list_auto_base_raw;
|
||||
|
||||
typedef value_r_f::list_auto_member_hook_t::
|
||||
value_traits<value_r_f, &value_r_f::list_auto_node_> list_auto_member_raw;
|
||||
|
||||
typedef value_s_f::list_base_hook_t::
|
||||
value_traits<value_s_f> list_base_smart;
|
||||
|
||||
typedef value_s_f::list_member_hook_t::
|
||||
value_traits<value_s_f, &value_s_f::list_node_> list_member_smart;
|
||||
|
||||
typedef value_s_f::list_auto_base_hook_t::
|
||||
value_traits<value_s_f> list_auto_base_smart;
|
||||
|
||||
typedef value_s_f::list_auto_member_hook_t::
|
||||
value_traits<value_s_f, &value_s_f::list_auto_node_> list_auto_member_smart;
|
||||
|
||||
typedef value_r_t::list_base_hook_t::
|
||||
value_traits<value_r_t> list_base_raw_t;
|
||||
|
||||
typedef value_r_t::list_member_hook_t::
|
||||
value_traits<value_r_t, &value_r_t::list_node_> list_member_raw_t;
|
||||
|
||||
typedef value_s_t::list_base_hook_t::
|
||||
value_traits<value_s_t> list_base_smart_t;
|
||||
|
||||
typedef value_s_t::list_member_hook_t::
|
||||
value_traits<value_s_t, &value_s_t::list_node_> list_member_smart_t;
|
||||
|
||||
typedef value_r_f::slist_base_hook_t::
|
||||
value_traits<value_r_f> slist_base_raw;
|
||||
|
||||
typedef value_r_f::slist_member_hook_t::
|
||||
value_traits<value_r_f, &value_r_f::slist_node_> slist_member_raw;
|
||||
|
||||
typedef value_r_f::slist_auto_base_hook_t::
|
||||
value_traits<value_r_f> slist_auto_base_raw;
|
||||
|
||||
typedef value_r_f::slist_auto_member_hook_t::
|
||||
value_traits<value_r_f, &value_r_f::slist_auto_node_> slist_auto_member_raw;
|
||||
|
||||
typedef value_s_f::slist_base_hook_t::
|
||||
value_traits<value_s_f> slist_base_smart;
|
||||
|
||||
typedef value_s_f::slist_member_hook_t::
|
||||
value_traits<value_s_f, &value_s_f::slist_node_> slist_member_smart;
|
||||
|
||||
typedef value_s_f::slist_auto_base_hook_t::
|
||||
value_traits<value_s_f> slist_auto_base_smart;
|
||||
|
||||
typedef value_s_f::slist_auto_member_hook_t::
|
||||
value_traits<value_s_f, &value_s_f::slist_auto_node_> slist_auto_member_smart;
|
||||
|
||||
typedef value_r_t::slist_base_hook_t::
|
||||
value_traits<value_r_t> slist_base_raw_t;
|
||||
|
||||
typedef value_r_t::slist_member_hook_t::
|
||||
value_traits<value_r_t, &value_r_t::slist_node_> slist_member_raw_t;
|
||||
|
||||
typedef value_s_t::slist_base_hook_t::
|
||||
value_traits<value_s_t> slist_base_smart_t;
|
||||
|
||||
typedef value_s_t::slist_member_hook_t::
|
||||
value_traits<value_s_t, &value_s_t::slist_node_> slist_member_smart_t;
|
||||
|
||||
} //namespace boost{
|
||||
} //namespace intrusive{
|
||||
|
||||
|
@@ -106,123 +106,122 @@ class smart_ptr
|
||||
|
||||
public: //Public Functions
|
||||
|
||||
/*!Constructor from raw pointer (allows "0" pointer conversion). Never throws.*/
|
||||
//!Constructor from raw pointer (allows "0" pointer conversion). Never throws.
|
||||
smart_ptr(pointer ptr = 0)
|
||||
: m_ptr(ptr)
|
||||
{}
|
||||
|
||||
/*!Constructor from other pointer. Never throws.*/
|
||||
|
||||
//!Constructor from other pointer. Never throws.
|
||||
template <class T>
|
||||
smart_ptr(T *ptr)
|
||||
: m_ptr(ptr)
|
||||
{}
|
||||
|
||||
/*!Constructor from other smart_ptr */
|
||||
//!Constructor from other smart_ptr
|
||||
smart_ptr(const smart_ptr& ptr)
|
||||
: m_ptr(ptr.m_ptr)
|
||||
{}
|
||||
|
||||
/*!Constructor from other smart_ptr. If pointers of pointee types are
|
||||
convertible, offset_ptrs will be convertibles. Never throws.*/
|
||||
//!Constructor from other smart_ptr. If pointers of pointee types are
|
||||
//!convertible, offset_ptrs will be convertibles. Never throws.
|
||||
template<class T2>
|
||||
smart_ptr(const smart_ptr<T2> &ptr)
|
||||
: m_ptr(ptr.m_ptr)
|
||||
{}
|
||||
|
||||
/*!Emulates static_cast operator. Never throws. */
|
||||
//!Emulates static_cast operator. Never throws.
|
||||
template<class Y>
|
||||
smart_ptr(const smart_ptr<Y> & r, detail::static_cast_tag)
|
||||
: m_ptr(static_cast<PointedType*>(r.get()))
|
||||
{}
|
||||
|
||||
/*!Emulates const_cast operator. Never throws.*/
|
||||
//!Emulates const_cast operator. Never throws.
|
||||
template<class Y>
|
||||
smart_ptr(const smart_ptr<Y> & r, detail::const_cast_tag)
|
||||
: m_ptr(const_cast<PointedType*>(r.get()))
|
||||
{}
|
||||
|
||||
/*!Emulates dynamic_cast operator. Never throws.*/
|
||||
//!Emulates dynamic_cast operator. Never throws.
|
||||
template<class Y>
|
||||
smart_ptr(const smart_ptr<Y> & r, detail::dynamic_cast_tag)
|
||||
: m_ptr(dynamic_cast<PointedType*>(r.get()))
|
||||
{}
|
||||
|
||||
/*!Emulates reinterpret_cast operator. Never throws.*/
|
||||
//!Emulates reinterpret_cast operator. Never throws.
|
||||
template<class Y>
|
||||
smart_ptr(const smart_ptr<Y> & r, detail::reinterpret_cast_tag)
|
||||
: m_ptr(reinterpret_cast<PointedType*>(r.get()))
|
||||
{}
|
||||
|
||||
/*!Obtains raw pointer from offset. Never throws.*/
|
||||
//!Obtains raw pointer from offset. Never throws.
|
||||
pointer get() const
|
||||
{ return m_ptr; }
|
||||
|
||||
/*!Pointer-like -> operator. It can return 0 pointer. Never throws.*/
|
||||
//!Pointer-like -> operator. It can return 0 pointer. Never throws.
|
||||
pointer operator->() const
|
||||
{ return this->get(); }
|
||||
|
||||
/*!Dereferencing operator, if it is a null smart_ptr behavior
|
||||
is undefined. Never throws.*/
|
||||
//!Dereferencing operator, if it is a null smart_ptr behavior
|
||||
//! is undefined. Never throws.
|
||||
reference operator* () const
|
||||
{ return *(this->get()); }
|
||||
|
||||
/*!Indexing operator. Never throws.*/
|
||||
//!Indexing operator. Never throws.
|
||||
reference operator[](std::ptrdiff_t idx) const
|
||||
{ return this->get()[idx]; }
|
||||
|
||||
/*!Assignment from pointer (saves extra conversion). Never throws.*/
|
||||
//!Assignment from pointer (saves extra conversion). Never throws.
|
||||
smart_ptr& operator= (pointer from)
|
||||
{ m_ptr = from; return *this; }
|
||||
|
||||
/*!Assignment from other smart_ptr. Never throws.*/
|
||||
//!Assignment from other smart_ptr. Never throws.
|
||||
smart_ptr& operator= (const smart_ptr & pt)
|
||||
{ m_ptr = pt.m_ptr; return *this; }
|
||||
|
||||
/*!Assignment from related smart_ptr. If pointers of pointee types
|
||||
are assignable, offset_ptrs will be assignable. Never throws.*/
|
||||
//!Assignment from related smart_ptr. If pointers of pointee types
|
||||
//! are assignable, offset_ptrs will be assignable. Never throws.
|
||||
template <class T2>
|
||||
smart_ptr& operator= (const smart_ptr<T2> & pt)
|
||||
{ m_ptr = pt.m_ptr; return *this; }
|
||||
|
||||
/*!smart_ptr + std::ptrdiff_t. Never throws.*/
|
||||
//!smart_ptr + std::ptrdiff_t. Never throws.
|
||||
smart_ptr operator+ (std::ptrdiff_t offset) const
|
||||
{ return smart_ptr(this->get()+offset); }
|
||||
|
||||
/*!smart_ptr - std::ptrdiff_t. Never throws.*/
|
||||
//!smart_ptr - std::ptrdiff_t. Never throws.
|
||||
smart_ptr operator- (std::ptrdiff_t offset) const
|
||||
{ return smart_ptr(this->get()-offset); }
|
||||
|
||||
/*!smart_ptr += std::ptrdiff_t. Never throws.*/
|
||||
//!smart_ptr += std::ptrdiff_t. Never throws.
|
||||
smart_ptr &operator+= (std::ptrdiff_t offset)
|
||||
{ m_ptr += offset; return *this; }
|
||||
|
||||
/*!smart_ptr -= std::ptrdiff_t. Never throws.*/
|
||||
//!smart_ptr -= std::ptrdiff_t. Never throws.
|
||||
smart_ptr &operator-= (std::ptrdiff_t offset)
|
||||
{ m_ptr -= offset; return *this; }
|
||||
|
||||
/*!++smart_ptr. Never throws.*/
|
||||
//!++smart_ptr. Never throws.
|
||||
smart_ptr& operator++ (void)
|
||||
{ ++m_ptr; return *this; }
|
||||
|
||||
/*!smart_ptr++. Never throws.*/
|
||||
//!smart_ptr++. Never throws.
|
||||
smart_ptr operator++ (int)
|
||||
{ smart_ptr temp(*this); ++*this; return temp; }
|
||||
|
||||
/*!--smart_ptr. Never throws.*/
|
||||
//!--smart_ptr. Never throws.
|
||||
smart_ptr& operator-- (void)
|
||||
{ --m_ptr; return *this; }
|
||||
|
||||
/*!smart_ptr--. Never throws.*/
|
||||
//!smart_ptr--. Never throws.
|
||||
smart_ptr operator-- (int)
|
||||
{ smart_ptr temp(*this); --*this; return temp; }
|
||||
|
||||
/*!safe bool conversion operator. Never throws.*/
|
||||
//!safe bool conversion operator. Never throws.
|
||||
operator unspecified_bool_type() const
|
||||
{ return this->get()? &self_t::unspecified_bool_type_func : 0; }
|
||||
|
||||
/*!Not operator. Not needed in theory, but improves portability.
|
||||
Never throws.*/
|
||||
//!Not operator. Not needed in theory, but improves portability.
|
||||
//!Never throws.
|
||||
bool operator! () const
|
||||
{ return this->get() == 0; }
|
||||
/*
|
||||
@@ -235,65 +234,65 @@ class smart_ptr
|
||||
*/
|
||||
};
|
||||
|
||||
/*!smart_ptr<T1> == smart_ptr<T2>. Never throws.*/
|
||||
//!smart_ptr<T1> == smart_ptr<T2>. Never throws.
|
||||
template<class T1, class T2>
|
||||
inline bool operator== (const smart_ptr<T1> &pt1,
|
||||
const smart_ptr<T2> &pt2)
|
||||
{ return pt1.get() == pt2.get(); }
|
||||
|
||||
/*!smart_ptr<T1> != smart_ptr<T2>. Never throws.*/
|
||||
//!smart_ptr<T1> != smart_ptr<T2>. Never throws.
|
||||
template<class T1, class T2>
|
||||
inline bool operator!= (const smart_ptr<T1> &pt1,
|
||||
const smart_ptr<T2> &pt2)
|
||||
{ return pt1.get() != pt2.get(); }
|
||||
|
||||
/*!smart_ptr<T1> < smart_ptr<T2>. Never throws.*/
|
||||
//!smart_ptr<T1> < smart_ptr<T2>. Never throws.
|
||||
template<class T1, class T2>
|
||||
inline bool operator< (const smart_ptr<T1> &pt1,
|
||||
const smart_ptr<T2> &pt2)
|
||||
{ return pt1.get() < pt2.get(); }
|
||||
|
||||
/*!smart_ptr<T1> <= smart_ptr<T2>. Never throws.*/
|
||||
//!smart_ptr<T1> <= smart_ptr<T2>. Never throws.
|
||||
template<class T1, class T2>
|
||||
inline bool operator<= (const smart_ptr<T1> &pt1,
|
||||
const smart_ptr<T2> &pt2)
|
||||
{ return pt1.get() <= pt2.get(); }
|
||||
|
||||
/*!smart_ptr<T1> > smart_ptr<T2>. Never throws.*/
|
||||
//!smart_ptr<T1> > smart_ptr<T2>. Never throws.
|
||||
template<class T1, class T2>
|
||||
inline bool operator> (const smart_ptr<T1> &pt1,
|
||||
const smart_ptr<T2> &pt2)
|
||||
{ return pt1.get() > pt2.get(); }
|
||||
|
||||
/*!smart_ptr<T1> >= smart_ptr<T2>. Never throws.*/
|
||||
//!smart_ptr<T1> >= smart_ptr<T2>. Never throws.
|
||||
template<class T1, class T2>
|
||||
inline bool operator>= (const smart_ptr<T1> &pt1,
|
||||
const smart_ptr<T2> &pt2)
|
||||
{ return pt1.get() >= pt2.get(); }
|
||||
|
||||
/*!operator<< */
|
||||
//!operator<<
|
||||
template<class E, class T, class Y>
|
||||
inline std::basic_ostream<E, T> & operator<<
|
||||
(std::basic_ostream<E, T> & os, smart_ptr<Y> const & p)
|
||||
{ return os << p.get(); }
|
||||
|
||||
/*!operator>> */
|
||||
//!operator>>
|
||||
template<class E, class T, class Y>
|
||||
inline std::basic_istream<E, T> & operator>>
|
||||
(std::basic_istream<E, T> & os, smart_ptr<Y> & p)
|
||||
{ Y * tmp; return os >> tmp; p = tmp; }
|
||||
|
||||
/*!std::ptrdiff_t + smart_ptr */
|
||||
//!std::ptrdiff_t + smart_ptr
|
||||
template<class T>
|
||||
inline smart_ptr<T> operator+(std::ptrdiff_t diff, const smart_ptr<T>& right)
|
||||
{ return right + diff; }
|
||||
|
||||
/*!smart_ptr - smart_ptr */
|
||||
//!smart_ptr - smart_ptr
|
||||
template<class T, class T2>
|
||||
inline std::ptrdiff_t operator- (const smart_ptr<T> &pt, const smart_ptr<T2> &pt2)
|
||||
{ return pt.get()- pt2.get(); }
|
||||
|
||||
/*!swap specialization */
|
||||
//!swap specialization
|
||||
template<class T>
|
||||
inline void swap (smart_ptr<T> &pt,
|
||||
smart_ptr<T> &pt2)
|
||||
@@ -303,13 +302,13 @@ inline void swap (smart_ptr<T> &pt,
|
||||
pt2 = ptr;
|
||||
}
|
||||
|
||||
/*!get_pointer() enables boost::mem_fn to recognize smart_ptr.
|
||||
Never throws.*/
|
||||
//!detail::get_pointer() enables boost::mem_fn to recognize smart_ptr.
|
||||
//!Never throws.
|
||||
template<class T>
|
||||
inline T* get_pointer(const smart_ptr<T> & p)
|
||||
{ return p.get(); }
|
||||
|
||||
/*!Simulation of static_cast between pointers. Never throws.*/
|
||||
//!Simulation of static_cast between pointers. Never throws.
|
||||
template<class T, class U>
|
||||
inline smart_ptr<T>
|
||||
static_pointer_cast(smart_ptr<U> const & r)
|
||||
@@ -317,14 +316,14 @@ inline smart_ptr<T>
|
||||
return smart_ptr<T>(r, detail::static_cast_tag());
|
||||
}
|
||||
|
||||
/*!Simulation of const_cast between pointers. Never throws.*/
|
||||
//!Simulation of const_cast between pointers. Never throws.
|
||||
template<class T, class U>
|
||||
inline smart_ptr<T>const_pointer_cast(smart_ptr<U> const & r)
|
||||
{
|
||||
return smart_ptr<T>(r, detail::const_cast_tag());
|
||||
}
|
||||
|
||||
/*!Simulation of dynamic_cast between pointers. Never throws.*/
|
||||
//!Simulation of dynamic_cast between pointers. Never throws.
|
||||
template<class T, class U>
|
||||
inline smart_ptr<T>
|
||||
dynamic_pointer_cast(smart_ptr<U> const & r)
|
||||
@@ -333,7 +332,7 @@ inline smart_ptr<T>
|
||||
(r, detail::dynamic_cast_tag());
|
||||
}
|
||||
|
||||
/*!Simulation of reinterpret_cast between pointers. Never throws.*/
|
||||
//!Simulation of reinterpret_cast between pointers. Never throws.
|
||||
template<class T, class U>
|
||||
inline smart_ptr<T>
|
||||
reinterpret_pointer_cast(smart_ptr<U> const & r)
|
||||
|
@@ -71,8 +71,11 @@ void test_sequence_container(Container & c, Data & d)
|
||||
BOOST_TEST( c.size() == 0 );
|
||||
BOOST_TEST( c.empty() );
|
||||
|
||||
c.insert( c.begin(), *d.begin() );
|
||||
c.insert( c.end(), *(++d.begin()) );
|
||||
{
|
||||
typename Data::iterator i = d.begin();
|
||||
c.insert( c.begin(), *i );
|
||||
c.insert( c.end(), *(++i) );
|
||||
}
|
||||
|
||||
BOOST_TEST( c.size() == 2 );
|
||||
BOOST_TEST( !c.empty() );
|
||||
@@ -81,7 +84,11 @@ void test_sequence_container(Container & c, Data & d)
|
||||
|
||||
BOOST_TEST( c.size() == 1 );
|
||||
|
||||
c.insert( c.begin(), *(++++d.begin()) );
|
||||
{
|
||||
typename Data::iterator i = d.begin();
|
||||
++++i;
|
||||
c.insert( c.begin(), *(i) );
|
||||
}
|
||||
|
||||
c.erase( c.begin(), c.end() );
|
||||
|
||||
@@ -121,8 +128,8 @@ void test_common_unordered_and_associative_container(Container & c, Data & d)
|
||||
BOOST_TEST( c.find(*di) != c.end() );
|
||||
}
|
||||
|
||||
typename Data::const_iterator da = d.begin();
|
||||
typename Data::const_iterator db = ++d.begin();
|
||||
typename Data::const_iterator db = d.begin();
|
||||
typename Data::const_iterator da = db++;
|
||||
|
||||
size_type old_size = c.size();
|
||||
|
||||
|
Reference in New Issue
Block a user