I would like to use the name of a type at compile time. For example, suppose I've written:
constexpr size_t mx_strlen(const char* s)
{
const char* cp = s;
while(*cp != '\0') { cp++; };
return cp - s;
}
and now I want to have:
template <typename T>
constexpr auto type_name_length = my_strlen(typeid(T).name());
But alas, typeid(T).name() is just const char*
, not constexpr... is there some other, constexpr way to get a type's name?
Aucun commentaire:
Enregistrer un commentaire