#include <iostream>
#include <vector>
#include <algorithm>
struct Item
{
int attribute;
};
void fun(const Item &i)
{
std::cout << "Item with attr: " << i.attribute << std::endl;
}
int main() {
std::vector<Item> items = {
Item {1}, Item {4}, Item{8}
};
fun(*std::find_if(items.begin(), items.end(), [](const Item &i) {return i.attribute == 4; }));
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKc3RydWN0IEl0ZW0KewoJaW50IGF0dHJpYnV0ZTsKfTsKCnZvaWQgZnVuKGNvbnN0IEl0ZW0gJmkpCnsKCXN0ZDo6Y291dCA8PCAiSXRlbSB3aXRoIGF0dHI6ICIgPDwgaS5hdHRyaWJ1dGUgPDwgc3RkOjplbmRsOwp9CgppbnQgbWFpbigpIHsKCXN0ZDo6dmVjdG9yPEl0ZW0+IGl0ZW1zID0gewoJCUl0ZW0gezF9LCBJdGVtIHs0fSwgSXRlbXs4fQoJfTsKCQoJZnVuKCpzdGQ6OmZpbmRfaWYoaXRlbXMuYmVnaW4oKSwgaXRlbXMuZW5kKCksIFtdKGNvbnN0IEl0ZW0gJmkpIHtyZXR1cm4gaS5hdHRyaWJ1dGUgPT0gNDsgfSkpOwoJCglyZXR1cm4gMDsKfQ==