I understood universal polymorphism to be different from what we expect in C++. C++ is ad-hoc polymorphism.
Universal says there can be only version of the same signature, regardless of the number of types.
I think the other answers skim over the detail that parametric and inclusion are categories of universal. Given the original text, I can see how they or I have been confused. ;)
Given the below:
struct Foo {
virtual void foo();
};
struct Bar {
virtual void bar();
// virtual void foo(); // this would error
};
Parametric would be like:
struct FooBar : public Foo, public Bar {};
The signatures contained in FooBar
is statically determined at compile time.
C++ does not directly support inclusion polymorphism. They would be closer to injection that you might find in scripting languages where functions are first order.
Please don't take this code literally, it is just for demonstration.
struct FooBar {};
int main() {
FooBar foob;
foob.foo = Foo::foo;
foob.bar = Bar::bar;
return 0;
}
FooBar
doesn't know its interface at compile time, it is dynamically composed. I've used similar behavior in javascript and Lua, and I'm sure many others have the like.