C++ performance myths debunked

Andy Salnikov a_salnikov at yahoo.com
Mon Aug 5 19:36:45 EDT 2002

"Gerson Kurz" <gerson.kurz at t-online.de> wrote in message
news:3d4acdcc.18746140 at news.t-online.de...
> Download the libraries from over at www.boost.org. Compile a sample
> program (with VC6), get 31 warnings like this (I'm not making this up,
> and yes, it is *one* single warning):
> This is the sample code
>    string s = "This is,  a test";
>    tokenizer<> tok(s);
>    for(tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg)
>    {
>       const char* shit = beg->c_str();
>    }
  C'mon, real C++ programmers do not know what const char* is :) Last
line of code _must_ read:

  const string& shit = beg ;

You really really do not want c_str() in any code which pretends to be fast.

Other guys said enough about optimization, I only want to note that boost
library is kinda raw around corners, wait until they get it into C+ standard
vendors implement their own super-fast versions (which can take a while :)


More information about the Python-list mailing list