Is it possible to get a type according to a string known at compile time?
Mainly with constexpr std::string_view.
#include <bits/stdc++.h>
template <std::string_view>
struct MakeType {};
template <>
struct MakeType<"int"> {
using type = int;
};
template <>
struct MakeType<"float"> {
using type = float;
};
int main() {
constexpr std::string_view my_int = "int";
MakeType<my_int>::type i = 5;
return 0;
}