Can't cash str.begin when "insert" is involved.

This commit is contained in:
Ivan Popivanov 2014-11-03 19:31:42 -05:00
parent 279370c5cb
commit bc87b2841b

View File

@ -93,12 +93,11 @@ void insertThousandSep(std::string& str, char thSep, char decSep = '.')
std::string::size_type decPos = str.find(decSep);
// there's no rinsert, using forward iterator to go backwards
std::string::iterator it = str.end();
std::string::iterator begin = str.begin();
if (exPos != std::string::npos) it -= str.size() - exPos;
if (decPos != std::string::npos)
{
while (it != begin)
while (it != str.begin())
{
--it;
if (*it == decSep) break;
@ -106,7 +105,7 @@ void insertThousandSep(std::string& str, char thSep, char decSep = '.')
}
int thCount = 0;
if (it == str.end()) --it;
for (; it != begin;)
for (; it != str.begin();)
{
std::string::iterator pos = it;
std::string::value_type chr = *it;