Skip to content

Instantly share code, notes, and snippets.

@ax3l
Created February 15, 2017 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ax3l/5d9b5660da18c58748defd762cb227d4 to your computer and use it in GitHub Desktop.
Save ax3l/5d9b5660da18c58748defd762cb227d4 to your computer and use it in GitHub Desktop.
Same Int Param
#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