Created
February 15, 2017 19:21
-
-
Save ax3l/5d9b5660da18c58748defd762cb227d4 to your computer and use it in GitHub Desktop.
Same Int Param
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 <iostream> | |
#include <type_traits> | |
template< | |
int A, | |
int B, | |
bool isSame = ( A == B ), | |
typename TSfinae = void> | |
struct S; | |
template< int C > | |
struct S< | |
C, | |
C, | |
true> | |
{ | |
void operator()(){ | |
std::cout << "same" << std::endl; | |
} | |
}; | |
template< int C > | |
struct S< | |
1, | |
C, false> | |
{ | |
void operator()(){ | |
std::cout << "1" << std::endl; | |
} | |
}; | |
template< int C > | |
struct S< | |
C, | |
1, | |
false > | |
{ | |
void operator()(){ | |
std::cout << "2" << std::endl; | |
} | |
}; | |
S<1,2> s1; | |
S<1,1> s2; | |
S<7,1> s3; | |
int main() | |
{ | |
s1(); | |
s2(); | |
s3(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment