Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Coding style conformance

...

Code Block
bgColor#FFcccc
langcpp
#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
bgColor#ccccff
langcpp
#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())

...