octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Random questions


From: Júlio Hoffimann
Subject: Re: Random questions
Date: Wed, 26 Dec 2012 18:20:57 -0300

Hi Dan,

   // FIXME -- removing all commas does too much...
-  std::string::iterator se = str.end ();
-  se = std::remove (str.begin (), se, ',');
-  str.erase (se, str.end ());
+  str.erase (std::remove (str.begin (), str.end(), ','), str.end ());

What is the FIXME about in this code hunk?  Can the code be fixed and the comment removed?

We should keep the FIXME clause, because of locale issues.
 
Also, be careful about the new _expression_.  I can't recall any statements about defined order of evaluation for C++ function arguments.  If the rightmost str.end() is evaluated before the leftmost str.end(), could it be problematic?  Maybe there is something about the recursive level I don't recall, but if there is a reference that ensures order, please indicate.

This is known as the Erase-Remove idiom: http://en.wikipedia.org/wiki/Erase-remove_idiom

Júlio.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]