[libc++] Add noexcept to string::find and similar members.

Adds `noexcept` to `string_view`/`string::find` and similar members
(`rfind`, etc.). See discussion in D95251. Refs D95821.

Reviewed By: curdeius, ldionne

Differential Revision: https://reviews.llvm.org/D95848
This commit is contained in:
zoecarver
2021-02-05 11:54:47 -08:00
parent 59c1139d3e
commit dea74b2820
60 changed files with 139 additions and 46 deletions

View File

@@ -21,6 +21,7 @@ void
test(const S& s, typename S::value_type c, typename S::size_type pos,
typename S::size_type x)
{
LIBCPP_ASSERT_NOEXCEPT(s.find_first_of(c, pos));
assert(s.find_first_of(c, pos) == x);
if (x != S::npos)
assert(pos <= x && x < s.size());
@@ -30,6 +31,7 @@ template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type x)
{
LIBCPP_ASSERT_NOEXCEPT(s.find_first_of(c));
assert(s.find_first_of(c) == x);
if (x != S::npos)
assert(x < s.size());

View File

@@ -21,6 +21,7 @@ void
test(const S& s, const typename S::value_type* str, typename S::size_type pos,
typename S::size_type x)
{
LIBCPP_ASSERT_NOEXCEPT(s.find_first_of(str, pos));
assert(s.find_first_of(str, pos) == x);
if (x != S::npos)
assert(pos <= x && x < s.size());
@@ -30,6 +31,7 @@ template <class S>
void
test(const S& s, const typename S::value_type* str, typename S::size_type x)
{
LIBCPP_ASSERT_NOEXCEPT(s.find_first_of(str));
assert(s.find_first_of(str) == x);
if (x != S::npos)
assert(x < s.size());

View File

@@ -21,6 +21,7 @@ void
test(const S& s, const typename S::value_type* str, typename S::size_type pos,
typename S::size_type n, typename S::size_type x)
{
LIBCPP_ASSERT_NOEXCEPT(s.find_first_of(str, pos, n));
assert(s.find_first_of(str, pos, n) == x);
if (x != S::npos)
assert(pos <= x && x < s.size());

View File

@@ -20,6 +20,7 @@ template <class S>
void
test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
{
LIBCPP_ASSERT_NOEXCEPT(s.find_first_of(str, pos));
assert(s.find_first_of(str, pos) == x);
if (x != S::npos)
assert(pos <= x && x < s.size());
@@ -29,6 +30,7 @@ template <class S>
void
test(const S& s, const S& str, typename S::size_type x)
{
LIBCPP_ASSERT_NOEXCEPT(s.find_first_of(str));
assert(s.find_first_of(str) == x);
if (x != S::npos)
assert(x < s.size());

View File

@@ -20,6 +20,7 @@ template <class S, class SV>
void
test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x)
{
LIBCPP_ASSERT_NOEXCEPT(s.find_first_of(sv, pos));
assert(s.find_first_of(sv, pos) == x);
if (x != S::npos)
assert(pos <= x && x < s.size());
@@ -29,6 +30,7 @@ template <class S, class SV>
void
test(const S& s, SV sv, typename S::size_type x)
{
LIBCPP_ASSERT_NOEXCEPT(s.find_first_of(sv));
assert(s.find_first_of(sv) == x);
if (x != S::npos)
assert(x < s.size());