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
> 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
> 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&


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