Struct CowString¶
Defined in File CowString.hpp
Nested Relationships¶
Nested Types¶
Struct Documentation¶
-
struct CowString¶
A string-like type, that is either std::string_view (borrowed) or std::string (owned) with copy-on-write functionality. Inspired by rust’s std::borrow::Cow (https://doc.rust-lang.org/std/borrow/enum.Cow.html).
Public Types
-
using value_type = std::string_view::value_type¶
-
using traits_type = std::string_view::traits_type¶
-
using iterator = std::string_view::iterator¶
-
using const_iterator = std::string_view::const_iterator¶
-
using const_reverse_iterator = std::string_view::const_reverse_iterator¶
-
using reverse_iterator = std::string_view::reverse_iterator¶
-
using size_type = std::string_view::size_type¶
Public Functions
-
inline constexpr CowString(borrowed_tag, std::string_view const value) noexcept¶
-
inline constexpr value_type const *data() const noexcept¶
-
inline constexpr bool empty() const noexcept¶
-
inline constexpr const_iterator begin() const noexcept¶
-
inline constexpr const_iterator end() const noexcept¶
-
inline constexpr const_iterator cbegin() const noexcept¶
-
inline constexpr const_iterator cend() const noexcept¶
-
inline constexpr const_reverse_iterator rbegin() const noexcept¶
-
inline constexpr const_reverse_iterator rend() const noexcept¶
-
inline constexpr const_reverse_iterator crbegin() const noexcept¶
-
inline constexpr const_reverse_iterator crend() const noexcept¶
-
inline constexpr operator std::string_view() const noexcept¶
-
inline constexpr std::string_view view() const noexcept¶
-
inline constexpr bool is_borrowed() const noexcept¶
-
inline constexpr bool is_owned() const noexcept¶
-
inline constexpr std::string_view get_borrowed() const¶
-
inline constexpr std::string const &get_owned() const¶
-
inline constexpr std::string &get_owned()¶
-
inline std::string into_owned() && noexcept¶
Converts this CowString into std::string (by move if the owned form is active)
-
inline std::string &to_mutable() noexcept¶
Returns a non-const reference to the owned form of the data (std::string) Converts the data to the owned for if it is currently the borrowed form
-
inline constexpr std::strong_ordering operator<=>(std::string_view const rhs) const noexcept¶
-
inline constexpr bool operator==(std::string_view const rhs) const noexcept¶
Public Static Attributes
-
static constexpr borrowed_tag borrowed = {}¶
-
struct borrowed_tag¶
-
struct owned_tag¶
-
using value_type = std::string_view::value_type¶