I'm trying to std::move an element out of a std::set and then erase it from the set:
std::set<some_type> the_set;
some_type item;
for (auto iter = the_set.begin(); iter != the_set.end(); iter++)
{
auto miter = std::make_move_iterator(iter);
item = std::move(*miter);
the_set.erase(iter);
break;
}
The compiler doesn't like it, though (MSVC 2015):
error C2280: 'some_type &some_type::operator =(const some_type &)': attempting to reference a deleted function
Seems like it's trying to use a copy constructor instead, which I don't want. How would I get it to use the move constructor? (I tried the move_iterator out of desperation, not sure if it's the right solution here).
Aucun commentaire:
Enregistrer un commentaire