Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #11764

Re: Mutability of temporary variables

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!198.186.194.247.MISMATCH!news-out.readnews.com!transit3.readnews.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-b-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
Content-Type text/plain; charset=utf-8; format=flowed; delsp=yes
Newsgroups comp.lang.c++
Subject Re: Mutability of temporary variables
References <op.v4605gilpbcp0d@localhost.localdomain> <ja8dkh$snr$1@news.albasani.net>
Date Thu, 24 Nov 2011 00:50:43 +0100
MIME-Version 1.0
Content-Transfer-Encoding Quoted-Printable
From kyle <kyle@nomail.com>
Organization none
Message-ID <op.v5fa6tmvpbcp0d@localhost.localdomain> (permalink)
User-Agent Opera Mail/11.50 (Linux)
Lines 33
NNTP-Posting-Host 83.25.64.105
X-Trace 1322092242 unt-rea-a-01.news.neostrada.pl 2203 83.25.64.105:35360
X-Complaints-To abuse@news.neostrada.pl
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:11764

Show key headers only | View raw


Dnia 19-11-2011 o 16:16:45 Johannes Schaub  
<schaub.johannes@googlemail.com> napisaƂ(a):

> kyle wrote:
>
>> Consider following code:
>>
>> int main() {
>>    const int& c = int();
>>    int& m = const_cast<int&>(c);
>>    m = 4;
>> }
>>
>
> The error in your thinking is that you think that "int()" is a temporary
> object.
>

This is indeed what i assumed.
As i understand, i could 'fix' the code by having a function 'int foo()  
{return 1;}' and using it in place of 'int()'?

Unfortunately, what i originally planned to do is illegal for entirely  
different reason ;)

-- 
kyle

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Mutability of temporary variables kyle <kyle@nomail.com> - 2011-11-19 13:33 +0100
  Re: Mutability of temporary variables Paavo Helde <myfirstname@osa.pri.ee> - 2011-11-19 07:18 -0600
    Re: Mutability of temporary variables Victor Bazarov <v.bazarov@comcast.invalid> - 2011-11-19 08:45 -0500
      Re: Mutability of temporary variables Leigh Johnston <leigh@i42.co.uk> - 2011-11-19 14:25 +0000
        Re: Mutability of temporary variables "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2011-11-20 00:14 +0000
          Re: Mutability of temporary variables Leigh Johnston <leigh@i42.co.uk> - 2011-11-20 00:45 +0000
            Re: Mutability of temporary variables Leigh Johnston <leigh@i42.co.uk> - 2011-11-20 01:14 +0000
              Re: Mutability of temporary variables "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2011-11-20 02:34 +0000
                Re: Mutability of temporary variables "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2011-11-20 02:44 +0000
                Re: Mutability of temporary variables Leigh Johnston <leigh@i42.co.uk> - 2011-11-20 13:06 +0000
                Re: Mutability of temporary variables Leigh Johnston <leigh@i42.co.uk> - 2011-11-20 13:21 +0000
                Re: Mutability of temporary variables "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2011-11-20 16:51 +0000
                Re: Mutability of temporary variables Leigh Johnston <leigh@i42.co.uk> - 2011-11-20 17:24 +0000
      Re: Mutability of temporary variables SG <s.gesemann@gmail.com> - 2011-11-20 00:49 -0800
  Re: Mutability of temporary variables Victor Bazarov <v.bazarov@comcast.invalid> - 2011-11-19 08:42 -0500
    Re: Mutability of temporary variables Paavo Helde <myfirstname@osa.pri.ee> - 2011-11-19 08:20 -0600
      Re: Mutability of temporary variables Victor Bazarov <v.bazarov@comcast.invalid> - 2011-11-19 15:51 -0500
        Re: Mutability of temporary variables Paavo Helde <myfirstname@osa.pri.ee> - 2011-11-19 16:51 -0600
        Re: Mutability of temporary variables "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2011-11-20 00:23 +0000
  Re: Mutability of temporary variables Johannes Schaub <schaub.johannes@googlemail.com> - 2011-11-19 16:16 +0100
    Re: Mutability of temporary variables "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2011-11-20 00:31 +0000
    Re: Mutability of temporary variables kyle <kyle@nomail.com> - 2011-11-24 00:50 +0100
      Re: Mutability of temporary variables Johannes Schaub <schaub.johannes@googlemail.com> - 2011-11-24 20:36 +0100
  Re: Mutability of temporary variables SG <s.gesemann@gmail.com> - 2011-11-21 01:17 -0800
    Re: Mutability of temporary variables Johannes Schaub <schaub.johannes@googlemail.com> - 2011-11-22 23:26 +0100

csiph-web