Skip to content

Instantly share code, notes, and snippets.

@akindyakov
Last active October 20, 2016 20:27
Show Gist options
  • Save akindyakov/d822dcf4fffba5a6d3d614471f9f3b3d to your computer and use it in GitHub Desktop.
Save akindyakov/d822dcf4fffba5a6d3d614471f9f3b3d to your computer and use it in GitHub Desktop.
#include<iostream>
#include<type_traits>
struct Wrong1 {};
template<typename T1, typename T2>
struct Wrong2 {
T1 f;
T2 s;
};
template<typename T1, typename T2>
struct First {
T1 f;
T2 s;
};
template <typename T>
struct IsFirst : std::false_type {};
template <typename T1, typename T2>
struct IsFirst<First<T1, T2>> : std::true_type {};
int main() {
std::cout << std::boolalpha;
std::cout << IsFirst<Wrong1>::value << std::endl;
std::cout << IsFirst<Wrong2<int, int>>::value << std::endl;
std::cout << IsFirst<First<int, int>>::value << std::endl;
}
@akindyakov
Copy link
Author

false
false
true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment