Categories > Coding > C++ >
Polymorphism In C++
Posted
I'm doing research on type systems. For this project, I'm looking at how Variants, structural subtyping, universal polymorphism, and existential polymorphism are used in popular languages. Such functions are provided by functional languages such as heskell and ocaml. But I'm curious if a popular language like C++ has the above capability. That is, how C++ is implemented.
variants
subtyping of structural elements
polymorphism at all levels
Existential polymorphism is a type of polymorphism.
Thank you
Replied
It does have existential polymorphism (via C++ 20 concepts), it doesn't TRULY have universal polymorphism, universal polymorphism would imply that in a function X, an operation could be performed on a generic type T and generate the same result, no matter what it later monomorphises to, and this is not true in C++.
It does have structural subtyping (inheritance).
And yes we do have variants (assuming you're talking about covariance and contravariance). Please let me know if you meant something else.
And what do you mean polymorphism at all levels? You're gonna have to be more specific.
Cancel
Post
https://media.discordapp.net/attachments/1044764388546068510/1051935933836050482/Signature_4.png
Replied
@luxiferrwoo, Oh okay Got it
By saying polymorphism at all levels i mean universal polymorphism and about that i read that the templates resemble universal polymorphism on the surface but are fundamentally different. These are essentially glorified macros with minimal to no type checking (like with macros, both checking and code generation happens after expansion).
Thank you for your reply man
Cancel
Post
Thank you
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post