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

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

 



Hi John,

John Love-Jensen wrote:
> [...]
> The rationale is in the Design & Evolution of C++.

I'll have that soon.

> 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).

Ahh, now I see. This really helps me understanding the design of C++ here.

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

Yes, but by doing so I start writing code for the machine again. I write code 
for other programmers to read it. And if you take a look at the auto_ptr 
implementation: it's really hard to read.

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

I'd like to, as long as the code keeps readable. The auto_ptr approach is no 
option for me. In my case it's just about a bool attribute that need's to be 
changed. One solution could be to just make it mutable.

Thanks,
  Christian

[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