如何在助推向量中查找项目

How to find an item in boost vector

本文关键字:查找 项目 向量      更新时间:2023-10-16

我正在使用Boost库的vector,我需要检查是否存在特定项。Boost中是否有类似STL查找算法的功能,例如std::find(vector.begin,vector.end, element)

以下代码作为stl查找算法工作

包括标题

#include"boostrangealgorithmfind.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);
}