home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13062 < prev    next >
Encoding:
Text File  |  1992-08-30  |  982 b   |  25 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!stanford.edu!agate!tfs.com!tfs.com!eric
  3. From: eric@tfs.com (Eric Smith)
  4. Subject: Proposal: static T& function argument
  5. Message-ID: <1992Aug30.000250.12486@tfs.com>
  6. Organization: TFS
  7. Date: Sun, 30 Aug 1992 00:02:50 GMT
  8. Lines: 15
  9.  
  10.  
  11. My earlier proposal of auto T& turns out to be unneeded because
  12. good compilers can optimize to get the same effect if the
  13. programmer uses T instead of T&.  Thanks to everyone who pointed
  14. that out.
  15.  
  16. Here is another proposal that might simplify the issue about
  17. lifetime of temporaries.  If a function formal argument is
  18. specified as static T& the programmer doesn't want any calls
  19. using references to temporaries.  The "static" in the static T&
  20. in that context tells the compiler to issue an error message
  21. at compile time whenever anyone tries to call that function with
  22. a temporary.  This allows the function to safely return a
  23. reference or pointer to the static T& argument knowing it can't
  24. be a temporary.
  25.