home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13221 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.6 KB  |  57 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
  3. From: jss@lucid.com (Jerry Schwarz)
  4. Subject: Re: Destruction of temporaries
  5. Message-ID: <1992Sep2.192339.2774@lucid.com>
  6. Sender: usenet@lucid.com
  7. Reply-To: jss@lucid.com (Jerry Schwarz)
  8. Organization: Lucid, Inc.
  9. References: <rmartin.715101472@thor> <1992Aug29.184025.328@frumious.uucp> <rmartin.715267769@thor> <1992Sep2.042030.488@frumious.uucp>
  10. Date: Wed, 2 Sep 92 19:23:39 GMT
  11. Lines: 44
  12.  
  13. In article <1992Sep2.042030.488@frumious.uucp>, pat@frumious.uucp (Patrick Smith) writes:
  14. |> 
  15. |> So I think it would be a better idea for the programmer to identify
  16. |> those functions which can't be called with temporaries as arguments,
  17. |> instead of those which can.  As, for example, in Eric Smith's
  18. |> proposal upon which I commented in another posting.
  19.  
  20. Several people have expressed opinions that seem to suggest that
  21. there are some functions that should be called with temporaries
  22. and some that shouldn't.  I don't have the same intuition.
  23.  
  24. In particular, I'm assuming that they would designate that the
  25. first argument of all my insertors as not usable with temporaries.
  26.  
  27.    ostream& operator<<(ostream& out, MyType& mytype) ;
  28.  
  29. But the description of these is clear.  They return their first
  30. argument.  Except that they have a side effect on out they are
  31. identity functions.  So if I have a function, h that accepts
  32. an ostrstream& I can call
  33.  
  34.     h( ostrstream() ) ;
  35.  
  36. but not 
  37.  
  38.     h ( ostrstream() << "contents" << ends ) ;
  39.  
  40. This doesn't make much sense to me.  It is one of the
  41. reasons I am strongly opposed to "earliest possible" destruction
  42. of temporaries.
  43.  
  44.   -- Jerry Schwarz
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.