Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: s/l/loc/g;

...

Code Block
bgColor#FFcccc
langcpp
#include <string>
#include <locale>

void capitalize(std::string &s) {
  std::locale lloc;
  s.front() = std::use_facet<std::ctype<char>>(lloc).toupper(s.front());
}

Compliant Solution

...

Code Block
bgColor#ccccff
langcpp
#include <string>
#include <locale>

void capitalize(std::string &s) {
  if (s.empty()) {
    return;
  }

  std::locale lloc;
  s.front() = std::use_facet<std::ctype<char>>(lloc).toupper(s.front());
}

Risk Assessment

...