Path: 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 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