C ++ 11 constexpr and typeid (type)

Is there any way how to get typeidin a variable at compile time using constexpr?

This does not work because it std::type_indexdoes not have constexpr ctor

constexpr std::type_index i = typeid(double);
+4
source share
1 answer

In a sense, there are:

constexpr const std::type_info &i = typeid(double);

You must remember that typeidtype returns const std::type_info &, not std::type_index.

+1
source

Source: https://habr.com/ru/post/1609569/


All Articles