如何在boost矢量中找到一个项目

时间:2016-05-10 10:47:16

标签: c++ boost

我正在使用vector of the Boost library,我需要检查某个特定项目是否存在。 Boost中是否存在类似于STL查找算法的任何函数,例如flock()

1 个答案:

答案 0 :(得分:1)

下面的代码用作stl find算法

包含标题

#include"boost\range\algorithm\find.hpp"
int main()
{
  boost::container::vector<int> my_intvector;

  my_intvector.push_back(1);
  my_intvector.push_back(2);
  my_intvector.push_back(3);  
  my_intvector.push_back(4);
  my_intvector.push_back(5);

  boost::container::vector::iterator it;
  it = boost::find(my_intvector,3);

}