Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-12-15 21:04:11


Arkadiy Vertleyb wrote:
>
> What is current state of the art on l-value/r-value detection? (I know Eric
> made some progress in the past by using the "?" operator).
>
> What we have in typeof is quite primitive :-(
>
> I think it might be a good idea to eventially factor it out into a separate
> header file, and reuse, to avoid contradictions between different libs, and
> provide the single point of maintenance...

FOREACH does rvalue detection that is able to detect even
const-qualified rvalues on highly conforming compilers, but there is a
serious limitation to the technique: it doesn't yield a compile-time
constant. This means it is not applicable to typeof, sadly.

The closest I've been able to come to reliable, compile-time detection
of rvalues in standard C++ is to see if the expression can be bound to a
reference. Naturally, this is foiled by const-qualified rvalues. I think
that's what you're already doing in typeof, right?

It's an open question whether it's possible to do this in standard C++.
If it's possible, I'd be very interested.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

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