I'm just guessing here (and I'll probably remove the answer if it doesn't solve your problem).
Try to replace the line containning std::transform
with these two:
auto dest = transformValue.begin();
std::transform(transformValue.cbegin(), transformValue.cend(), dest, &::tolower);
Notice the use of cbegin()
and cend()
(rather than begin()
and end()
).
On another topic: You're copying the string passed to ConvertStdStringToBool
twice when you could do it just once. To do this, replace:
bool ConverterUtil::ConvertStdStringToBool(const std::string value)
{
std::string transformValue = value;
with
bool ConverterUtil::ConvertStdStringToBool(std::string transformValue)
{
(You might want to rename transformValue
to value
after this change).
Update: My explanation why I think it's going to help.
First of all, notice that transformValue
is non const
. Hence, transformValue.begin()
and transformValue.end()
will call these overloads:
iterator begin(); // non const overload
iterator end(); // non const overload
Hence the static analyser (rightly) concludes that begin()
and end()
might change the state of transformValue
. In this case, the final state of transformValue
might depend on which of begin()
and end()
is called first.
Now, when you call cbegin()
and cend()
, the overloads are these:
const_iterator cbegin() const; // notice the const
const_iterator cend() const; // notice the const
In this case, the static analyser will not deduce that these calls will change the state of transformValue
and doesn't raise the issue. (Strictly speaking even though the methods are const
they could change the state because there could exist mutable
data members in the class or the methods could use an evil const_cast
. IMHO, the static analyser shouldn't be blamed for that.)
Final remark: The call
std::transform(transformValue.cbegin(), transformValue.cend(), transformValue.cbegin(), &::tolower);
^^^^^^
is wrong. The third argument must be the non const
iterator, that is, it must be transformValue.begin()
(only the first two arguments are the c*
methods).
However, I guess, for a similar reasoning as above, just using transformValue.begin()
as the third argument won't be enough and that's why I suggested creating another variable (dest
).