| Home | Libraries | People | FAQ | More

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

Compare a string with the string.

###### Synopsis

    template<
        std::size_t M>
    constexpr int
    compare(
        basic_static_string::size_type pos1,
        basic_static_string::size_type count1,
        const basic_static_string< M, CharT, Traits >& s,
        basic_static_string::size_type pos2,
        basic_static_string::size_type count2 = basic_static_string::npos) const;

###### Description

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

###### Complexity

Linear.

###### Exception Safety

Strong guarantee.

###### Return Value

The result of lexicographically comparing `sub1` and `sub2`.

###### Parameters

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

###### Exceptions

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