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 a snapshot of the develop branch, built from commit 92f6582f71.
PrevUpHomeNext
basic_static_string::compare (8 of 9 overloads)

Compare a string with the string.

Synopsis
template<
    typename T>
constexpr int
compare(
    size_type pos1,
    size_type count1,
    const T& t) const;
Description

Let s be string_view_type(t), 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.

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_pointer>::value &&
!std::is_convertible<const T&, const basic_static_string&>::value.
Return Value

The result of lexicographically comparing s and sub.

Parameters

Name

Description

pos1

The index at which to begin the substring.

count1

The length of the substring.

t

The string to compare.


PrevUpHomeNext