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::compare (2 of 9 overloads)

Compare a string with the string.

Synopsis
template<
    std::size_t M>
constexpr int
compare(
    size_type pos1,
    size_type count1,
    const basic_static_string< M, CharT, Traits >& s) const;
Description

Let sub be substr(pos1, count1) and comp be traits_type::compare(sub.data(), s.data(), std::min(sub.size(), s.size()). If comp != 0, then the result is comp. Otherwise, the result is 0 if sub.size() == s.size(), -1 if sub.size() < s.size(), and 1 otherwise.

Complexity

Linear.

Exception Safety

Strong guarantee.

Return Value

The result of lexicographically comparing sub and s.

Template Parameters

Type

Description

M

The size of the string to compare with.

Parameters

Name

Description

pos1

The index at which to begin the substring.

count1

The size of the substring.

s

The string to compare.

Exceptions

Type

Thrown On

std::out_of_range

pos1 > size()


PrevUpHomeNext