-1

I am using vector of the Boost library, and I need to check if a particular item is present or not. Is there any function in Boost similar to STL find algorithm, e.g. std::find(vector.begin,vector.end, element)?

Jens
  • 8,423
  • 9
  • 58
  • 78
Ushus
  • 63
  • 1
  • 6
  • 3
    `std::find()` doesn't work with only `std::vector`s. `std::find`() will work with any pair of objects that meet the requirements of an iterator. – Sam Varshavchik May 10 '16 at 10:50
  • Maybe this? http://www.boost.org/doc/libs/1_54_0/libs/fusion/doc/html/fusion/algorithm/query/functions/find.html – CinCout May 10 '16 at 10:51
  • 2
    Related: [contains](http://stackoverflow.com/questions/15640770/boostalgorithmcontains) function, or [more examples](http://stackoverflow.com/questions/26186483/c-concisely-checking-if-item-in-stl-container-e-g-vector) – Jens May 10 '16 at 10:52

1 Answers1

1

Below code works as stl find algorithm

include the header

#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);

}
Ushus
  • 63
  • 1
  • 6