removed const_cast from bstree, list, and slist

This commit is contained in:
Matei David
2014-03-31 19:03:13 -04:00
parent 26acf03a9b
commit 1391668ed2
3 changed files with 15 additions and 15 deletions

View File

@@ -184,14 +184,14 @@ struct bstbase3
static const_iterator s_iterator_to(const_reference value)
{
BOOST_STATIC_ASSERT((!stateful_value_traits));
return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), const_value_traits_ptr());
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());
}
iterator iterator_to(reference value)
{ return iterator (this->get_value_traits().to_node_ptr(value), this->value_traits_ptr()); }
const_iterator iterator_to(const_reference value) const
{ return const_iterator (this->get_value_traits().to_node_ptr(const_cast<reference> (value)), this->value_traits_ptr()); }
{ return const_iterator (this->get_value_traits().to_node_ptr(*pointer_traits<pointer>::const_cast_from(pointer_traits<const_pointer>::pointer_to(value))), this->value_traits_ptr()); }
static void init_node(reference value)
{ node_algorithms::init(value_traits::to_node_ptr(value)); }
@@ -223,7 +223,7 @@ struct bstbase2
const value_compare &comp() const
{ return this->get(); }
value_compare &comp()
{ return this->get(); }
@@ -489,7 +489,7 @@ struct bstbase_hack<ValueTraits, VoidOrKeyComp, false, SizeType, AlgoType>
const size_traits &sz_traits() const
{ return s_size_traits; }
static size_traits s_size_traits;
};
@@ -822,7 +822,7 @@ class bstree_impl
//!
//! <b>Throws</b>: If value_compare copy-constructor throws.
key_compare key_comp() const;
//! <b>Effects</b>: Returns the value_compare object used by the container.
//!
//! <b>Complexity</b>: Constant.
@@ -1492,7 +1492,7 @@ class bstree_impl
//! <b>Throws</b>: If `comp` throws.
template<class KeyType, class KeyValueCompare>
iterator lower_bound(const KeyType &key, KeyValueCompare comp);
//! <b>Effects</b>: Returns a const iterator to the first element whose
//! key is not less than k or end() if that element does not exist.
//!
@@ -1634,7 +1634,7 @@ class bstree_impl
//! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
//! ordering compatible with the strict weak ordering used to create the
//! the container.
//! the container.
//! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
//! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
//!
@@ -1678,7 +1678,7 @@ class bstree_impl
//! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
//! ordering compatible with the strict weak ordering used to create the
//! the container.
//! the container.
//! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
//! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
//!

View File

@@ -1213,8 +1213,8 @@ class list_impl
static const_iterator s_iterator_to(const_reference value)
{
BOOST_STATIC_ASSERT((!stateful_value_traits));
BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(value_traits::to_node_ptr(const_cast<reference> (value))));
return const_iterator(value_traits::to_node_ptr(const_cast<reference> (value)), const_value_traits_ptr());
BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(value_traits::to_node_ptr(*pointer_traits<pointer>::const_cast_from(pointer_traits<const_pointer>::pointer_to(value)))));
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());
}
//! <b>Requires</b>: value must be a reference to a value inserted in a list.
@@ -1243,8 +1243,8 @@ class list_impl
//! <b>Note</b>: Iterators and references are not invalidated.
const_iterator iterator_to(const_reference value) const
{
BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(this->priv_value_traits().to_node_ptr(const_cast<reference> (value))));
return const_iterator(this->priv_value_traits().to_node_ptr(const_cast<reference> (value)), value_traits_ptr());
BOOST_INTRUSIVE_INVARIANT_ASSERT(!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))), value_traits_ptr());
}
/// @cond

View File

@@ -1686,7 +1686,7 @@ 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(const_cast<reference> (value)), const_value_traits_ptr());
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());
}
//! <b>Requires</b>: value must be a reference to a value inserted in a list.
@@ -1715,8 +1715,8 @@ 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(const_cast<reference> (value))));
return const_iterator(this->priv_value_traits().to_node_ptr(const_cast<reference> (value)), this->value_traits_ptr());
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());
}
//! <b>Returns</b>: The iterator to the element before i in the list.