A search in a vector with elements of a custom type is possible - via find using the equality operator, or find_if with the provision of a search predicate.
An example is below.
struct Test { string name; vector<int> data; bool operator==(const Test& t) { return name == t.name; } }; int main(int argc, const char * argv[]) { vector<Test> v{ {"a",{1,2,3}}, {"b",{4,5,6}}, {"c",{7,8,9}} }; // Поиск с использованием оператора равенства (ищем с name=="b") if (auto t = find(v.begin(),v.end(),Test{"b",{}}); t != v.end()) { for(auto i: t->data) cout << i << " "; cout << endl; } // Поиск с использованием предиката - тот, где первый элемент data - 7 if (auto t = find_if(v.begin(),v.end(), [](const Test& q){ return q.data.size()>0 && q.data[0] == 7; }); t != v.end()) { for(auto i: t->data) cout << i << " "; cout << endl; } }
find_ifwith the corresponding predicate. - Harry