1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| #include <iostream>
#include <vector>
#include <algorithm>
struct Test {
Test(int const val=int{}): mValue{val} {};
int mValue;
};
bool operator==(Test const & left, Test const & right) { return left.mValue == right.mValue; }
bool operator!=(Test const & left, Test const & right) { return !(left==right); }
int main() {
std::vector<Test> tab(10, Test{});
tab[5].mValue = 66;
auto it{ std::find( tab.begin(), tab.end(), [](Test & obj){ return obj.mValue == 66 ? true : false; }) };
std::cout << it->mValue << '\n';
return 0;
} |