Boost logo

Boost :

Subject: Re: [boost] [gsoc] improving any and variant
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2009-03-29 23:33:45


> A few little ideas that could eventually be joined to be a single GSoC
> project:
>
> - 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(
> args<int>(_1),
> args<std::string>(size(_1))
> );
>
> 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);

Please add your ideas to the wiki. That's the place where students will look
first.
Regards Hartmut


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