This program does not compile:
template <class T>
struct Base {
Base();
template <class U>
Base(const Base<U>&);
};
template <class T>
struct Doh : Base<T> {
using Base<T>::Base;
};
template <class T>
struct Derp : Base<T> {
using Base<T>::Base;
};
Doh<void> x = Derp<void>();
The error message says inherited constructor cannot be used to copy object. Live demo.
But when we change the last line to this, it compiles.
Doh<void> doh;
Doh<void> x1 = doh;
Doh<void> x2 = Derp<void*>();
Doh<void> x3(Derp<void>());
In these three cases the inherited constructor can be used. Why?