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.
This is plainly some sort of Clang/libc++ bug: the type std::make_index_sequence<…>
isn’t __make_integer_seq
, it’s… std::index_sequence<…>
. Type aliases (and alias templates) are transparent, and deduction has always worked for std::vector
despite its default (allocator) template argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With