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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!secapl!Cookie!frank
  3. From: frank@Cookie.secapl.com (Frank Adams)
  4. Subject: Re: Destruction of temporaries
  5. Message-ID: <1992Sep02.231236.168687@Cookie.secapl.com>
  6. Date: Wed, 02 Sep 1992 23:12:36 GMT
  7. References: <rmartin.715267769@thor> <1992Sep2.042030.488@frumious.uucp> <1992Sep2.192339.2774@lucid.com>
  8. Organization: Security APL, Inc.
  9. Lines: 25
  10.  
  11. In article <1992Sep2.192339.2774@lucid.com> jss@lucid.com (Jerry Schwarz) writes:
  12. >In article <1992Sep2.042030.488@frumious.uucp>, pat@frumious.uucp (Patrick Smith) writes:
  13. >Several people have expressed opinions that seem to suggest that
  14. >there are some functions that should be called with temporaries
  15. >and some that shouldn't.  I don't have the same intuition.
  16. >
  17. >In particular, I'm assuming that they would designate that the
  18. >first argument of all my insertors as not usable with temporaries.
  19. >
  20. >   ostream& operator<<(ostream& out, MyType& mytype) ;
  21. >
  22. >But the description of these is clear. They return their first
  23. >argument.  Except that they have a side effect on out they are
  24. >identity functions.
  25.  
  26. It isn't clear from the prototype.  In other words, there is no way for the
  27. compiler to know it.
  28.  
  29. I think this is part of a more general problem with functions that return
  30. their arguments in C++.  Consider the problem with the const-ness of the
  31. return results of functions returning an argument.  We have a solution to
  32. this, sort of, but it isn't very good: it involves making an exception to
  33. the type checking.
  34.  
  35. This isn't an answer; just an attempt to redefine the question.
  36.