I have created 2 custom structs on my project and each one have a std::set.
struct Subject {
std::string name;
std::set<SubjectFrame> frames;
Subject(std::string subject_name);
void AddFrame(SubjectFrame &frame);
bool operator<(const Subject &rhs) const { return (name < rhs.name);}
bool operator==(const Subject &rhs) const { return (name == rhs.name);}
};
struct Dataset {
std::set<Subject> subjects;
std::map<int, std::vector<Subject> > classification_groups;
Dataset(const std::string ds_path);
void AddSubject(Subject &subject);
void GetDSFromFileSystem(const std::string dataset_path);
void GetClassificationGroups(int number_of_groups_to_create);
};
Every time I wanna add some frame to my set 'frames' I call this function:
void Dataset::AddSubject(Subject &subject) {
set<Subject>::iterator it = this->subjects.find(subject);
if (it != this->subjects.end()) {
for (Subject fr : this->subjects) {
it->AddFrame(fr);
}
} else this->subjects.insert(subject);
}
That calls this function:
void Subject::AddFrame(SubjectFrame &frame) {
set<SubjectFrame>::iterator it = this->frames.find(frame);
if (it != this->frames.end()) {
if (frame.l_eye_centroid.x != 0) {
it->r_eye_centroid = frame.r_eye_centroid;
it->l_eye_centroid = frame.l_eye_centroid;
}
if (frame.path != "") it->path = frame.path;
else return;
}
else this->frames.insert(frame);
}
So, the logic behind an add operation is: I pass an object and check if there's a object with that name already inside my std::set. If yes, I update the existent object with the informations that my parameter object has and the already registered object don't have, if no I insert the object.
I'm getting this errors when I try to compile my program:
error: no viable overloaded '=' it->r_eye_centroid = frame.r_eye_centroid;
error: no viable overloaded '=' it->l_eye_centroid = frame.l_eye_centroid;
error: no viable overloaded '=' if (frame.path != "") it->path = frame.path;
error: member function 'AddFrame' not viable: 'this' argument has type 'const Subject', but function is not marked const it->AddFrame(fr);
Someone has any idea what is causing, and how I can solve, these problems?