値が構造体へのポインターのベクトル内にあるかどうかを調べるために、lower_bound を使用しようとしています。私は使っている
auto it = lower_bound( myVector.begin() , myVector.end() , value , comparer() );
比較関数は次のようになります
struct comparer
{
bool operator ()(Property * ms, int const i) const
{
return ms -> ID < i;
};
};
上記のIDを持つ要素が見つかったかどうかを確認したい。どうすれば確認できますか?使ってみた
if( (*it) -> ID == value ) {
return false;
}
しかし、これはセグメンテーション違反をスローしています。要素が既に存在するかどうかを確認する方法はありますか?