Another "who's right, between g++ and clang++?" question for standard gurus.
Given the following trivial code
#include <utility>
template <std::size_t N, typename = std::make_index_sequence<N>>
struct foo;
template <std::size_t...Is>
struct foo<sizeof...(Is), std::index_sequence<Is...>>
{ };
int main ()
{
foo<3u> f;
(void)f; // just to avoid the "unused variable" warning
}
I have that clang++ compile without problems (clang++ 9.0.0, by example, but also older versions) where g++ (g++ 9.2.0, by example, but also older versions) give me the following compilation error
prog.cc:8:8: error: template argument 'sizeof... (Is)' involves template parameter(s)
8 | struct foo<sizeof...(Is), std::index_sequence<Is...>>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The question, as usual is: who's right?
Or, in other words: is correct my code example?
-- EDIT --
About the other question, I suppose is related, but I don't think this one it's an exact duplicate.
In fact clang++ doesn't compile the code in that question, compile this code.
Otherwise the g++ error is the same and, if I understand correctly, the accepted answer of that question could be an answer also for this question.
Following that answer, if I understand correctly, the code is wrong before cwg 1315, because "A partially specialized non-type argument expression" (sizeof...(Is)) involve "a template parameter of the partial specialization" that isn't "a simple identifier".
After cwg 1315 -- again, if I understand correctly -- the code should be correct because "Each template-parameter" appear once "outside a non-deduced context".