Loop through the vector of objects, if that object matches the one in hand return a success message?
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
#include <vector>
#include <algorithm>
struct some_struct { int key ; /* ... */ };
struct has_same_key
{
explicit ( const some_struct& s ) : what(s) {}
bool operator() ( const some_struct& elem ) const
{ return elem.key == what.key ; }
const some_struct& what ;
};
inline std::vector<some_struct>::const_iterator
do_find( const std::vector<some_struct>& vec, const some_struct& what )
{
return std::find_if( vec.begin(), vec.end(), has_same_key(what) ) ;
}
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287