Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
basic_static_string::find (1 of 5 overloads)

Find the first occurrence of a string within the string.

Synopsis
template<
    [role red error.param neither has a declname nor a 'class ' prefix in the type][role red error.param neither has a declname nor a 'class ' prefix in the type][role red error.param neither has a declname nor a 'class ' prefix in the type][role red error.param neither has a declname nor a 'class ' prefix in the type]>
constexpr size_type
find(
    const T& t,
    size_type pos = 0) const;
Description

Constructs a temporary string_view_type object sv from t, and finds the first occurrence of sv within the string starting at the index pos.

Complexity

Linear.

Remarks

An empty string is always found.

Template Parameters

Type

Description

T

The type of the object to convert.

Constraints

std::is_convertible<const T&, string_view>::value && !std::is_convertible<const T&, const CharT*>::value.

Return Value

The lowest index idx greater than or equal to pos where each element of {sv.begin(), sv.end()) is equal to that of {begin() + idx, begin() + idx + count) if one exists, and npos otherwise.

Parameters

Name

Description

t

The string to search for.

pos

The index to start searching at. The default argument for this parameter is 0.


PrevUpHomeNext