🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++
Article #215

Defining operators

#215
From: Michael Tiemann
Date: Wed, 22 Nov 1989 10:01
26 lines
1283 bytes
    Why not allow a third form, where the caller would pass as a third argument
    a reference to the place where the result should be put?

    void operator+(matrix& x, matrix& y, matrix& result) { ... }

    The previous example would translate into:
	    matrix U;
	    operator+(A,B,U);
	    operator+(U,C,X);
    and no copying would be necessary. Am I missing something obvious?

	 Daniel Ranson
	 X400: ranson@lannion.cnet.fr
	 uucp: ranson@cnetlu.fr, or ...!mcvax!inria!cnetlu!ranson

Why not allow a fourth form, using Named Return Values (see
July/August C++ Report for details of this GNU C++ language
extension):

matrix operator+(matrix& x, matrix& y) return z { ... }

This permits the compiler to give the effiency of return-by-reference
with the semantics of return-by-value.

Michael
Technical Details
Message-ID: <8911221001.AA29853@lurch.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!LURCH.STANFORD.EDU!tiemann
References: <1253@cnetlu.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!LURCH.STANFORD.EDU!tiemann
From: tiemann@LURCH.STANFORD.EDU (Michael Tiemann)
Newsgroups: gnu.g++
Subject: Defining operators
Message-ID: <8911221001.AA29853@lurch.Stanford.EDU>
Date: 22 Nov 89 10:01:52 GMT
References: <1253@cnetlu.UUCP>
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: tiemann@lurch.stanford.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 26