I’m trying to translate the usage of find function in Matlab to C++. From what I can see from the C++ find function, I can’t seem to find in the description anywhere of an easy method of finding the index in the list in which certain conditions is true rather than just comparing for equality between the item that is being searched for and the list of items. Before I implement my own method of performing the find function, it would be great to see if there is any easy, efficient, standard implemented way of doing so already. Thanks in advance.
Share
If you’re looking for mathing a condition, you want ‘find_if’. Using find if will allow you to pass in a predicate which determines whether a given item in the list matches. You will still have to write the matching logic (or find a relevant existing function in the standard algorithms, but its less than having to write the whole framework of ‘find’.