size_type copy(charT* s, size_type n, size_type pos = 0) const;
Let
rlen be the smaller of
n and
size() - pos.Throws:
out_of_range if
pos > size(). Requires:
[s, s + rlen) is a valid range
. Effects:
Equivalent to
traits::copy(s, data() + pos, rlen). constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
Let
rlen be the smaller of
n and
size() - pos.Throws:
out_of_range if
pos > size(). Effects:
Determines
rlen, the effective length of the string to reference
. Returns:
basic_string_view(data() + pos, rlen). constexpr int compare(basic_string_view str) const noexcept;
Let
rlen be the smaller of
size() and
str.size().Effects:
Determines
rlen, the effective length of the strings to compare
. The function then compares the two strings by calling
traits::compare(data(), str.data(), rlen).Returns:
The nonzero result if the result of the comparison is nonzero
. Otherwise, returns a value as indicated in Table
61.Table
61 —
compare() results
Condition | Return Value |
size() < str.size() | < 0 |
size() == str.size() | 0 |
size() > str.size() | > 0 |
constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
Effects:
Equivalent to: return substr(pos1, n1).compare(str);
constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
size_type pos2, size_type n2) const;
Effects:
Equivalent to: return substr(pos1, n1).compare(str.substr(pos2, n2));
constexpr int compare(const charT* s) const;
Effects:
Equivalent to: return compare(basic_string_view(s));
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
Effects:
Equivalent to: return substr(pos1, n1).compare(basic_string_view(s));
constexpr int compare(size_type pos1, size_type n1,
const charT* s, size_type n2) const;
Effects:
Equivalent to: return substr(pos1, n1).compare(basic_string_view(s, n2));