Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2004-07-22 20:04:03


"Andy Little" <andy_at_[hidden]> wrote

> I want variables!
> In context of my physical quantities library types resulting from calcs
are
> computed in non-trivial ways.
> If the programmer has a complicated calculation then declaring a variable
> may force a scaling
>
> q_area::mm2 a;
> q_length:: mm b;
> q_length::m c = a / b;
>
> In the above, the temporary result of a / b will be divided by 1000 in
the
> assign to cc, because the programmer has forced this by the l_value
> assignment,but:
>
> auto c = a / b;

I don't think you really want lvalues. You would only want to preserve
lvalue if you want to do something like:

a /b = 5;

and I don't think that is what you want.

The "auto" is implemented via typeof, not via decltype. So your type is
always a value. If you want a reference, you explicitly specify this:

int& foo();
auto p = foo(); // int
auto& p = foo(); //int&

The same can be emulated with BOOST_AUTO:

BOOST_AUTO(p, foo());// int
BOOST_AUTO(&p, foo());//int&

Arkadiy


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