Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: TypeErasure
From: Hite, Christopher (Christopher.Hite_at_[hidden])
Date: 2012-06-07 12:54:18

> > 4) What about and any_base<> + any_derived<> ?
> > Based on several cases where I've seen/done type deletion a common pattern is to define a base class and a templated derived class.
> > boost::asio::detail::op_base+op

Steven Watanabe:
> I don't understand. If you want a
> base/templated derived class, the
> easiest thing is just to implement it
> that way.

I don't want to have to do it. Typically each time someone runs into one of these problems they do their type-deletion that way. Each time it's done for a particular use case, usually based on the signature of a callable concept.

If you want more examples of this:
        asio::detail::descriptor_read_op => descriptor_read_op_base - deletes the handler type
        descriptor_read_op_base =>reactor_op - deletes the buffer type

Could/would you do that more cleanly with an any<>? I think so.

If you're OK with heap storage, instead of holding a base* you can hold an any<..>.

I'm not so sure if you want control over the storage, though it looks like any<...,_self&> allows me to avoid the heap. There'd have to be an indirection more. I think it can be avoided by your library by exposing something you're forced to implement anyway.


Boost list run by bdawes at, gregod at, cpdaniel at, john at