forked from boostorg/static_string
Throw when pos2 is out of range
This commit is contained in:
@ -45,7 +45,7 @@ using smallest_width =
|
||||
template<typename To>
|
||||
void is_nothrow_convertible_helper(To) noexcept;
|
||||
|
||||
// MSVC is unable to parse this inline, so a helper is needed
|
||||
// MSVC is unable to parse this as a single expression, so a helper is needed
|
||||
template<typename From, typename To, typename =
|
||||
decltype(is_nothrow_convertible_helper<To>(std::declval<From>()))>
|
||||
struct is_nothrow_convertible_msvc_helper
|
||||
|
@ -953,6 +953,9 @@ public:
|
||||
size_type index_str,
|
||||
size_type count = npos) BOOST_STATIC_STRING_NO_EXCEPTIONS_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_STRING_THROW_IF(
|
||||
index_str > str.size(), std::out_of_range{"index_str > str.size()"}
|
||||
);
|
||||
return insert(index, str.data() + index_str, (std::min)(count, str.size() - index_str));
|
||||
}
|
||||
|
||||
@ -1967,6 +1970,9 @@ public:
|
||||
size_type pos2,
|
||||
size_type n2 = npos) BOOST_STATIC_STRING_NO_EXCEPTIONS_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_STRING_THROW_IF(
|
||||
pos2 > str.size(), std::out_of_range{"pos2 > str.size()"}
|
||||
);
|
||||
return replace(pos1, n1, str.data() + pos2, (std::min)(n2, str.size() - pos2));
|
||||
}
|
||||
|
||||
@ -2010,6 +2016,9 @@ public:
|
||||
size_type pos2,
|
||||
size_type n2 = npos) BOOST_STATIC_STRING_NO_EXCEPTIONS_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_STRING_THROW_IF(
|
||||
pos2 > str.size(), std::out_of_range{"pos2 > str.size()"}
|
||||
);
|
||||
return replace_unchecked(pos1, n1, str.data() + pos2, (std::min)(n2, str.size() - pos2));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user