发布于 1年前

判断std::vector里是否存在指定的元素?

可以使用<algorithm>的std::find来搜索vector

#include <algorithm>

if ( std::find(vector.begin(), vector.end(), item) != vector.end() )
   do_this();
else
   do_that();</algorithm>
C++
©2020 edoou.com   京ICP备16001874号-3