Created
September 21, 2020 12:13
-
-
Save christianparpart/eae2ab7ac9788e0d7516dc81b500ebf3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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