snplib_string.h: add snplib_get_type_name functions (type name
representation as std::string_view)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
#include <source_location>
|
||||
#include <string>
|
||||
|
||||
#include "../concepts/snplib_concepts.h"
|
||||
@@ -439,4 +440,30 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* GET COMPILER STRING PRESENTATION OF THE TYPE */
|
||||
|
||||
// NOTE: return std::string_view
|
||||
template <typename T>
|
||||
consteval auto snplib_get_type_name(T&&)
|
||||
{
|
||||
return []<typename VT>(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()<T>();
|
||||
}
|
||||
|
||||
|
||||
// NOTE: return std::string_view
|
||||
template <typename T>
|
||||
consteval auto snplib_get_type_name()
|
||||
{
|
||||
return []<typename VT>(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()<T>();
|
||||
}
|
||||
|
||||
} // namespace snplib
|
||||
Reference in New Issue
Block a user