remove all the elements except last list c++ code example
Example: C++ drop last element of list
std::string res; // sample
// do things
if (res.size() > 0 ) res.pop_back();
return res; // typical next instruction
// alternative
return res.substr(0, res.size() - 1);