How to find out if an item is present in a std::vector?

后端 未结 18 2565
滥情空心
滥情空心 2020-11-22 05:31

All I want to do is to check whether an element exists in the vector or not, so I can deal with each case.

if ( item_present )
   do_this();
else
   do_that(         


        
18条回答
  •  面向向阳花
    2020-11-22 06:19

    With boost you can use any_of_equal:

    #include 
    
    bool item_present = boost::algorithm::any_of_equal(vector, element);
    

提交回复
热议问题