Andre Poenitz <[EMAIL PROTECTED]> writes: | On Sun, Oct 21, 2007 at 09:43:11PM +0200, Lars Gullik Bjønnes wrote: | > | > Does this look correct? | > [The #if0 vs. else parth] | > | > WriteStream & operator<<(WriteStream & ws, docstring const & s) | > { | > if (ws.pendingSpace() && s.length() > 0) { | > if (isAlphaASCII(s[0])) | > ws.os() << ' '; | > ws.pendingSpace(false); | > } | > ws.os() << s; | > #if 0 | > int lf = 0; | > docstring::const_iterator dit = s.begin(); | > docstring::const_iterator end = s.end(); | > for (; dit != end; ++dit) | > if ((*dit) == '\n') | > ++lf; | > #else | > int lf = std::count(s.begin(), s.end(), char_type('\n')); | > #endif | > ws.addlines(lf); | > return ws; | > } | | Looks ok to me.
Just let me add something... gcc 4.3's stdlibc++ will have support for a paralell mode, where some of the standard algorithms (and some other stuff) will automatically be able to take advantage of multi-core and smp. This also sees to be the trend for this kindo of paralallization: do it in the compiler and/or the support libraries instead of forcing applications to handle all threading themselves. So, for us to take advantage of some multi-processing almost for free, it is important to use std::algorithms when possible. -- Lgb