Given the code:
template <typename...> struct list{};
template <typename> list<> foo{};
template <typename H, typename... Ts>
list<H, decltype(foo<list<Ts...>>)> foo<list<H, Ts...>>{};
what is the type of foo<list<int, double>>
?
I'm asking this because MSVC (v19.37) behaves here differently from all the other compilers I've tested this with (namely, gcc 13, clang 16, and icx 2023.2). While the other compilers use the recursive specialization in decltype
(and so the type for them is list<int, list<double, list<>>>
), MSVC doesn't (thus it gives list<int, list<>>
).
The questions obviously are:
- Is this code correct (let's say, according to the C++20 standard, for certainty) and the type in question well-defined?
- If so, which compiler is right?