Template Class basic_string_view

Class Documentation

template<typename Char>
class fmt::v6::basic_string_view

An implementation of std::basic_string_view for pre-C++17. It provides a subset of the API. fmt::basic_string_view is used for format strings even if std::string_view is available to prevent issues when a library is compiled with a different -std option than the client code (which is not recommended).

Public Types

using char_type = Char
using iterator = const Char*

Public Functions

basic_string_view()
basic_string_view(const Char *s, size_t count)

Constructs a string reference object from a C string and a size.

basic_string_view(const Char *s)

Constructs a string reference object from a C string computing the size with std::char_traits<Char>::length.

template<typename Traits, typename Alloc>
basic_string_view(const std::basic_string<Char, Traits, Alloc> &s)

Constructs a string reference from a std::basic_string object.

template<typename S>
basic_string_view(S s)
const Char *data() const

Returns a pointer to the string data.

size_t size() const

Returns the string size.

iterator begin() const
iterator end() const
const Char &operator[](size_t pos) const
void remove_prefix(size_t n)
int compare(basic_string_view other) const

Friends

friend bool operator==(basic_string_view lhs, basic_string_view rhs)
friend bool operator!=(basic_string_view lhs, basic_string_view rhs)
friend bool operator<(basic_string_view lhs, basic_string_view rhs)
friend bool operator<=(basic_string_view lhs, basic_string_view rhs)
friend bool operator>(basic_string_view lhs, basic_string_view rhs)
friend bool operator>=(basic_string_view lhs, basic_string_view rhs)