Skip to content

The `utf::string_view` class API

Alex Qzminsky edited this page Dec 30, 2020 · 2 revisions

Not ready yet!

Contents

  1. Member types
  2. Public member functions
    1. Constructors
    2. Span accessors
    3. Transforming algorithms
    4. Properties

Member types

Name Defined as
string_view::char_type uint32_t
string_view::difference_type ptrdiff_t
string_view::unit uint8_t
string_view::pointer string::unit*
string_view::size_type ptrdiff_t
string_view::value_type Same as char_type
iterator Itself

The char_type, difference_type, unit, pointer, size_type, value_type aliases is similar to string's.

Public member functions

Constructors

string_view::string_view (const char*)

Constructs a view over given C-string.

Properties

string_view::bytes () -> string_view::pointer const noexcept

Returns a pointer to the beginning of the view's data.


string_view::bytes_end () -> string_view::pointer const noexcept

Returns a pointer to the ending of the view's data. I.e., bytes() + size() == bytes_end().


string_view::is_empty () -> bool const noexcept

Predicate. Returns true if the view does not contains any characters. The effect is equivalent to string_view::operator ! ().


string_view::length () -> string_view::size_type const noexcept

Returns the number of Unicode characters in the span.

This is an O(n) operation as it requires iteration over every UTF-8 character of the string.


string_view::size () -> string_view::size_type const noexcept

Returns the number of the UTF-8 bytes data used by the span.