add to_string(), explicit operator string

This commit is contained in:
neargye 2019-10-24 20:26:53 +05:00
parent 742f2879db
commit 9d66520257

View file

@ -166,9 +166,15 @@ class [[nodiscard]] cstring {
[[nodiscard]] constexpr const char* c_str() const noexcept { return data(); }
template<typename Char = char, typename Traits = std::char_traits<Char>, typename Allocator = std::allocator<Char>>
[[nodiscard]] std::basic_string<Char, Traits, Allocator> to_string() const { return {begin(), end()}; }
[[nodiscard]] constexpr operator std::string_view() const noexcept { return {data(), size()}; }
[[nodiscard]] constexpr explicit operator const char*() const noexcept { return data(); }
template<typename Char = char, typename Traits = std::char_traits<Char>, typename Allocator = std::allocator<Char>>
[[nodiscard]] explicit operator std::basic_string<Char, Traits, Allocator>() const { return {begin(), end()}; }
};
template <std::size_t N>