I have a templated class G:
template<int I>
class G {}
And it's so happens that I need 2 implementations based on that int I
If it was a single value, I would always be able to do:
template<>
class G<int Specific_I>
{
/*Implementation for that I*/
}
If I had single condition, which shows to use implementation_1 if true and implementation_2 if false, I could've used advice given here
But, my situation is more general.
Let's say I defined conditions on I for each implementation:
template<int I>
constexpr bool Condition_1 = /*whatever*/;
template<int I>
constexpr bool Condition_2 = /*whatever_v2*/;
This allows for easy readability and expansion as needed
And if I get an error due to none or multiple of conditions applying for specific I when called in program, I'm fine with that
Obvious choice is to use std::enable_if_t
template<int I,
enable_if_t<Condition_1<I>>
>
class G
{
/*Implementation based on Condition_1*/
}
template<int I,
enable_if_t<Condition_2<I>>
>
class G
{
/*Implementation based on Condition_2*/
}
But this causes an error
template parameter ‘typename std::enable_if<Condition_1<I>, void>::type <anonymous>’|
redeclared here as ‘typename std::enable_if<Condition_2<I>, void>::type <anonymous>’|
Where have I made mistake and how do I fix that?