How to check if two class template instantiations belong to same class template. This is my code
#include <iostream>
#include <type_traits>
template<typename T1, typename T2>
class A {
float val;
public:
};
int main() {
A<double, double> a_float_type;
A<int, int> a_int_type;
// how to check whether both a_double_type and a_int_type were instantiated from the same template class A<,>
std::cout << std::is_same<decltype(a_float_type), decltype(a_int_type)>::value << std::endl; // returns false
}
My compiler only supports C++11
This is surprisingly quite simple:
https://godbolt.org/z/hq65PKqKr
As you can see it passes basic tests.
Some tweaks are needed if you wish to handle templates with none type template parameters (it fails on
std::array- I've added test for it).