#include <vector>
#include <algorithm>
#include <functional>
#include <iostream>
using find_ten_t = std::pair<std::reference_wrapper<const std::vector<int>>, std::vector<int>::const_iterator>;
auto find_ten = [](const std::vector<int>& v1, const std::vector<int>& v2) -> find_ten_t {
auto it1 = std::find(v1.cbegin(), v1.cend(), 10);
if (it1 != v1.cend()) {
return std::make_pair(std::ref(v1), it1);
}
auto it2 = std::find(v2.cbegin(), v2.cend(), 10);
return std::make_pair(std::cref(v2), it2);
};
int main() {
std::vector<int> v1{ 1, 2, 3 };
std::vector<int> v2{ 3, 4, 10 };
auto r = find_ten(v1, v2);
std::cout << "r.first[0] = " << r.first.get()[0] << "\n";
}
CSNpbmNsdWRlIDx2ZWN0b3I+CgkjaW5jbHVkZSA8YWxnb3JpdGhtPgoJI2luY2x1ZGUgPGZ1bmN0aW9uYWw+CgkjaW5jbHVkZSA8aW9zdHJlYW0+CgoJdXNpbmcgZmluZF90ZW5fdCA9IHN0ZDo6cGFpcjxzdGQ6OnJlZmVyZW5jZV93cmFwcGVyPGNvbnN0IHN0ZDo6dmVjdG9yPGludD4+LCBzdGQ6OnZlY3RvcjxpbnQ+Ojpjb25zdF9pdGVyYXRvcj47CgoJYXV0byBmaW5kX3RlbiA9IFtdKGNvbnN0IHN0ZDo6dmVjdG9yPGludD4mIHYxLCBjb25zdCBzdGQ6OnZlY3RvcjxpbnQ+JiB2MikgLT4gZmluZF90ZW5fdCB7CgkJYXV0byBpdDEgPSBzdGQ6OmZpbmQodjEuY2JlZ2luKCksIHYxLmNlbmQoKSwgMTApOwoJCWlmIChpdDEgIT0gdjEuY2VuZCgpKSB7CgkJCXJldHVybiBzdGQ6Om1ha2VfcGFpcihzdGQ6OnJlZih2MSksIGl0MSk7CgkJfQoJCWF1dG8gaXQyID0gc3RkOjpmaW5kKHYyLmNiZWdpbigpLCB2Mi5jZW5kKCksIDEwKTsKCQlyZXR1cm4gc3RkOjptYWtlX3BhaXIoc3RkOjpjcmVmKHYyKSwgaXQyKTsKCX07CgoJaW50IG1haW4oKSB7CgkJc3RkOjp2ZWN0b3I8aW50PiB2MXsgMSwgMiwgMyB9OwoJCXN0ZDo6dmVjdG9yPGludD4gdjJ7IDMsIDQsIDEwIH07CgkJYXV0byByID0gZmluZF90ZW4odjEsIHYyKTsKCQlzdGQ6OmNvdXQgPDwgInIuZmlyc3RbMF0gPSAiIDw8IHIuZmlyc3QuZ2V0KClbMF0gPDwgIlxuIjsKCX0=