Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2007-11-05 18:40:42


Mathias Gaunard <mathias.gaunard <at>> writes:

> Steven Watanabe wrote:
> > 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
> >
> > struct increment : concept_<increment, void(_&)> {
> > template<class T>
> > static void execute(T& t) {
> > ++t;
> > }
> > }
> >
> > any<increment> x(1);
> > increment()(x);
> > assert(type_erasure::any_cast<int>(x) == 1);
> Doesn't adobe::poly provide similar things but with way nicer interfaces?

a) I'm not entirely convinced that adobe::poly's interfaces are nicer.
   Would you mind elaborating. If you mean that adobe allows
   ++x instead of increment()(x), I provide a template that can
   be specialized to enable such usage, too. poly's interface
   is optimized for interfaces that have many functions grouped
   together. Mine is optimized for having many independent functions.
   In terms of the amount of boilerplate, it's about a toss-up.
b) I support multiple independent functions in such a way that
   any<increment, decrement> can be converted to any<increment> or
   any<decrement> or any<> without adding a layer of indirection.
c) adobe::poly relies on undefined behavior to implement the small
   object optimization. (It assumes that a single base class is allocated
   at the beginning of the object). As far as I know, it is
   impossible to implement the small object optimization in a standard
   conformant way without either changing the interface away
   from virtual functions or adding an extra pointer to the poly<>
   object or having double indirection for the virtual table.

In Christ,
Steven Watanabe

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