C++ - Forward declaration and alias (with using or typedef)
It does not work because the forward declaration
struct mutex;
tells the compiler thatmutex
is a new type. Withusing
you are then creating a type alias, which means it's not a new type (as promised to the compiler), but an alias to an existing type.No.
Yes.
What you could do is:
struct mutex : ParticularMutex {
using ParticularMutex::ParticularMutex; // inherit constructors
};
Which does define a type derived from ParticularMutex
which is hopefully compatible enough. Of course, this is a new type which might lead to other problems.