Given a class that takes two policy template parameters:
template<typename PolicyA, typename PolicyB>
class widget;
And the following available policy classes A1, A2, A3, B1, B2, B3. How can convey that the 1s and 2s are compatible between each other but that A3 is only compatible with B3? That is, only the following instantiations are allowed:
widget<A1, B1> w11; // All valid.
widget<A1, B2> w12;
widget<A2, B1> w21;
widget<A2, B2> w22;
widget<A3, B3> w33;
// No other combination allowed.
My failed attempt at using std::enable_if within a specialization was met with a compilation error:
template<typename A, typename B>
class<A3, enable_if<is_same<B, B3>::value, B3>::type>
{};
1 Answer