I recently wrote a fairly complex C++ meta function that boils down to:
template <size_t N, typename val>
struct Rec {
using type = typename std::conditional<N == 0,
val,
typename Rec<N - 1, val>::type>::type;
};
Both Clang and G++ barf on this type of recession, stating that, "Template instantiation depth exceeds maximum of X". I quickly rewrote the program and fixed the problem, but it got me thinking about the evaluation strategy of C++ template parameters.
Is there anything in the C++ standard that would prevent templates from using call by need evaluation of template parameters, or is this limitation purely an implementation defect?