by MathMonkeyMan · 4w ago · 0 comments
Would you return `input.c_str()`? You might think twice about that, but it's the same thing. My favorite fix is to take a `std::string_view` as the parameter.
string_view remove_leading_spaces(string_view input) {
auto new_start = find_if(input.begin(), input.end(), [](char ch) { return ch != ' '; });
return string_view(new_start, input.end());
}
The result of the undefined behavior in your program is surprising, though. As it usually is.No comments yet.