Lars Ivar Igesund wrote:
Jason House wrote:
Andrei Alexandrescu wrote:
I'd be curious to find out more about a runtime queryable struct
interface. How would it work? What idioms would it enable?
I don't know what Lars is thinking of, but I think of struct
interfaces as a non-polymorphic / compile-time inheritance. AKA,
you can have a struct implement it, but you can't cast it to a base
struct/interface. Outside of defining the struct, I'd expect it to
only be usable in templates and is-expressions
Nope, I want something that works at runtime. Inheritance
could/should be non-polymorphic and compile-time, but I want to know
at runtime that a void* has implemented a given interface.
Consider you can avail yourself of a function:
bool implements(Interface)(void* p);
What would you do with it?
Andrei