Boost logo

Boost :

From: Douglas Paul Gregor (gregod_at_[hidden])
Date: 2002-10-22 13:44:24


On Tue, 22 Oct 2002, Alexander Nasonov wrote:
> I started implementation of operators for dynamic_any. Currently, they are
> in examples.
>
> example4.cpp: negate and inplace_negate
> example5.cpp: dereference and increment
>
> URL for download is:
> http://prdownloads.sourceforge.net/cpp-experiment/dynamic_any-1.0.1.tar.gz?download
>
> Look how nice they are!

Very nice indeed!

(As always), on suggestion. dynamic_any could use the curiously recurring
template pattern to support member operators/functions directly. For
instance, the "dereference" class from example5.hpp could be augmented
with a mixin:

struct dereference : /* same as before */ {
  // same code as before...

  template<typename Derived>
  struct mixin {
    Derived operator*() const
    {
      return boost::call(dereference(),
                         static_cast<const Derived&>(*this));
    }
  };
};

The mixin will be inherited by dynamic_any<Sequence> as
mixin<dynamic_any<Sequence> >. That sticks the dereference operator
directly in dynamic_any, so that member functions, operators, etc. can be
applied directly to dynamic_any objects that have them mixed-in.

        Doug


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