从位置删除多个单词
定义
template <int... Positions> void removeWords (std::string& str);
将在位置上删除所有单词(令牌)位置...
的str
。例如,
removeWords<1,3,8>(sentence);
将从句子
中删除第一,第三和第8个单词。如何这样做,理想地使用C ++ 17倍表达式? pre c ++ 17,我们必须删除位置中的单词first
,然后必须将REST的所有值降低...
在使用之前再次,这是一团糟。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论