home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18013 < prev    next >
Encoding:
Text File  |  1992-12-15  |  1.6 KB  |  47 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!utcsri!torn!mcshub!aruba!ruby!sandys
  3. From: sandys@aruba.UUCP (Sandy Schindler)
  4. Subject: inlining friend functions
  5. Message-ID: <1992Dec15.182858.22555@aruba.uucp>
  6. Sender: sandys@aruba (Sandy Schindler)
  7. Date: Tue, 15 Dec 1992 18:28:58 GMT
  8. Organization: Project Zed
  9. Keywords: friend inline
  10. Lines: 35
  11.  
  12. I would like to inline some friend functions for a class, without placing
  13. the method definitions inside the class declaration.  Such as:
  14.  
  15. class Foo{
  16. public:
  17.   friend inline doFoo(const Foo&, const Foo&);
  18. };
  19.  
  20. inline doFoo(const Foo& f1, const Foo& f2)
  21. {
  22.    //something...
  23. }
  24.  
  25. This _should_ be legal, according to the 2nd ed., pg 567, "A friend 
  26. function defined in a class declaration is inline and the rewriting rule 
  27. specified for member functions (r9.3.2) is applied..."  The HP C++ 
  28. compilers (2.x and 3.0) compile this sort of thing without complaint.
  29.  
  30. BUT, when I try to compile this with Borland's C++ 3.1, I get the error
  31. message 
  32.   Error inl.hh, line xx: Storage class 'inline' is not allowed here 
  33. Borland will not allow the inline keyword to used on a friend function 
  34. inside a class declaration, no matter where the definition happens.
  35.  
  36. Is this a mere compiler bug on Borland's part, or is this the first 
  37. appearance of a standard restriction?  I hope not.  With the volume of 
  38. code we're working on, omitting the inline keyword from the headers is not 
  39. an option.
  40.  
  41.  
  42. -- 
  43.             ...Mix it all together, and viola! ... hmm, wait, that's not quite it...
  44. Sandy Schindler                  |Internet Style: aruba!sandys@uu2.psi.com
  45. Systems Programming/UI, Club Zed |UUCP: ...!uunet!uu2.psi.com!aruba!sandys
  46.  
  47.