My question is simple enough, given the following data structure, std::vector<std::pair<int, std::unique_ptr<foo>>>, if I have the following:
auto it = std::find_if(begin(v), end(v), [&](std::pair<...> const& p){ return p.first == some_value; });
Can I expect that whatever is pointed to by the pointer is not fetched (I don’t want it fetched, will later pre-fetch as needed) into the cache purely for the find operation? Or is this impossible to determine (if so I will close the question..)
When “find” searches in a vector, it will look at the value of the entry in the vector, and match that with what you are searching for. So, it will use whatever “equal” function that is provided by the find, or “operator==” if there is no function provided to find.
Since in this case, you are just comparing the int value in the pair with your expected value, the
unique_ptr<foo>will not be dereferenced (and thus data pointed to byunique_ptr<foo>will not enter the cache).