Table Of Contents

Previous topic

back

Next topic

substr

This Page

find

Interface

template<std::size_t N2>
SPROUT_CONSTEXPR size_type find(basic_string<T, N2, Traits> const& str, size_type pos = 0) const SPROUT_NOEXCEPT;

Effects

Determines the lowest position xpos, if possible, such that both of the following conditions obtain:
  • pos <= xpos and xpos + str.size() <= size();
  • traits_type::eq(at(xpos + I), str.at(I)) for all elements I of the string controlled by str.

Returns

xpos if the function can determine such a value for xpos. Otherwise, returns npos.

Remarks

Uses traits_type::eq().

Examples

#include <sprout/string.hpp>
using namespace sprout;

SPROUT_STATIC_CONSTEXPR auto input = string<8>("madocchi");
SPROUT_STATIC_CONSTEXPR auto result = input.find("cchi");
static_assert(result == 4, "a found position is 4.");

Complexity

Recursive function invocations in O(logN) (logarithmic) depth.

Note

The current implementation is incomplete. O(N) (linear) depth.


Interface

SPROUT_CONSTEXPR size_type find(value_type const* s, size_type pos, size_type n) const;

Returns



Interface

SPROUT_CONSTEXPR size_type find(value_type const* s, size_type pos = 0) const;

Returns



Interface

SPROUT_CONSTEXPR size_type find(value_type c, size_type pos = 0) const;

Returns