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.
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'.
Then again, the "whole framework of find" is not so difficult, even if you don't have tail recursion.
This might be an example of something worth writing yourself because, even if at this moment you're not quite as fast at whipping out the correct function as you would be picking it from the standard library, after writing it a few more times you will be. Not to mention then you'll really know what goes on underneath the hood, as we say in Chevy-land....