I have a class C
which does not define operator=
. I have am trying to use a vector like so: std::vector<std::pair<C,D>> vec;
. Now, my problem is that I am not able to erase the pair after I am done with it. The compiler complains of missing operator=
for C
. Can I not have a vector of a class which does not have this operator? How do I get around this? I cannot add assignment to C
. This is the error I get:
error C2582: 'operator =' function is unavailable in 'C' C:...includeutility 196 1 my-lib
This is my code:
void Remove(const C& c)
{
auto i = cs_.begin();
while( i != cs_.end()) {
if (i->first == c) {
cs_.erase(i); // this is the problem
break;
}
i++;
}
}
where cs_
is:
std::vector<std::pair<C,D>> cs_;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…