▲ | kazinator 3 days ago | ||||||||||||||||
GNU C++ once had a system called Signatures, could support mixing in. It was removed. Many years ago now I think. A signature resembles a class declaration in that it specifies member functions. A signature is never instantiated. Rather any class which has those member functions conforms to the signature, and a signature-typed pointer can point to instances of that class. Thus signatures bring about quack-like-a-duck polymorphism not requiring inheritance. | |||||||||||||||||
▲ | humanrebar 3 days ago | parent [-] | ||||||||||||||||
You can implement that in C++ code, no language extensions required, by using type erasure and a pointer semantic type with at least one constructor templated on the type of the object being pointed to. | |||||||||||||||||
|