Boost logo

Boost :

From: Korcan Hussein (korcan_h_at_[hidden])
Date: 2006-12-12 04:58:21

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?

Korcan Hussein.

Be the first to hear what's new at MSN - sign up to our free newsletters!

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