template<typename T, int i, int current = 0>
auto constexpr get_my(const T& t, typename std::enable_if< i!=current >::type* = 0) ->
decltype( get_my<T, i, current+1>(t.el1) )
{
return get_my<T, i, current+1>(t.el1);
}
calls the nested get_my
function with wrong arguments. The type for the nested call should be get_my<decltype(t.el1), i, current+1>(t.el1)
instead of get_my<T, i, current+1>(t.el1)
.
So the correct code should be:
template<typename T, int i, int current = 0>
auto constexpr get_my(const T& t, typename std::enable_if< i!=current >::type* = 0) ->
decltype( get_my<decltype(t.el1), i, current+1>(t.el1) )
{
return get_my<decltype(t.el1), i, current+1>(t.el1);
}