Minor bugfix in get_type_name

This commit is contained in:
Patrick Urbanke
2024-03-03 17:13:15 +01:00
parent eaa715362c
commit 1e6bf03387
2 changed files with 11 additions and 2 deletions
+9 -2
View File
@@ -25,8 +25,13 @@ consteval auto get_type_name_str_view() {
const auto split = func_name.substr(0, func_name.size() - 1);
return split.substr(split.find("T = ") + 4);
#elif defined(_MSC_VER)
const auto split = func_name.substr(0, func_name.size() - 7);
return split.substr(split.find("get_type_name_str_view<") + 23);
auto split = func_name.substr(0, func_name.size() - 7);
split = split.substr(split.find("get_type_name_str_view<") + 23);
auto pos = split.find(" ");
if (pos != std::string_view::npos) {
return split.substr(pos + 1);
}
return split;
#else
static_assert(
false,
@@ -37,6 +42,8 @@ consteval auto get_type_name_str_view() {
template <class T>
consteval auto get_type_name() {
static_assert(get_type_name_str_view<int>() == "int",
"Expected 'int', got something else.");
constexpr auto name = get_type_name_str_view<T>();
const auto to_str_lit = [&]<auto... Ns>(std::index_sequence<Ns...>) {
return StringLiteral<sizeof...(Ns) + 1>{name[Ns]...};
+2
View File
@@ -30,6 +30,7 @@ namespace parsing {
template <class R, class W, class T>
requires AreReaderAndWriter<R, W, T>
struct Parser {
public:
using InputVarType = typename R::InputVarType;
using OutputVarType = typename W::OutputVarType;
@@ -159,6 +160,7 @@ struct Parser {
}
}
private:
template <class U>
static schema::Type make_description(
std::map<std::string, schema::Type>* _definitions) {