From 17856db3be0f1582630d24ce112e8c434ef824bc Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Tue, 15 Sep 2026 17:14:34 +0300 Subject: [PATCH] snplib_string.h: add snplib_get_type_name functions (type name representation as std::string_view) --- include/snipplib/utils/snplib_string.h | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/snipplib/utils/snplib_string.h b/include/snipplib/utils/snplib_string.h index ecd5dda..095dc20 100644 --- a/include/snipplib/utils/snplib_string.h +++ b/include/snipplib/utils/snplib_string.h @@ -2,6 +2,7 @@ #include #include +#include #include #include "../concepts/snplib_concepts.h" @@ -439,4 +440,30 @@ public: } }; + +/* GET COMPILER STRING PRESENTATION OF THE TYPE */ + +// NOTE: return std::string_view +template +consteval auto snplib_get_type_name(T&&) +{ + return [](const std::source_location loc = std::source_location::current()) { + const std::string_view fname = loc.function_name(); + auto tmp = fname.substr(fname.rfind('=') + 2); + return tmp.substr(0, tmp.size() - 1); + }.template operator()(); +} + + +// NOTE: return std::string_view +template +consteval auto snplib_get_type_name() +{ + return [](const std::source_location loc = std::source_location::current()) { + const std::string_view fname = loc.function_name(); + auto tmp = fname.substr(fname.rfind('=') + 2); + return tmp.substr(0, tmp.size() - 1); + }.template operator()(); +} + } // namespace snplib \ No newline at end of file