
On 6/7/12 11:14 PM, lcaminiti wrote:
Nevin Liber wrote
Take the following base class:
struct S { void f(); void g(); void h(); };
In the virtual function world, to enforce that interface, one merely has to write:
struct AbstractS { virtual void f() = 0; virtual void g() = 0; virtual void h() = 0; };
and have others derive from it.
If I wanted a type erased version of the equivalent callable interface, what do I have to do? If it isn't as simple as writing AbstractS above, only a small fraction of C++ developers will ever attempt it, let alone do it on a regular basis.
Steven's library does a great job at covering a lot of cases, but adding custom concepts is a chore.
What if this were possible? Would this be an acceptable way to add custom concepts?
BOOST_TYPE_ERASURE_CONCEPT( concept (sable) ( class S ) ( void member_body(S, f) ( void ) , void member_body(S, g) ( void ) , void member_body(S, h) ( void ) ) )
--Lorenzo
I think this would be a step in the right direction, but not quite good enough yet. I have used and written similar macro based IDLs on/for several systems, and they were always disliked by most developers, even though they worked quite well. For such a common feature the Syntax has to be as easy as Possible, and I think (but am not sure) this can't be done without a language feature. I could Imagine a Syntax like either the above AbstractS (with or without the virtual) or even more ideally be able to do something like "create_type_erased_concept_from<S>;" which should be implementable (maybe with a macro instead of a template) if we had some kind of compile time reflection. regards Fabio