In summary, I would like to be able to check if the type of an object matches some type or if two objects match types.
The essence of what I'm trying to do is pasted below:
#include <vector>
#include <iostream>
#include <type_traits>
template< class T1, class T2 >
bool compare_types(T1, T2)
{
return std::is_same<T1, T2>::value;
}
class OBJ
{
};
int main(int argc, char *argv[])
{
OBJ a;
OBJ b;
int c;
std::cout<<"\n"<<compare_types(a, b)<<"\n"; // ok and returns true
//std::cout<<"\n"<<compare_types(c, int)<<"\n"; // compile error, ideally return true
//std::cout<<"\n"<<std::is_same<c, int>::value<<"\n"; // compile error, ideally return trues
//std::cout<<"\n"<<compare_types(a, OBJ)<<"\n"; // compile error, ideally return true
//std::cout<<"\n"<<std::is_same<a, OBJ>::value<<"\n"; // compile error, ideally return true
//std::cout<<"\n"<<compare_types(a, std::vector)<<"\n"; // compile error, ideally return false
//std::cout<<"\n"<<std::is_same<a, b>::value<<"\n"; // compile error, ideally return true
//std::cout<<"\n"<<std::is_same<a, c>::value<<"\n"; // compile error, ideally return false
//std::cout<<"\n"<<std::is_same<int, float>::value<<"\n"; // compile error, ideally return false
std::cout<<"\n"<<std::is_same<int, std::int32_t>::value<<"\n"; // ok and returns true
return 0;
}