Fundamentals
Strings
#include <algorithm> std::string digest(const std::string& param) { std::string result; std::for_each(param.begin(), param.end(), [&result](char i){result.push_back(i); result.push_back(' ');}); result.pop_back(); return result; }
- #include <algorithm>
- std::string digest(const std::string& param) {
std::string result;result.reserve(param.size() * 2); // Ensure exactly one memory allocationfor (char letter: param) {result.push_back(letter);result.push_back(' ');}result.pop_back();return result;- std::string result;
- std::for_each(param.begin(), param.end(), [&result](char i){result.push_back(i); result.push_back(' ');});
- result.pop_back();
- return result;
- }