Re: non-const reference to temporary (was: non-const copy ctor)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Christian,
 
> Yes, I guessed so as well. But what's the reason for this decision?

The rationale is in the Design & Evolution of C++.

Synopsis:  it would be far too easy to accidentally use a temporary as an
lvalue, especially since C++ is "helpful" by doing implicit conversions
(which may create temporaries otherwise unbeknownst to the programmer).

> Yes, mostly. And that this is forbidden imposes a problem in the rare cases
> where it does make sense. And in those cases where someone does not want to
> use const at all (like me).

One workaround to the language safety feature is to do what auto_ptr does.

A better workaround is to design the application so that it wouldn't need to
use non-const references to temporaries.

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux