Boost logo

Boost :

Subject: Re: [boost] A more convenient Variant visitation syntax
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-04-14 23:49:05


on Sat Apr 14 2012, Thomas Heller <thom.heller-AT-googlemail.com> wrote:

> On Sat, Apr 14, 2012 at 5:41 PM, Mathias Gaunard
> <mathias.gaunard_at_[hidden]> wrote:
>> On 14/04/12 17:00, Kevin Wu Won wrote:
>>>
>>> This is C++11 only because it's quite pointless without lambda
>>> functions.  I've tested it with gcc 4.7.  It doesn't work on gcc 4.6,
>>> which can't handle the variadic templates.
>>
>>
>> It can be done in C++03 and expression-template-based lambdas just fine as
>> well.
>>
>> All you need to do is generate a function object that inherits recursively
>> from a set of other function objects.
>>
>> The function objects in question need to be either monomorphic or to be
>> sufficiently constrained with SFINAE so that each operator() overload is not
>> ambiguous.
>>
>> Unfortunately, Boost.Phoenix was never extended to support this.
>
> I really like the idea, and i think the C++11-based solution above is
> nice! I didn't have the time yet to glance through the code though ...
>
> Phoenix didn't tackle that yet because it is a hard problem ... the
> main problem is the syntax how to express which lambda is responsible
> for what types. The above solution with C++11 lambdas is nice indeed!

Yeah, the first time I've actually been happy that non-polymorphic
lambdas exist! Nice idea, Kevin!

> However, what's missing is something like a "catch all" aka a
> templated lambda ...

...ah, yes... there's the rub. And my day is now spoiled :-)

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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