I tried to overload the std::find function, in this way:
include <list>
include <string>
include "Marker.h"
namespace Test {
class MarkerContainer {
private:
std::list<Marker*> list;
double end_t;
inline bool exists(std::list<Marker*> *input_list, Marker* check);
public:
MarkerContainer();
MarkerContainer(double end_time);
bool addMarker(Marker* input);
double computeBeatTime(double sample_t);
double computeSampleTime(double beat_t);
void printAll();
};
}
std::list<Ableton::Marker*>::iterator std::find(std::list<Ableton::Marker*>::iterator first, std::list<Ableton::Marker*>::iterator last, Ableton::Marker* value){
for ( ;first!=last; first++) if ( **first==*value ) break;
return first;
}
But I catch this compiler error:
Out-of-line definition of ‘find’ does not match any declaration in
namespace ‘std’ in /Users/…/MarkerContainer.h
I hope I did some stupid mistake and what I would like to do is simple.. any idea ?
Thanks in advance!
Pietro
You aren’t allowed to overload
find. You are allowed to specialize templates in thestdnamespace, but in this case it’s far simpler to usefind_ifwith a dereferencing functor.