Reputation: 332
This code is compiled by gcc with an error
template<typename>
struct B {
};
template<typename... Types>
struct A : public B<Types>... {
using B<Types>::B...;
using B<Types>::operator=...;
}
compiler output
<source>:8:8: error: expected nested-name-specifier before 'B'
8 | using B<Types>::operator=...;
|
^
But this code compiles without errors
template<typename>
struct B {
};
template<typename... Types>
struct A : public B<Types>... {
using B<Types>::operator=...;
using B<Types>::B...;
};
I can 't understand why this is happening.
Update
for gcc, constructor inheritance also breaks the code
template<typename T>
struct B {
void foo() {}
};
template<typename... Types>
struct A : public B<Types>... {
using B<Types>::B...;
void bar() {
(B<Types>::foo() , ...);
}
};
Upvotes: 6
Views: 87
Reputation: 21307
It was a GCC bug, that was fixed finally in GCC 11.
Demo: https://gcc.godbolt.org/z/arxjPjTa5
Another demo: https://gcc.godbolt.org/z/KhjGn945G
Upvotes: 1