The following code forwards constructors from base to derived class.
Why 2 copy constructor calls? What happen in the background?
Compiled with g++.
#include <iostream>
using namespace std;
struct A {
A() { cout << "A" << endl; }
A(const A&) { cout << "A(const A&)" << endl; }
template<typename T> A(T a); // Needed to compile :-O
};
template<typename T>
struct C : public T { using T::T; };
int main()
{
A a;
C<A> ca(a);
//C<A> caa(ca);
return 0;
}
Output is:
A
A(const A&)
A(const A&)