Boost logo

Boost :

Subject: Re: [boost] [typeof][implementation]why not use decltype or conditional expr?
From: Michel Morin (mimomorin_at_[hidden])
Date: 2012-08-05 07:04:00


paul Fultz wrote:
>>And if decltype not available, why couldn't it use the
>>conditional expression method described here:
>>
>> http://www.artima.com/cppsource/foreach2.html
>>
>
>
> Actually, the rvalue detection techniques in the article could be used to
> create a better decltype emulation on older compilers. I use this here:
>
> https://github.com/pfultz2/Zelda/blob/master/zelda/typeof.h
>
> Its a macro called ZELDA_XTYPEOF, which in C++11 is the equivalent
> of decltype(()) with double parenthesis. On older compilers,
> it will bind to a reference, unless its an rvalue which it will not
> have a reference.

On C++03-compliant compilers, you cannot use Boost.Foreach's technique
to detect rvalueness for classes with a template conversion operator.

Regards,
Michel


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