Boost logo

Boost :

Subject: [boost] [gsoc] improving any and variant
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2009-03-29 22:01:27

A few little ideas that could eventually be joined to be a single GSoC

- Allow visitation for Any. This can actually be generalized to any
object that exposes a type_info, such as polymorphic objects.

Techniques, including non-portable ones based on name mangling, could be
experimented to get more efficient dispatch.

- Add SBO to any.

- Improve variant so that the functor doesn't require to expose a
result_type. The result_type can be automatically deduced by "joining"
all the possible return types obtained by boost::result_of.

- Allow the easy construction of a visitor from lambda expressions, with
a syntax like

variant<int, std::string> a = "foo";

int b = match(a).with(

instead of the potentially more verbose

struct my_visitor : static_visitor<int>
     int operator()(int a) { return a; }
     int operator()(const std::string& b) { return b.size(); }

variant<int, std::string> a = "foo";;

int b = apply_visitor(my_visitor(), a);

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