Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <type_traits>
- struct Test
- {
- int a;
- int b;
- };
- template< typename Type >
- using a_member_variable_type = decltype(std::declval<Type>().a);
- template< typename Type >
- using b_member_variable_type = decltype(std::declval<Type>().b);
- template< typename Type >
- using ab_member_variables_has_the_same_type_policy = std::enable_if_t< std::is_same<a_member_variable_type<Type>, b_member_variable_type<Type> >::value>;
- template< typename TestType, typename = void>
- struct AnotherTest
- {
- void f()
- {
- std::cout << "No" << std::endl;
- };
- };
- template< typename TestType >
- struct AnotherTest< TestType, ab_member_variables_has_the_same_type_policy<TestType>>
- {
- void f()
- {
- std::cout << "Yes" << std::endl;
- };
- };
- int main()
- {
- AnotherTest< Test > another_test;
- another_test.f();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement