Boost logo

Boost :

From: Eric Friedman (ebf_at_[hidden])
Date: 2007-01-02 03:53:44


Korcan,

Regarding visitation for boost::any, I did some work a long while ago in
the Boost Sandbox:

http://boost-sandbox.cvs.sourceforge.net/boost-sandbox/boost-sandbox/boost/any.hpp

http://boost-sandbox.cvs.sourceforge.net/boost-sandbox/boost-sandbox/boost/visitor/

I haven't looked at any of this in a while though.

Also, in case you are interested, there is the more experimental
application of visitation in the form of a "switch" construct:

http://boost-sandbox.cvs.sourceforge.net/boost-sandbox/boost-sandbox/boost/type_switch.hpp

Eric

Korcan Hussein wrote:
> I propose 3 changes/additions made to boost::any:
>
> 1. Support for custom allocator types.
>
> 2. Support for in-place factories.
>
> 3. Last but not least boost::variant style visitors.
>
> I'll elaborate on the last one, i've written primarily support for
> boost::variant style visitors for boost::any. The method is based on the
> acyclic visitor pattern and works as follows:
>
> struct printer_fn : boost::dynamic_visitor<int, std::string> {
>
> void operator()(int) const { std::cout << "int\n" }
> void operator(const std::string&) cosnt { std::cout << "string\n" }
>
> } const printer;
>
> ......
>
> boost::any a = 1;
>
> boost::apply_visitor(a, printer);
>
> a = std::string();
>
> boost::apply_visitor(a, printer);
>
> I'm looking to also provide the ability to extend their visitors (and
> override if need be) to support more types as well as provide "catch-all"
> (i.e (const) boost::any&) implementation which defaults to throwing an
> exception. I also want this to be constant-correct in the way of
> const_iterator and iterator, i need to look into this carefully since there
> are 4-cases to deal with (instead of 2).
>
> Is there any interest for these changes/additions?
>
> Thanks.
> Korcan Hussein.
>
> _________________________________________________________________
> Be the first to hear what's new at MSN - sign up to our free newsletters!
> http://www.msn.co.uk/newsletters
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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