Boost logo

Boost :

Subject: Re: [boost] RFC: type erasure
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2011-05-23 17:34:32


Steven Watanabe-4 wrote:
>
> AMDG
>
> Over the last few months I've re-done my
> type erasure library from scratch, fixing
> a lot of the bad design decisions I made
> originally. Here's a basic sample of what
> you can do with it:
>
> simulate boost::any:
>
> type_erasure::any<
> mpl::vector&lt;copy_constructible&lt;&gt;, typeid_<> > >
> x(10);
>
> simulate boost::function&lt;void(int)&gt;:
>
> type_erasure::any<
> mpl::vector&lt;copy_constructible&lt;&gt;, typeid_<>,
> callable&lt;void(int)&gt; > >
> f(foo);
>
> The code is available from the Vault:
> http://tinyurl.com/3z9jcwp
>
> The library is nearly complete. I've included
> pre-built html documentation in the zip. Questions,
> comments, and criticism are welcome.
>
>

Hi,

I've just taken a diagonal read at the documentation and the library seems
really promising.

I like how concepts are materialized using a template class that implements
the default behavior of the concept and that can be specialized to map type
to concepts. I understand that you need a second step to introduce the
functions themselves specializing concept_interface.

What I don't understand is the overloading issues. Could you use a concrete
example to try to clarify the problems you have addressed?

I would try to study more deeply your design in order to see the advantage
it could provide to my library. While developing Boost.Opaque (available on
the sandbox
https://svn.boost.org/svn/boost/sandbox/opaque/libs/opaque/doc/html/index.html),
I was confronted to a similar problem, that is, how to add in a declarative
way, more operations to the underlying class. I have reached to manage with
this using what I have called a meta-mixin.

A MetaMixin is a meta-function having as nested type a Mixin. The archetype
of a MetaMixin is

struct MetaMixinArchetype {
    template (*typename Final, typename Base*)
    struct type : Base
    {
        ...
    };
};

Metamixins are is a similar way to your concepts, passing them in a
mpl-sequence.

I will appreciate a lot if you can take a look and comment the design of
Boost.Opaque.

Best,
Vicente

--
View this message in context: http://boost.2283326.n4.nabble.com/RFC-type-erasure-tp3542886p3545573.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