mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 15:04:00 +00:00
Merge pull request #98 from boostorg/feature/string_view_remove_prefix_suffix_precondition
string_view: Change string_view::remove_prefix/suffix preconditions to use asserts
This commit is contained in:
commit
028a90b29d
@ -23,6 +23,7 @@
|
|||||||
#include <boost/io/ostream_put.hpp>
|
#include <boost/io/ostream_put.hpp>
|
||||||
#include <boost/utility/string_view_fwd.hpp>
|
#include <boost/utility/string_view_fwd.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -140,6 +141,8 @@ namespace boost {
|
|||||||
void clear() BOOST_NOEXCEPT { len_ = 0; } // Boost extension
|
void clear() BOOST_NOEXCEPT { len_ = 0; } // Boost extension
|
||||||
|
|
||||||
BOOST_CXX14_CONSTEXPR void remove_prefix(size_type n) {
|
BOOST_CXX14_CONSTEXPR void remove_prefix(size_type n) {
|
||||||
|
BOOST_ASSERT(n <= size());
|
||||||
|
// This check is deprecated and is left for backward compatibility. It will be removed in the future.
|
||||||
if ( n > len_ )
|
if ( n > len_ )
|
||||||
n = len_;
|
n = len_;
|
||||||
ptr_ += n;
|
ptr_ += n;
|
||||||
@ -147,6 +150,8 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CXX14_CONSTEXPR void remove_suffix(size_type n) {
|
BOOST_CXX14_CONSTEXPR void remove_suffix(size_type n) {
|
||||||
|
BOOST_ASSERT(n <= size());
|
||||||
|
// This check is deprecated and is left for backward compatibility. It will be removed in the future.
|
||||||
if ( n > len_ )
|
if ( n > len_ )
|
||||||
n = len_;
|
n = len_;
|
||||||
len_ -= n;
|
len_ -= n;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user