From 9d66520257a78ea7df554462c3542ecc76f9a3ff Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 24 Oct 2019 20:26:53 +0500 Subject: [PATCH] add to_string(), explicit operator string --- include/nameof.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/nameof.hpp b/include/nameof.hpp index 1f854f2..9b8ac24 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -166,9 +166,15 @@ class [[nodiscard]] cstring { [[nodiscard]] constexpr const char* c_str() const noexcept { return data(); } + template, typename Allocator = std::allocator> + [[nodiscard]] std::basic_string 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 Allocator = std::allocator> + [[nodiscard]] explicit operator std::basic_string() const { return {begin(), end()}; } }; template