Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: TypeErasure
From: lcaminiti (lorcaminiti_at_[hidden])
Date: 2012-06-07 17:14:54


Nevin Liber wrote
>
> On 7 June 2012 14:33, Simonson, Lucanus J
> <lucanus.j.simonson@>wrote:
>
>> >> In a nutshell, concept-based-runtime-polymorphism/type-erasure allows
>> >> you to have runtime polymorphism while preserving value semantics.
>> >> The value of that win is very commonly underestimated.
>> >>
>> >So, is there a language feature that could be added to C++17 that would
>> make implementing type erasure easier?
>>
>> Standardize Steven's library as part of the STL?
>
>
> 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

--
View this message in context: http://boost.2283326.n4.nabble.com/Formal-Review-Request-TypeErasure-tp4630373p4631037.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk