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

Compare a string with 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 int
compare(
    const T& t) const;
Description

Let s be string_view_type(t) and comp be traits_type::compare(data(), s.data(), std::min(size(), s.size()). If comp != 0, then the result is comp. Otherwise, the result is 0 if size() == s.size(), -1 if 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.
Return Value

The result of lexicographically comparing s and the string.

Parameters

Name

Description

t

The string to compare.


PrevUpHomeNext