| Home | Libraries | People | FAQ | More

##### basic_static_string::compare (6 of 9 overloads)

Compare a string with the string.

###### Synopsis

    constexpr int
    compare(
        basic_static_string::size_type pos1,
        basic_static_string::size_type count1,
        basic_static_string::const_pointer s,
        basic_static_string::size_type count2) const;

###### Description

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

###### Complexity

Linear.

###### Exception Safety

Strong guarantee.

###### Return Value

The result of lexicographically comparing `s` and `sub`.

###### Parameters

Name | Description
--- | ---
`pos1` | The index at which to begin the substring.
`count1` | The size of the substring.
`s` | The string to compare.
`count2` | The length of the string to compare.

###### Exceptions

Type | Thrown On
--- | ---
`std::out_of_range` | `pos1 > size()`