Added bounds checking via BOOST_ASSERT to operator[]

[SVN r83797]
This commit is contained in:
Ion Gaztañaga
2013-04-07 19:11:22 +00:00
parent 409b3fa27b
commit 3e8acdcb8c

View File

@@ -1127,7 +1127,10 @@ class stable_vector
//!
//! <b>Complexity</b>: Constant.
reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
{ return static_cast<node_reference>(*this->index[n]).value; }
{
BOOST_ASSERT(n < this->size());
return static_cast<node_reference>(*this->index[n]).value;
}
//! <b>Requires</b>: size() > n.
//!
@@ -1138,7 +1141,10 @@ class stable_vector
//!
//! <b>Complexity</b>: Constant.
const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
{ return static_cast<const_node_reference>(*this->index[n]).value; }
{
BOOST_ASSERT(n < this->size());
return static_cast<const_node_reference>(*this->index[n]).value;
}
//! <b>Requires</b>: size() > n.
//!