diff --git a/include/boost/fixed_string/fixed_string.hpp b/include/boost/fixed_string/fixed_string.hpp index ea21d00..b294f6d 100644 --- a/include/boost/fixed_string/fixed_string.hpp +++ b/include/boost/fixed_string/fixed_string.hpp @@ -1518,10 +1518,8 @@ public: const T& t, size_type pos = 0) const { - return string_view_type( - *this).find( - t, pos); - + string_view_type sv = t; + return find(sv.data(), pos, sv.size()); } #endif @@ -1585,9 +1583,8 @@ public: const T& t, size_type pos = npos) const { - return string_view_type( - *this).rfind( - t, pos); + string_view_type sv = t; + return rfind(sv.data(), pos, sv.size()); } #endif @@ -1650,9 +1647,8 @@ public: const T& t, size_type pos = 0) const { - return string_view_type( - *this).find_first_of( - t, pos); + string_view_type sv = t; + return find_first_of(sv.data(), pos, sv.size()); } #endif @@ -1715,9 +1711,8 @@ public: const T& t, size_type pos = npos) const { - return string_view_type( - *this).find_last_of( - t, pos); + string_view_type sv = t; + return find_last_of(sv.data(), pos, sv.size()); } #endif @@ -1780,9 +1775,8 @@ public: const T& t, size_type pos = 0) const { - return string_view_type( - *this).find_first_not_of( - t, pos); + string_view_type sv = t; + return find_first_not_of(sv.data(), pos, sv.size()); } #endif @@ -1845,9 +1839,8 @@ public: const T& t, size_type pos = npos) const { - return string_view_type( - *this).find_last_not_of( - t, pos); + string_view_type sv = t; + return find_last_not_of(sv.data(), pos, sv.size()); } #endif diff --git a/include/boost/fixed_string/impl/fixed_string.hpp b/include/boost/fixed_string/impl/fixed_string.hpp index 0142260..8e69bc2 100644 --- a/include/boost/fixed_string/impl/fixed_string.hpp +++ b/include/boost/fixed_string/impl/fixed_string.hpp @@ -667,12 +667,10 @@ find( size_type n) const -> size_type { - if (pos > n_) + if (pos > n_ || n > n_ - pos) return npos; if (!n) return pos; - if (n > n_ - pos) - return npos; const auto res = std::search(&s_[pos], &s_[n_], s, &s[n], Traits::eq); return res == end() ? npos : std::distance(s_, res); }