size_type find_last_not_of (basic_string_view that) const { for (auto iter = this->rbegin(); iter != this->rend(); ++iter) { if (traits::find(that.data(), that.size(), *iter)) { continue; } return this->size() - std::distance(this->rbegin(), iter) - 1; } return npos; }
bool ends_with (basic_string_view that) const noexcept { return this->size() >= that.size() and traits::compare( this->data() + this->size() - that.size(), that.data(), that.size() ) == 0; }
size_type find (basic_string_view that) const { auto iter = std::search( this->begin(), this->end(), that.begin(), that.end(), traits::eq ); if (iter == this->end()) { return npos; } return std::distance(this->begin(), iter); }
size_type rfind (basic_string_view that) const { auto iter = std::search( this->rbegin(), this->rend(), that.rbegin(), that.rend(), traits::eq ); if (iter == this->rend()) { return npos; } return this->size() - std::distance(this->rbegin(), iter) - 1; }
size_t operator() (const basic_string_view<T, Traits>& sv, charT *buf, size_t buf_len) const noexcept { const size_t n = sv.size(); if (buf) { CLUE_ASSERT(n < buf_len); ::std::copy(sv.begin(), sv.end(), buf); buf[n] = static_cast<charT>('\0'); } return n; }
difference_type compare (basic_string_view that) const { auto cmp = traits::compare( this->data(), that.data(), std::min(this->size(), that.size()) ); if (cmp != 0) { return cmp; } if (this->size() == that.size()) { return 0; } if (this->size() < that.size()) { return -1; } return 1; }
size_t to_string(PrintOptions, format_appender<T>& app, basic_string_view<CharT, Traits> options) { app.append(options.data(), options.size()); return options.size(); }
size_t dispatch_to_string(const basic_string_view<CharT, Traits>& arg, Appender& app, FmtFlags flags) { app.append(arg); return arg.size(); }
bool operator < ( basic_string_view<CharT, Traits> lhs, basic_string_view<CharT, Traits> rhs ) noexcept { return lhs.compare(rhs) < 0; }
bool operator != ( basic_string_view<CharT, Traits> lhs, basic_string_view<CharT, Traits> rhs ) noexcept { return lhs.size() != rhs.size() or lhs.compare(rhs) != 0; }
bool operator == ( basic_string_view<CharT, Traits> lhs, basic_string_view<CharT, Traits> rhs ) noexcept { return lhs.size() == rhs.size() and lhs.compare(rhs) == 0; }