erase() after performing remove_if()

前端 未结 2 1852
囚心锁ツ
囚心锁ツ 2020-12-20 12:50

I\'ve created a function to run through a vector of strings and remove any strings of length 3 or less. This is a lesson in using the STL Algorithm library.

I\'m ha

2条回答
  •  甜味超标
    2020-12-20 13:03

    You should be using the two parameter form of erase:

    myVector.erase(remove_if(myVector.begin(), myVector.end(), StringLengthTest),
                   myVector.end());
    

提交回复
热议问题