qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Qpid Wiki] Update of "CppTips/BewareStdStringLiterals" by AlanConway
Date Tue, 19 Sep 2006 12:25:45 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Qpid Wiki" for change notification.

The following page has been changed by AlanConway:

  The short story: in C++ code using `std::string` never use string literals except to initialize
static-scoped `std::string` constants.
- (And by the way: NeverUseStaticLocalVariables)
+ (And by the way: CppTips/NeverUseStaticLocalVariables)
  The long story: `std::string` is all about avoiding copies. Reference counting and copy-on-write
serve to maximise the sharing of a single heap-allocated char array while maintaining memory
safety. When used consistently in a program it works rather nicely.
@@ -31, +31 @@

  void f() { std::string x; while (x != end) {...} }
- And once again NeverUseLocalStaticVariables.
+ And once again CppTips/NeverUseLocalStaticVariables.

View raw message