forked from boostorg/utility
Added string_view::contains methods.
These methods were added in C++23. Also updated string_view/ref tests: - Added tests for string_view::contains. - Added missing includes. - Added missing std:: qualification. - Removed tabs. - Fixed misleading indentation (fixes gcc warnings). - Fixed decrementing pointer before beginning of the string. Closes https://github.com/boostorg/utility/issues/93.
This commit is contained in:
@@ -245,6 +245,18 @@ namespace boost {
|
||||
traits::compare(ptr_ + len_ - x.len_, x.ptr_, x.len_) == 0;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR bool contains(basic_string_view s) const BOOST_NOEXCEPT {
|
||||
return find(s) != npos;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR bool contains(charT c) const BOOST_NOEXCEPT {
|
||||
return find(c) != npos;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR bool contains(const charT* s) const BOOST_NOEXCEPT {
|
||||
return find(s) != npos;
|
||||
}
|
||||
|
||||
// find
|
||||
BOOST_CXX14_CONSTEXPR size_type find(basic_string_view s, size_type pos = 0) const BOOST_NOEXCEPT {
|
||||
if (pos > size())
|
||||
|
||||
Reference in New Issue
Block a user