Some usual template specialization like this:
template<class T>
class C
{
void common() { ... }
void f2 = delete;
};
template<>
class C<int>
{
void common() { ... }
void f1() { ... }
};
Could be represented with static_if
as:
template<class T>
class C
{
void common() { ... }
static_if(std::is_same<T, int>::value)
{
void f1( ) { ... }
}
else
{
void f2( ) = delete;
}
}
Are these directly competing features? Can template specialization do something static_if
cannot? It seems like static_if
can do everything template specialization can do, and much much more.
As an aside: I don't really like static_if
in this context because it potentially makes what parts of an interface are available to you in any given circumstance non-obvious. Maybe template specialization still provides clearer syntax in some cases.