Skip to content

Instantly share code, notes, and snippets.

@christianparpart
Created September 21, 2020 12:13
Show Gist options
  • Select an option

  • Save christianparpart/eae2ab7ac9788e0d7516dc81b500ebf3 to your computer and use it in GitHub Desktop.

Select an option

Save christianparpart/eae2ab7ac9788e0d7516dc81b500ebf3 to your computer and use it in GitHub Desktop.
#include <type_traits>
#include <typeinfo>
#include <cstdio>
template <
template <class> class T,
class A,
class B
>
bool f(T<A>&& a, T<B>&& b)
{
(void) a;
(void) b;
if constexpr (std::is_same<T<A>, T<B>>::value)
return true;
else
return false;
}
template <typename A, typename B>
void test()
{
printf("%s %s %s\n",
typeid(A).name(),
f(A{}, B{}) ? "==" : "!=",
typeid(B).name()
);
}
template <typename T> struct S { T v; };
template <typename T> struct U { T v; };
int main()
{
test<S<int>, S<int>>();
test<S<int>, S<float>>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment