mirror of
https://github.com/boostorg/utility.git
synced 2025-07-30 04:47:30 +02:00
Revert "Make string_{view|ref} remove_prefix and remove_suffix throw on invalid lengths. Addresses issue #73"
This reverts commit 601fc9371f
.
This commit is contained in:
@ -147,15 +147,15 @@ namespace boost {
|
|||||||
// modifiers
|
// modifiers
|
||||||
void clear() { len_ = 0; }
|
void clear() { len_ = 0; }
|
||||||
void remove_prefix(size_type n) {
|
void remove_prefix(size_type n) {
|
||||||
if ( n > size())
|
if ( n > len_ )
|
||||||
BOOST_THROW_EXCEPTION( std::out_of_range ( "string_ref::substr" ) );
|
n = len_;
|
||||||
ptr_ += n;
|
ptr_ += n;
|
||||||
len_ -= n;
|
len_ -= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_suffix(size_type n) {
|
void remove_suffix(size_type n) {
|
||||||
if ( n > size())
|
if ( n > len_ )
|
||||||
BOOST_THROW_EXCEPTION( std::out_of_range ( "string_ref::substr" ) );
|
n = len_;
|
||||||
len_ -= n;
|
len_ -= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,15 +141,15 @@ 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) {
|
||||||
if ( n > size())
|
if ( n > len_ )
|
||||||
BOOST_THROW_EXCEPTION( std::out_of_range ( "string_ref::substr" ) );
|
n = len_;
|
||||||
ptr_ += n;
|
ptr_ += n;
|
||||||
len_ -= n;
|
len_ -= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CXX14_CONSTEXPR void remove_suffix(size_type n) {
|
BOOST_CXX14_CONSTEXPR void remove_suffix(size_type n) {
|
||||||
if ( n > size())
|
if ( n > len_ )
|
||||||
BOOST_THROW_EXCEPTION( std::out_of_range ( "string_ref::substr" ) );
|
n = len_;
|
||||||
len_ -= n;
|
len_ -= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,13 +74,6 @@ void test_remove ( const std::string &str ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ref = str;
|
|
||||||
try {
|
|
||||||
ref.remove_prefix(ref.size() + 1);
|
|
||||||
BOOST_TEST(false);
|
|
||||||
}
|
|
||||||
catch ( const std::out_of_range &) {}
|
|
||||||
|
|
||||||
for ( size_t i = 1; i < sz; ++ i ) {
|
for ( size_t i = 1; i < sz; ++ i ) {
|
||||||
work = str;
|
work = str;
|
||||||
ref = str;
|
ref = str;
|
||||||
@ -90,13 +83,6 @@ void test_remove ( const std::string &str ) {
|
|||||||
ref.remove_suffix (i);
|
ref.remove_suffix (i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ref = str;
|
|
||||||
try {
|
|
||||||
ref.remove_suffix(ref.size() + 1);
|
|
||||||
BOOST_TEST(false);
|
|
||||||
}
|
|
||||||
catch ( const std::out_of_range &) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *test_strings [] = {
|
const char *test_strings [] = {
|
||||||
|
@ -75,13 +75,6 @@ void test_remove ( const std::string &str ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ref = str;
|
|
||||||
try {
|
|
||||||
ref.remove_prefix(ref.size() + 1);
|
|
||||||
BOOST_TEST(false);
|
|
||||||
}
|
|
||||||
catch ( const std::out_of_range &) {}
|
|
||||||
|
|
||||||
for ( size_t i = 1; i < sz; ++ i ) {
|
for ( size_t i = 1; i < sz; ++ i ) {
|
||||||
work = str;
|
work = str;
|
||||||
ref = str;
|
ref = str;
|
||||||
@ -91,13 +84,6 @@ void test_remove ( const std::string &str ) {
|
|||||||
ref.remove_suffix (i);
|
ref.remove_suffix (i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ref = str;
|
|
||||||
try {
|
|
||||||
ref.remove_suffix(ref.size() + 1);
|
|
||||||
BOOST_TEST(false);
|
|
||||||
}
|
|
||||||
catch ( const std::out_of_range &) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_hash(const std::string& str) {
|
void test_hash(const std::string& str) {
|
||||||
|
Reference in New Issue
Block a user