🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3863

Re: Rationale behind disallowal of non-const r

#3863
From: Helmut Jarausch
Date: Fri, 29 Mar 1996 17:07
51 lines
2504 bytes
In article <4jevb1$kkp@engnews1.Eng.Sun.COM>, clamage@Eng.sun.com (Steve
Clamage) writes:
> In article 96Mar27195129@trigati.cs.haverford.edu,
> davew@trigati.cs.haverford.edu (David G. Wonnacott) writes:
> >
> >I am looking for an explanation for the rationale behind the decision
> >of the standards committee to disallow the binding of a non-const
> >reference to an rvalue.

SNIP



> 
> Yes, there are times when you would like to be able to bind an rvalue
> to a non-const reference, since the only things you care about are
> sure to happen anyway. For example, given a class T:
> 	T f1();     // f1 returns a T rvalue
> 	f1().foo(); // ok only if foo is a const member function of T
> Sometimes you don't care about the effects of foo on the object here,
> and you only want the external side-effects of foo. I believe the C++
> committee looked for ways to allow this binding of an rvalue to a non-const
> reference in cases where the results were what was intended, but failed to
> find a good way to define those cases.

What about the following rule

class T
{
  change() { ...};
  lookat() { ...} const;
}

      T f1(){ ...};
const T f2(){...};

f1().change(); // should be OK
f2().change(); // should be an error
f2().lookat(); // should be OK

Helmut Jarausch
Institute of Technology
RWTH-Aachen
Germany
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]
Technical Details
Message-ID: <4jgukv$dcg@news.rwth-aachen.de>
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern
References: <DAVEW.96Mar27195129@trigati.cs.haverford.edu> <4jevb1$kkp@engnews1.Eng.Sun.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern
From: jarausch@igpm.rwth-aachen.de (Helmut Jarausch)
Newsgroups: comp.std.c++
Subject: Re: Rationale behind disallowal of non-const r
Date: 29 Mar 1996 09:07:33 PST
Organization: RWTH Aachen (Inst. f. Geometrie & Prakt. Mathematik)
Approved: austern@isolde.mti.sgi.com
Message-ID: <4jgukv$dcg@news.rwth-aachen.de>
References: <DAVEW.96Mar27195129@trigati.cs.haverford.edu> <4jevb1$kkp@engnews1.Eng.Sun.COM>
NNTP-Posting-Host: isolde.mti.sgi.com
X-Original-Date: 29 Mar 1996 15:12:31 GMT
X-Newsreader: xrn 7.00 (Motif)
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMVwY1ky4NqrwXLNJAQFEQAH9FCkwlnJ9NWFUECmobeqwrGx5EynPYM6P
 CCWk4jjfq0VtCLx7Sac1pX9DlxGT+RPhFZ8bp77A+W3z4HlZeX6Rzw==
 =6ePO
Originator: austern@isolde.mti.sgi.com