Although I\'m doubtful, I\'m curious as to whether it\'s possible to extract primitive-type template parameters from an existing type, perhaps using RTTI.
For exampl
I like Marc Garcia's answer because it shows how to extract the template parameter in a generic way, but I believe his example can be simpler:
#include
#include
template
struct MyType {};
template typename T, int N>
constexpr int extract(const T&) { return N; }
int main() {
constexpr MyType<5> myObj;
std::cout << extract(myObj);
}
Live demo