This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: non-const reference to temporary (was: non-const copy ctor)
Hi Andrew,
Andrew Haley wrote:
> [...]
> I can. "The initializer of a const T& need not be an lvalue..." In
> other words, although he doesn't explicitly say so, the initializer of
> a const T& has to be an lvalue.
Yes, I guessed so as well. But what's the reason for this decision?
>
> > I understand that it generally doesn't make sense to alter a
> > temporary object. But why forbid it?
>
> Because, semantically speaking, it makes no sense.
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).
Thanks,
Christian
>
> But we're way off topic now.
>
> Andrew.