...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <string> void f(const std::string &input) { std::string email; // Copy input into email converting ";" to " " std::string::iterator loc = email.begin(); for (auto Ii = input.begin(), Ee = input.end(); Ii != Ee; ++Ii, ++loc) { email.insert(loc, *Ii != ';' ? *Ii : ' '); } } |
Compliant Solution (std::string::insert()
)
...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <string> void f(const std::string &input) { std::string email; // Copy input into email converting ";" to " " std::string::iterator loc = email.begin(); for (auto Ii = input.begin(), Ee = input.end(); Ii != Ee; ++Ii, ++loc) { loc = email.insert(loc, *Ii != ';' ? *Ii : ' '); } } |
Compliant Solution (std::replace()
)
...