mirror of
https://github.com/boostorg/intrusive.git
synced 2025-08-02 14:04:36 +02:00
Fixed #9961: tests for hooks not derived frorm generic_hook
This commit is contained in:
@@ -3800,6 +3800,7 @@ to be inserted in intrusive containers are allocated using `std::vector` or `std
|
||||
* [@https://svn.boost.org/trac/boost/ticket/9746 #9746: Modern Sun CC compiler detects error in intrusive library header]
|
||||
* [@https://svn.boost.org/trac/boost/ticket/9940 #9940: bad bug in intrusive list with safe_link (or auto_unlink) hooks]
|
||||
* [@https://svn.boost.org/trac/boost/ticket/9949 #9949: clear header node hooks upon intrusive container destruction]
|
||||
* [@https://svn.boost.org/trac/boost/ticket/9961 #9961: tests for hooks not derived frorm generic_hook]
|
||||
|
||||
* Optimized tree rebalancing code to avoid redundant assignments.
|
||||
|
||||
|
@@ -318,6 +318,9 @@
|
||||
<File
|
||||
RelativePath="..\..\..\test\Jamfile.v2">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\test\nonhook_node.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\test\smart_ptr.hpp">
|
||||
</File>
|
||||
|
@@ -1,16 +1,30 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Matei David 2014-2014.
|
||||
// (C) Copyright Ion Gaztanaga 2014-2014.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/intrusive for documentation.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BOOST_INTRUSIVE_DETAIL_NONHOOK_NODE_HPP
|
||||
#define BOOST_INTRUSIVE_DETAIL_NONHOOK_NODE_HPP
|
||||
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <boost/intrusive/list.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/intrusive/detail/utilities.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
|
||||
namespace boost{
|
||||
namespace intrusive{
|
||||
|
||||
|
||||
//This node will only be used in safe or auto unlink modes
|
||||
//so test it's been properly released
|
||||
template < typename Node_Traits, template <typename> class Node_Algorithms >
|
||||
struct nonhook_node_member : public Node_Traits::node
|
||||
{
|
||||
@@ -24,29 +38,23 @@ struct nonhook_node_member : public Node_Traits::node
|
||||
{
|
||||
node_algorithms::init(pointer_traits<node_ptr>::pointer_to(static_cast< node& >(*this)));
|
||||
}
|
||||
|
||||
nonhook_node_member(const nonhook_node_member& rhs)
|
||||
{
|
||||
if (rhs.is_linked())
|
||||
{
|
||||
std::cerr << "nonhook_node_member copy ctor from linked: &=" << (void*)this << ", rhs=" << (void*)&rhs << std::endl;
|
||||
}
|
||||
BOOST_TEST(!rhs.is_linked());
|
||||
*this = rhs;
|
||||
}
|
||||
|
||||
nonhook_node_member& operator = (const nonhook_node_member& rhs)
|
||||
{
|
||||
if (is_linked() or rhs.is_linked())
|
||||
{
|
||||
std::cerr << "nonhook_node_member copy asop to/from linked: &=" << (void*)this << ", rhs=" << (void*)&rhs << std::endl;
|
||||
}
|
||||
BOOST_TEST(!this->is_linked() && !rhs.is_linked());
|
||||
static_cast< node& >(*this) = rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~nonhook_node_member()
|
||||
{
|
||||
if (is_linked())
|
||||
{
|
||||
std::cerr << "nonhook_node_member dtor of linked: &=" << (void*)this << std::endl;
|
||||
}
|
||||
BOOST_TEST(!this->is_linked());
|
||||
node_algorithms::init(pointer_traits<node_ptr>::pointer_to(static_cast< node& >(*this)));
|
||||
}
|
||||
|
||||
@@ -55,6 +63,7 @@ struct nonhook_node_member : public Node_Traits::node
|
||||
node_algorithms::swap_nodes(pointer_traits<node_ptr>::pointer_to(static_cast< node& >(*this)),
|
||||
pointer_traits<node_ptr>::pointer_to(static_cast< node& >(other)));
|
||||
}
|
||||
|
||||
bool is_linked() const
|
||||
{
|
||||
return !node_algorithms::unique(pointer_traits<const_node_ptr>::pointer_to(static_cast< const node& >(*this)));
|
||||
@@ -78,6 +87,8 @@ struct nonhook_node_member_value_traits
|
||||
|
||||
static const link_mode_type link_mode = Link_Mode;
|
||||
|
||||
BOOST_STATIC_ASSERT((Link_Mode == safe_link || Link_Mode == auto_unlink));
|
||||
|
||||
static node_ptr to_node_ptr(reference value)
|
||||
{
|
||||
return pointer_traits<node_ptr>::pointer_to(static_cast<node&>(value.*P));
|
||||
|
Reference in New Issue
Block a user