forked from boostorg/static_string
More constexpr for find_meow, more constexpr tests
This commit is contained in:
@ -507,10 +507,10 @@ BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
||||
inline
|
||||
ForwardIterator
|
||||
find_not_of(
|
||||
ForwardIterator first,
|
||||
ForwardIterator last,
|
||||
const CharT* str,
|
||||
std::size_t n) noexcept
|
||||
ForwardIterator first,
|
||||
ForwardIterator last,
|
||||
const CharT* str,
|
||||
std::size_t n) noexcept
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
if (!Traits::find(str, n, *first))
|
||||
@ -518,6 +518,57 @@ find_not_of(
|
||||
return last;
|
||||
}
|
||||
|
||||
// constexpr search for C++14
|
||||
template<
|
||||
typename ForwardIt1,
|
||||
typename ForwardIt2,
|
||||
typename BinaryPredicate>
|
||||
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
||||
inline
|
||||
ForwardIt1
|
||||
search(
|
||||
ForwardIt1 first,
|
||||
ForwardIt1 last,
|
||||
ForwardIt2 s_first,
|
||||
ForwardIt2 s_last,
|
||||
BinaryPredicate p)
|
||||
{
|
||||
for (; ; ++first)
|
||||
{
|
||||
ForwardIt1 it = first;
|
||||
for (ForwardIt2 s_it = s_first; ; ++it, ++s_it)
|
||||
{
|
||||
if (s_it == s_last)
|
||||
return first;
|
||||
if (it == last)
|
||||
return last;
|
||||
if (!p(*it, *s_it))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<
|
||||
typename InputIt,
|
||||
typename ForwardIt,
|
||||
typename BinaryPredicate>
|
||||
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
||||
inline
|
||||
InputIt
|
||||
find_first_of(
|
||||
InputIt first,
|
||||
InputIt last,
|
||||
ForwardIt s_first,
|
||||
ForwardIt s_last,
|
||||
BinaryPredicate p)
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
for (ForwardIt it = s_first; it != s_last; ++it)
|
||||
if (p(*first, *it))
|
||||
return first;
|
||||
return last;
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // static_string
|
||||
} // boost
|
||||
|
@ -776,7 +776,7 @@ find(
|
||||
return npos;
|
||||
if (!n)
|
||||
return pos;
|
||||
const auto res = std::search(&data()[pos], &data()[curr_size], s, &s[n], Traits::eq);
|
||||
const auto res = detail::search(&data()[pos], &data()[curr_size], s, &s[n], Traits::eq);
|
||||
return res == end() ? npos : detail::distance(data(), res);
|
||||
}
|
||||
|
||||
@ -817,7 +817,7 @@ find_first_of(
|
||||
const auto curr_data = data();
|
||||
if (pos >= size() || !n)
|
||||
return npos;
|
||||
const auto res = std::find_first_of(&curr_data[pos], &curr_data[size()], s, &s[n], Traits::eq);
|
||||
const auto res = detail::find_first_of(&curr_data[pos], &curr_data[size()], s, &s[n], Traits::eq);
|
||||
return res == end() ? npos : detail::distance(curr_data, res);
|
||||
}
|
||||
|
||||
@ -838,7 +838,7 @@ find_last_of(
|
||||
pos = 0;
|
||||
else
|
||||
pos = curr_size - (pos + 1);
|
||||
const auto res = std::find_first_of(rbegin() + pos, rend(), s, &s[n], Traits::eq);
|
||||
const auto res = detail::find_first_of(rbegin() + pos, rend(), s, &s[n], Traits::eq);
|
||||
return res == rend() ? npos : curr_size - 1 - detail::distance(rbegin(), res);
|
||||
}
|
||||
|
||||
|
@ -1996,7 +1996,7 @@ public:
|
||||
template<std::size_t M>
|
||||
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
||||
size_type
|
||||
find(
|
||||
find(
|
||||
const basic_static_string<M, CharT, Traits>& str,
|
||||
size_type pos = 0) const noexcept
|
||||
{
|
||||
|
Reference in New Issue
Block a user