Step 7 of 7
Challenge: a move-aware log
Put it together. std::exchange(obj, new_value) from <utility> sets obj to new_value and returns the old value, moving where it can. It's the tidy way to "take" a member and leave it reset:
return std::exchange(lines_, {}); // hand over the lines, leave an empty vector
Your turn: write class Log:
void add(std::string line): a sink; ignore empty linesint size() conststd::vector<std::string> flush(): hand over all lines (no copies) and leave the log empty