Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22045

GCC compilation error when inheriting constructors

$
0
0

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() , ...);
    }
};

Viewing all articles
Browse latest Browse all 22045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>