Boost logo

Boost :

Subject: Re: [boost] [variant] match()
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2015-01-09 13:04:11

Le 09/01/15 10:06, Antony Polukhin a écrit :
> 2015-01-09 8:10 GMT+03:00 Vicente J. Botet Escriba <vicente.botet_at_[hidden]
>> :
> <...>
>> I have started two separated C++ proposals for overload [1] and match [2]
>> In case some have suggestions for improving them,
>> Vicente
>> [1]
>> proposals/overload/
>> [2]
> I like the idea of `overload` more than the `match` idea. `match` looks
> like a function that does two things: constructs an overloaded function
> object and applies it as a visitor. While the first thing could be widely
> usable, the visitation part applies only to the variant. This makes the
> `overload` method (that is not bound to variant) more usable than `match`.
As I said, match can be applied to any sum type. The github repository
contain examples for boost::variant, either(boost::optional) and a
selection of possible types for boost::any. It can be applied also to
expected, any smart pointer, boost::future or any probably valued type.

Hopping this helps to describe the motivation for a function that makes
code much safer than using directly functions to check if there is a
value and to get it.


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