Boost logo

Boost :

Subject: Re: [boost] [variant] match()
From: Rob Stewart (rob.stewart_at_[hidden])
Date: 2015-01-07 04:41:59

On January 7, 2015 3:41:04 AM EST, Eelis <eelis_at_[hidden]> wrote:
> Boost.Variant provides access through get() and visitors, but in C++11
> we can do so much better! :)
> For a boost::variant<A,B,C>, the attached small utility function
> match() lets you write:
> match(v,
> [](A & a){ cout << "it's a A!"; }
> [](B & b){ cout << "oh, a B!"; }
> [](C & c){ cout << "ah yes, a C!"; });
> Return values are supported. I think this really belongs in Boost. It
> makes variants much more usable.

That looks nice, but I don't see how it will work for, say, variant<std::string,std::map<int,something>,int>. What's the common type for those types?


(Sent from my portable computation engine)

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