Another "who's right between g++ and clang++?" question for C++ standard gurus.
Given the following code
#include <utility>
template <std::size_t N, typename = std::make_index_sequence<N>>
struct foo;
template <std::size_t N, std::size_t ... Is>
struct foo<N, std::index_sequence<Is...>>
{ };
template <std::size_t N>
void bar (foo<N> const &)
{ }
int main()
{
bar(foo<42u>{});
}
I see that g++ compile where clang++ gives the following error
tmp_003-14,gcc,clang.cpp:32:4: error: no matching function for call to 'bar'
bar(foo<42u>{});
^~~
tmp_003-14,gcc,clang.cpp:27:6: note: candidate template ignored: could not match
'__make_integer_seq' against 'integer_sequence'
void bar (foo<N> const &)
^
1 error generated.
As usual, the question is: who's right? g++ or clang++?
-- EDIT -- As pointed by HolyBlackCat (thanks!), some older version of clang++ compile this code where the newer don't.
I've tried with Wandbox and I see that clang++ compile from 3.4 (the first version supporting std::make_index_sequence
/std::index_sequence
) to 3.8.1. Starting from 3.9.1 gives the preceding error.
-- EDIT 2 -- Observe that the clang++ compilation error seems strictly bounded to the use of the first template argument in definition of the default value for the second.
In fact, changing
template <std::size_t N, typename = std::make_index_sequence<N>>
struct foo;
in
// ........................... now doesn't depends from N -->VVV
template <std::size_t N, typename = std::make_index_sequence<10u>>
struct foo;
both compilers compile.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…