forked from boostorg/intrusive
Merge branch 'develop'
This commit is contained in:
commit
9f636d5bb1
14 files changed
+286
-341
No files matched your search
+4
-4
@@ -52,8 +52,8 @@ struct testvalue
|
||||
// have to be handled appropriately when copied:
|
||||
testvalue & operator= (const testvalue& src)
|
||||
{
|
||||
Hooks::base_hook_type::operator=(src);
|
||||
Hooks::auto_base_hook_type::operator=(src);
|
||||
Hooks::base_hook_type::operator=(static_cast<const typename Hooks::base_hook_type&>(src));
|
||||
Hooks::auto_base_hook_type::operator=(static_cast<const typename Hooks::auto_base_hook_type&>(src));
|
||||
this->node_ = src.node_;
|
||||
this->auto_node_ = src.auto_node_;
|
||||
value_ = src.value_;
|
||||
@@ -62,8 +62,8 @@ struct testvalue
|
||||
|
||||
void swap_nodes(testvalue &other)
|
||||
{
|
||||
Hooks::base_hook_type::swap_nodes(other);
|
||||
Hooks::auto_base_hook_type::swap_nodes(other);
|
||||
Hooks::base_hook_type::swap_nodes(static_cast<typename Hooks::base_hook_type&>(other));
|
||||
Hooks::auto_base_hook_type::swap_nodes(static_cast<typename Hooks::auto_base_hook_type&>(other));
|
||||
node_.swap_nodes(other.node_);
|
||||
auto_node_.swap_nodes(other.auto_node_);
|
||||
}
|
||||
|
||||
+13
-208
@@ -456,23 +456,32 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
}
|
||||
if(!list_type::linear)
|
||||
{
|
||||
list_type testlist1 (&values[0], &values[1]);
|
||||
|
||||
list_type testlist1 (&values[0], &values[0]+1);
|
||||
if(testlist1.size() != 1){
|
||||
abort();
|
||||
}
|
||||
{ int init_values [] = { 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
values[1].swap_nodes(values[2]);
|
||||
|
||||
BOOST_TEST(testlist1.size() == 1);
|
||||
BOOST_TEST(!values[1].is_linked());
|
||||
BOOST_TEST(!values[2].is_linked());
|
||||
{ int init_values [] = { 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
values[0].swap_nodes(values[2]);
|
||||
|
||||
BOOST_TEST(testlist1.size() == 1);
|
||||
BOOST_TEST(values[2].is_linked());
|
||||
BOOST_TEST(!values[0].is_linked());
|
||||
{ int init_values [] = { 3 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
values[0].swap_nodes(values[2]);
|
||||
|
||||
BOOST_TEST(testlist1.size() == 1);
|
||||
BOOST_TEST(!values[2].is_linked());
|
||||
BOOST_TEST(values[0].is_linked());
|
||||
{ int init_values [] = { 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
}
|
||||
@@ -730,207 +739,3 @@ int main(int, char* [])
|
||||
return boost::report_errors();
|
||||
}
|
||||
#include <boost/intrusive/detail/config_end.hpp>
|
||||
|
||||
/*
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/intrusive/list.hpp>
|
||||
#include <boost/intrusive/set.hpp>
|
||||
|
||||
namespace intrusive = boost::intrusive;
|
||||
|
||||
class object : public boost::noncopyable
|
||||
{
|
||||
public:
|
||||
int o;
|
||||
object()
|
||||
{
|
||||
}
|
||||
virtual ~object()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class signal : virtual public object
|
||||
{
|
||||
public:
|
||||
signal()
|
||||
{
|
||||
}
|
||||
virtual ~signal()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class set_item : public signal
|
||||
{
|
||||
public:
|
||||
set_item()
|
||||
{
|
||||
}
|
||||
virtual ~set_item()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual const std::string& get_buffer() const
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
typedef intrusive::set_member_hook<
|
||||
intrusive::link_mode<intrusive::auto_unlink>
|
||||
> hook;
|
||||
hook m_hook;
|
||||
|
||||
std::string m_buffer;
|
||||
};
|
||||
|
||||
|
||||
template <class T, class M, M (T::*V)>
|
||||
struct member_comparator
|
||||
{
|
||||
bool operator()(const T& t1, const T& t2) const
|
||||
{
|
||||
return (t1.*V) < (t2.*V);
|
||||
}
|
||||
bool operator()(const M& m, const T& t) const
|
||||
{
|
||||
return m < (t.*V);
|
||||
}
|
||||
bool operator()(const T& t, const M& m) const
|
||||
{
|
||||
return (t.*V) < m;
|
||||
}
|
||||
};
|
||||
|
||||
class kk{ int a; float f; };
|
||||
|
||||
class list_item : public kk, virtual public object
|
||||
{
|
||||
public:
|
||||
list_item()
|
||||
{
|
||||
}
|
||||
virtual ~list_item()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void f()
|
||||
{
|
||||
}
|
||||
|
||||
typedef intrusive::list_member_hook<
|
||||
intrusive::link_mode<intrusive::auto_unlink>
|
||||
> hook;
|
||||
hook m_hook;
|
||||
};
|
||||
|
||||
set_item srec;
|
||||
list_item lrec;
|
||||
|
||||
const set_item::hook set_item::* sptr_to_member = &set_item::m_hook;
|
||||
const list_item::hook list_item::* lptr_to_member = &list_item::m_hook;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int a = sizeof(sptr_to_member);
|
||||
int b = sizeof(lptr_to_member);
|
||||
const std::type_info &ta = typeid(set_item);
|
||||
const std::type_info &tb = typeid(list_item);
|
||||
|
||||
const set_item::hook &sh = srec.*sptr_to_member;
|
||||
const list_item::hook &l2 = lrec.*lptr_to_member;
|
||||
|
||||
{
|
||||
typedef member_comparator<
|
||||
set_item,
|
||||
std::string,
|
||||
&set_item::m_buffer
|
||||
> set_item_comparator;
|
||||
|
||||
typedef intrusive::set<
|
||||
set_item,
|
||||
intrusive::compare<set_item_comparator>,
|
||||
intrusive::member_hook<
|
||||
set_item,
|
||||
set_item::hook,
|
||||
&set_item::m_hook
|
||||
>,
|
||||
intrusive::constant_time_size<false>
|
||||
> set_items
|
||||
;
|
||||
|
||||
union
|
||||
{
|
||||
int as_int[2];
|
||||
const set_item::hook set_item::* ptr_to_member;
|
||||
}
|
||||
sss;
|
||||
sss.ptr_to_member = &set_item::m_hook;
|
||||
|
||||
std::cout << "set offsets: " << sss.as_int[0] << ":" << sss.as_int[1] << " and " << offsetof(set_item,m_hook) << std::endl;
|
||||
|
||||
set_items rr;
|
||||
|
||||
std::string key = "123";
|
||||
set_items::insert_commit_data icd;
|
||||
std::pair<set_items::iterator,bool> ir = rr.insert_check(
|
||||
key,
|
||||
set_item_comparator(),
|
||||
icd
|
||||
);
|
||||
|
||||
if ( !ir.second )
|
||||
{
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
set_item rec;
|
||||
rec.m_buffer = key;
|
||||
set_items::iterator i = rr.insert_commit( rec, icd );
|
||||
|
||||
set_item* rrr = &(*i);
|
||||
|
||||
std::cout << "set pointers: " << ((void*)rrr) << " and " << ((void*)&rec) << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef intrusive::list<
|
||||
list_item,
|
||||
intrusive::member_hook<
|
||||
list_item,
|
||||
list_item::hook,
|
||||
&list_item::m_hook
|
||||
>,
|
||||
intrusive::constant_time_size<false>
|
||||
> list_items
|
||||
;
|
||||
|
||||
union
|
||||
{
|
||||
int as_int[2];
|
||||
const list_item::hook list_item::* ptr_to_member;
|
||||
}
|
||||
sss;
|
||||
sss.ptr_to_member = &list_item::m_hook;
|
||||
|
||||
std::cout << "list offsets: " << sss.as_int[0] << ":" << sss.as_int[1] << " and " << offsetof(list_item,m_hook) << std::endl;
|
||||
|
||||
list_items rr;
|
||||
|
||||
list_item rec;
|
||||
const list_item::hook &h = rec.*sss.ptr_to_member;
|
||||
rr.push_back( rec );
|
||||
|
||||
list_item* rrr = &rr.front();
|
||||
|
||||
std::cout << "list pointers: " << ((void*)rrr) << " and " << ((void*)&rec) << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
@@ -261,38 +261,6 @@ inline void swap (smart_ptr<T> &pt,
|
||||
pt2 = ptr;
|
||||
}
|
||||
|
||||
//!Simulation of static_cast between pointers. Never throws.
|
||||
template<class T, class U>
|
||||
inline smart_ptr<T>
|
||||
static_pointer_cast(const smart_ptr<U> & r)
|
||||
{
|
||||
return smart_ptr<T>(r, detail::static_cast_tag());
|
||||
}
|
||||
|
||||
//!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.
|
||||
template<class T, class U>
|
||||
inline smart_ptr<T>
|
||||
dynamic_pointer_cast(smart_ptr<U> const & r)
|
||||
{
|
||||
return smart_ptr<T>
|
||||
(r, detail::dynamic_cast_tag());
|
||||
}
|
||||
|
||||
//!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)
|
||||
{
|
||||
return smart_ptr<T>(r, detail::reinterpret_cast_tag());
|
||||
}
|
||||
|
||||
} //namespace intrusive {
|
||||
} //namespace boost {
|
||||
|
||||
|
||||
+21
-2
@@ -13,14 +13,33 @@
|
||||
#ifndef BOOST_INTRUSIVE_TEST_TEST_MACROS_HPP
|
||||
#define BOOST_INTRUSIVE_TEST_TEST_MACROS_HPP
|
||||
|
||||
namespace boost{
|
||||
namespace intrusive{
|
||||
|
||||
template<class It1, class It2>
|
||||
bool test_equal(It1 f1, It1 l1, It2 f2)
|
||||
{
|
||||
while(f1 != l1){
|
||||
if(*f1 != *f2){
|
||||
return false;
|
||||
}
|
||||
++f1;
|
||||
++f2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#define TEST_INTRUSIVE_SEQUENCE( INTVALUES, ITERATOR )\
|
||||
{ \
|
||||
BOOST_TEST (std::equal(&INTVALUES[0], &INTVALUES[0] + sizeof(INTVALUES)/sizeof(INTVALUES[0]), ITERATOR) ); \
|
||||
BOOST_TEST (boost::intrusive::test_equal(&INTVALUES[0], &INTVALUES[0] + sizeof(INTVALUES)/sizeof(INTVALUES[0]), ITERATOR) ); \
|
||||
}
|
||||
|
||||
#define TEST_INTRUSIVE_SEQUENCE_EXPECTED( EXPECTEDVECTOR, ITERATOR )\
|
||||
{ \
|
||||
BOOST_TEST (std::equal(EXPECTEDVECTOR.begin(), EXPECTEDVECTOR.end(), ITERATOR) ); \
|
||||
BOOST_TEST (boost::intrusive::test_equal(EXPECTEDVECTOR.begin(), EXPECTEDVECTOR.end(), ITERATOR) ); \
|
||||
}
|
||||
|
||||
} //namespace boost{
|
||||
} //namespace intrusive{
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user