Class StringRef

Class Documentation

class StringRef

A non-owning string class (similar to the forthcoming std::string_view) Note that, because a StringRef may be a substring of another string, it may not be null terminated.

Public Types

using size_type = std::size_t
using const_iterator = const char*

Public Functions

constexpr StringRef() noexcept = default
StringRef(char const *rawChars) noexcept
inline constexpr StringRef(char const *rawChars, size_type size) noexcept
inline StringRef(std::string const &stdString) noexcept
inline explicit operator std::string() const
inline auto operator==(StringRef other) const noexcept -> bool
inline auto operator!=(StringRef other) const noexcept -> bool
inline constexpr auto operator[](size_type index) const noexcept -> char
bool operator<(StringRef rhs) const noexcept
inline constexpr auto empty() const noexcept -> bool
inline constexpr auto size() const noexcept -> size_type
inline constexpr StringRef substr(size_type start, size_type length) const noexcept
inline constexpr char const *data() const noexcept
inline constexpr const_iterator begin() const
inline constexpr const_iterator end() const
int compare(StringRef rhs) const

Provides a three-way comparison with rhs

Returns negative number if lhs < rhs, 0 if lhs == rhs, and a positive number if lhs > rhs

Public Static Attributes

static constexpr size_type npos = {static_cast<size_type>(-1)}

Friends

friend std::string &operator+=(std::string &lhs, StringRef rhs)
friend std::ostream &operator<<(std::ostream &os, StringRef str)
friend std::string operator+(StringRef lhs, StringRef rhs)