diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index 2de4ae1..3da8c64 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -1127,7 +1127,10 @@ class stable_vector //! //! Complexity: Constant. reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this->index[n]).value; } + { + BOOST_ASSERT(n < this->size()); + return static_cast(*this->index[n]).value; + } //! Requires: size() > n. //! @@ -1138,7 +1141,10 @@ class stable_vector //! //! Complexity: Constant. const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this->index[n]).value; } + { + BOOST_ASSERT(n < this->size()); + return static_cast(*this->index[n]).value; + } //! Requires: size() > n. //!