21 Strings library [strings]

21.4 String view classes [string.view]

21.4.2 Class template basic_­string_­view [string.view.template]

21.4.2.1 Construction and assignment [string.view.cons]

constexpr basic_string_view() noexcept;
Postconditions: size_­ == 0 and data_­ == nullptr.
constexpr basic_string_view(const charT* str);
Preconditions: [str, str + traits​::​length(str)) is a valid range.
Effects: Constructs a basic_­string_­view, initializing data_­ with str and initializing size_­ with traits​::​length(str).
Complexity: .
constexpr basic_string_view(const charT* str, size_type len);
Preconditions: [str, str + len) is a valid range.
Effects: Constructs a basic_­string_­view, initializing data_­ with str and initializing size_­ with len.
template<class It, class End> constexpr basic_string_view(It begin, End end);
Constraints:
  • It satisfies contiguous_­iterator.
  • End satisfies sized_­sentinel_­for<It>.
  • is_­same_­v<iter_­value_­t<It>, charT> is true.
  • is_­convertible_­v<End, size_­type> is false.
Preconditions:
  • [begin, end) is a valid range.
  • It models contiguous_­iterator.
  • End models sized_­sentinel_­for<It>.
Effects: Initializes data_­ with to_­address(begin) and initializes size_­ with end - begin.