Fixed #9948: remove use of const_cast in intrusive containers.

Added tests for [s_]iterator_to.
This commit is contained in:
Ion Gaztañaga committed 2014-05-01 16:19:42 +02:00
1 parent 95dcc3bade
commit 7fc779ff0d
6 files changed
+57 -20

No files matched your search

+5 -3
View File
@@ -1685,7 +1685,8 @@ class slist_impl
static const_iterator s_iterator_to(const_reference value)
{
BOOST_STATIC_ASSERT((!stateful_value_traits));
return const_iterator(value_traits::to_node_ptr(*pointer_traits<pointer>::const_cast_from(pointer_traits<const_pointer>::pointer_to(value))), const_value_traits_ptr());
reference r =*pointer_traits<pointer>::const_cast_from(pointer_traits<const_pointer>::pointer_to(value));
return const_iterator(value_traits::to_node_ptr(r), const_value_traits_ptr());
}
//! <b>Requires</b>: value must be a reference to a value inserted in a list.
@@ -1714,8 +1715,9 @@ class slist_impl
//! <b>Note</b>: Iterators and references are not invalidated.
const_iterator iterator_to(const_reference value) const
{
BOOST_INTRUSIVE_INVARIANT_ASSERT (linear || !node_algorithms::inited(this->priv_value_traits().to_node_ptr(*pointer_traits<pointer>::const_cast_from(pointer_traits<const_pointer>::pointer_to(value)))));
return const_iterator(this->priv_value_traits().to_node_ptr(*pointer_traits<pointer>::const_cast_from(pointer_traits<const_pointer>::pointer_to(value))), this->value_traits_ptr());
reference r =*pointer_traits<pointer>::const_cast_from(pointer_traits<const_pointer>::pointer_to(value));
BOOST_INTRUSIVE_INVARIANT_ASSERT (linear || !node_algorithms::inited(this->priv_value_traits().to_node_ptr(r)));
return const_iterator(this->priv_value_traits().to_node_ptr(r), this->value_traits_ptr());
}
//! <b>Returns</b>: The iterator to the element before i in the list.