Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2007-10-29 15:47:35


AMDG

Alexander Nasonov <alnsn <at> yandex.ru> writes:

>
> Steven Watanabe <watanabesj <at> gmail.com> writes:
>
> >
> > AMDG
> >
> > After 6+ months I've finally gotten back to this. I'd like to get
> > some feedback on my ideas before I continue. The current version is in
> > the vault.
> >
> > The basic interface is derived from Alexander Nasonov's dynamic_any
>
> Steven,
> I'm reading your code but there are 53 files full of meta-programming
> and reading them may take some time. Can you please give an overview of
> the implementation or highlight differences between your code and mine?

Biggest implementation difference:
    I am using an explicit table of function pointers and
    a separate buffer rather than a virtual functions.

All the metaprogramming is either for creating the table
or figuring out how one table maps onto another.

At the lowest level, I have two components:
a) a buffer class that handles allocation/deallocation or
    the small object optimization. (detail/anything.hpp)
b) A generic vtable that supports static initialization and
   table conversions. (this is in detail/table/*)

There are two distinct versions of function calls. The
first has a fixed return type. The second returns another
polymorphic object. The version that returns an any<>,
takes a pointer to a buffer as a parameter and constructs
the result in it. The table of the result is managed
from outside the function call. This implies that the
dynamic type of the result is entirely determined by the
dynamic types of the arguments. The advantage of this
is that conversions between any<>s work smoothly.
(The code for mapping the interface onto a set of function
pointers is in concept.hpp, detail/dispatch/*)

detail/metafunction just contains some utilities that I
needed and one important file that probably belongs elsewhere:
type_deduction.hpp. This file has the code for working out
what types each of the placeholders represent. e.g. If
you have an any<function_call<_1()> > and construct it
from a boost::function<int()> then _ will map to boost::function<int()>
and _1 will map to _1. It handles the related case of
mapping placeholders to placeholders for a conversion.

In Christ,
Steven Watanabe


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