mirror of
https://github.com/boostorg/intrusive.git
synced 2025-08-02 14:04:36 +02:00
Fixed errors when running MSVC x64 tests.
This commit is contained in:
@@ -250,33 +250,21 @@ class circular_slist_algorithms
|
|||||||
{
|
{
|
||||||
if (other_node == this_node)
|
if (other_node == this_node)
|
||||||
return;
|
return;
|
||||||
bool this_inited = base_t::inited(this_node);
|
const node_ptr this_next = NodeTraits::get_next(this_node);
|
||||||
bool other_inited = base_t::inited(other_node);
|
const node_ptr other_next = NodeTraits::get_next(other_node);
|
||||||
if(this_inited){
|
const bool this_null = !this_next;
|
||||||
base_t::init_header(this_node);
|
const bool other_null = !other_next;
|
||||||
}
|
const bool this_empty = this_next == this_node;
|
||||||
if(other_inited){
|
const bool other_empty = other_next == other_node;
|
||||||
base_t::init_header(other_node);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool empty1 = base_t::unique(this_node);
|
if(!(other_null || other_empty)){
|
||||||
bool empty2 = base_t::unique(other_node);
|
NodeTraits::set_next(this_next == other_node ? other_node : get_previous_node(other_node), this_node );
|
||||||
node_ptr prev_this (get_previous_node(this_node));
|
|
||||||
node_ptr prev_other(get_previous_node(other_node));
|
|
||||||
|
|
||||||
node_ptr this_next (NodeTraits::get_next(this_node));
|
|
||||||
node_ptr other_next(NodeTraits::get_next(other_node));
|
|
||||||
NodeTraits::set_next(this_node, other_next);
|
|
||||||
NodeTraits::set_next(other_node, this_next);
|
|
||||||
NodeTraits::set_next(empty1 ? other_node : prev_this, other_node);
|
|
||||||
NodeTraits::set_next(empty2 ? this_node : prev_other, this_node);
|
|
||||||
|
|
||||||
if(this_inited){
|
|
||||||
base_t::init(other_node);
|
|
||||||
}
|
}
|
||||||
if(other_inited){
|
if(!(this_null | this_empty)){
|
||||||
base_t::init(this_node);
|
NodeTraits::set_next(other_next == this_node ? this_node : get_previous_node(this_node), other_node );
|
||||||
}
|
}
|
||||||
|
NodeTraits::set_next(this_node, other_empty ? this_node : (other_next == this_node ? other_node : other_next) );
|
||||||
|
NodeTraits::set_next(other_node, this_empty ? other_node : (this_next == other_node ? this_node : this_next ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//! <b>Effects</b>: Reverses the order of elements in the list.
|
//! <b>Effects</b>: Reverses the order of elements in the list.
|
||||||
|
@@ -43,9 +43,6 @@ class common_slist_algorithms
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_header(const node_ptr & this_node)
|
|
||||||
{ NodeTraits::set_next(this_node, this_node); }
|
|
||||||
|
|
||||||
static void init(const node_ptr & this_node)
|
static void init(const node_ptr & this_node)
|
||||||
{ NodeTraits::set_next(this_node, node_ptr()); }
|
{ NodeTraits::set_next(this_node, node_ptr()); }
|
||||||
|
|
||||||
|
@@ -2711,15 +2711,16 @@ class hashtable_impl
|
|||||||
static std::size_t priv_stored_hash(slist_node_ptr n, detail::false_ false_value)
|
static std::size_t priv_stored_hash(slist_node_ptr n, detail::false_ false_value)
|
||||||
{ return bucket_plus_vtraits<ValueTraits, BucketTraits>::priv_stored_hash(n, false_value); }
|
{ return bucket_plus_vtraits<ValueTraits, BucketTraits>::priv_stored_hash(n, false_value); }
|
||||||
|
|
||||||
void priv_clear_buckets(bucket_ptr buckets_ptr, size_type bucket_cnt)
|
void priv_clear_buckets(const bucket_ptr buckets_ptr, const size_type bucket_cnt)
|
||||||
{
|
{
|
||||||
for(; bucket_cnt--; ++buckets_ptr){
|
bucket_ptr buckets_it = buckets_ptr;
|
||||||
|
for(size_type bucket_i = 0; bucket_i != bucket_cnt; ++buckets_it, ++bucket_i){
|
||||||
if(safemode_or_autounlink){
|
if(safemode_or_autounlink){
|
||||||
bucket_plus_vtraits_t::priv_clear_group_nodes(*buckets_ptr, optimize_multikey_t());
|
bucket_plus_vtraits_t::priv_clear_group_nodes(*buckets_it, optimize_multikey_t());
|
||||||
buckets_ptr->clear_and_dispose(detail::init_disposer<node_algorithms>());
|
buckets_it->clear_and_dispose(detail::init_disposer<node_algorithms>());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
buckets_ptr->clear();
|
buckets_it->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->priv_initialize_cache();
|
this->priv_initialize_cache();
|
||||||
|
@@ -189,7 +189,15 @@ struct pointer_traits
|
|||||||
|
|
||||||
template<class UPtr>
|
template<class UPtr>
|
||||||
static pointer priv_dynamic_cast_from(boost::false_type, const UPtr &uptr)
|
static pointer priv_dynamic_cast_from(boost::false_type, const UPtr &uptr)
|
||||||
{ return pointer_to(*dynamic_cast<element_type*>(&*uptr)); }
|
{
|
||||||
|
element_type *p = dynamic_cast<element_type*>(&*uptr);
|
||||||
|
if(!p){
|
||||||
|
return pointer();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return pointer_to(*p);
|
||||||
|
}
|
||||||
|
}
|
||||||
///@endcond
|
///@endcond
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -52,8 +52,8 @@ struct testvalue
|
|||||||
// have to be handled appropriately when copied:
|
// have to be handled appropriately when copied:
|
||||||
testvalue & operator= (const testvalue& src)
|
testvalue & operator= (const testvalue& src)
|
||||||
{
|
{
|
||||||
Hooks::base_hook_type::operator=(src);
|
Hooks::base_hook_type::operator=(static_cast<const Hooks::base_hook_type&>(src));
|
||||||
Hooks::auto_base_hook_type::operator=(src);
|
Hooks::auto_base_hook_type::operator=(static_cast<const Hooks::auto_base_hook_type&>(src));
|
||||||
this->node_ = src.node_;
|
this->node_ = src.node_;
|
||||||
this->auto_node_ = src.auto_node_;
|
this->auto_node_ = src.auto_node_;
|
||||||
value_ = src.value_;
|
value_ = src.value_;
|
||||||
@@ -62,8 +62,8 @@ struct testvalue
|
|||||||
|
|
||||||
void swap_nodes(testvalue &other)
|
void swap_nodes(testvalue &other)
|
||||||
{
|
{
|
||||||
Hooks::base_hook_type::swap_nodes(other);
|
Hooks::base_hook_type::swap_nodes(static_cast<Hooks::base_hook_type&>(other));
|
||||||
Hooks::auto_base_hook_type::swap_nodes(other);
|
Hooks::auto_base_hook_type::swap_nodes(static_cast<Hooks::auto_base_hook_type&>(other));
|
||||||
node_.swap_nodes(other.node_);
|
node_.swap_nodes(other.node_);
|
||||||
auto_node_.swap_nodes(other.auto_node_);
|
auto_node_.swap_nodes(other.auto_node_);
|
||||||
}
|
}
|
||||||
|
@@ -456,23 +456,32 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
|||||||
}
|
}
|
||||||
if(!list_type::linear)
|
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 };
|
{ int init_values [] = { 1 };
|
||||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
values[1].swap_nodes(values[2]);
|
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 };
|
{ int init_values [] = { 1 };
|
||||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
values[0].swap_nodes(values[2]);
|
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 };
|
{ int init_values [] = { 3 };
|
||||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
values[0].swap_nodes(values[2]);
|
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 };
|
{ int init_values [] = { 1 };
|
||||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
}
|
}
|
||||||
@@ -730,207 +739,3 @@ int main(int, char* [])
|
|||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
#include <boost/intrusive/detail/config_end.hpp>
|
#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;
|
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 intrusive {
|
||||||
} //namespace boost {
|
} //namespace boost {
|
||||||
|
|
||||||
|
@@ -13,14 +13,33 @@
|
|||||||
#ifndef BOOST_INTRUSIVE_TEST_TEST_MACROS_HPP
|
#ifndef BOOST_INTRUSIVE_TEST_TEST_MACROS_HPP
|
||||||
#define 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 )\
|
#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 )\
|
#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
|
#endif
|
||||||
|
Reference in New Issue
Block a user