2016-05-10 14 views
-1

私はvector of the Boost libraryを使用しています。特定のアイテムが存在するかどうかを確認する必要があります。 BoostにSTL findアルゴリズムと同様の関数がありますか? std::find(vector.begin,vector.end, element)?コードの下ブーストベクターでアイテムを見つける方法

+3

を含む 'のstd ::見つける()は、' 'だけのstd :: vector'sで動作しません。 'std :: find'()は、イテレータの要件を満たすオブジェクトのペアで動作します。 –

+0

これは多分でしょうか? http://www.boost.org/doc/libs/1_54_0/libs/fusion/doc/html/fusion/algorithm/query/functions/find.html – CinCout

+2

関連:[contains](http://stackoverflow.com/質問/ 15640770/boostalgorithmcontains)関数、または[more examples](http://stackoverflow.com/questions/26186483/c-concisely-checking-if-item-in-stl-container-eg-vector) – Jens

答えて

1

STLの検索アルゴリズム

として機能ヘッダ

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

} 
関連する問題