I have Conditional
template
template<bool C, typename ...>
struct Conditional {
};
template<typename C1, typename C2>
struct Conditional<true, C1, C2> {
typedef C1 value;
};
template<typename C1, typename C2>
struct Conditional<false, C1, C2> {
typedef C2 value;
};
Which seems to work as expected:
<Conditional<(0 != 1), Int<0>, Int<1>>::value; // Int<0>
<Conditional<(0 == 1), Int<0>, Int<1>>::value, // Int<1>
But it evaluates all values before returning:
template<typename G, typename M>
struct DoMove {
private:
constexpr static bool _isRLMove = (M::direction == Direction::LEFT || M::direction == Direction::RIGHT);
public:
using result = typename Conditional<
_isRLMove, typename DoMoveRL<G, M>::result, typename DoMoveUD<G, M>::result>::value;
// ^ when _isRLMove == false evaluates this
};
Which causes compile errors from DoMoveRL
.
How can one evaluate according to condition? What am I missing here?