'Removing multiple words from by positions
Define
template <int... Positions> void removeWords (std::string& str);
that will remove all the word (tokens) in the positions Positions... of str. For example,
removeWords<1,3,8>(sentence);
will remove the 1st, 3rd, and 8th words from sentence. How to do this, ideally using C++17 fold expressions? Pre C++17, we would have to remove the word in position First, then then would have to decrease all the values of Rest... by 1 before applying it again, which is a total mess.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
