for (auto componentsIterator : *m_components)
That auto
expands to std::unique_ptr<Component>
, which means that you are trying to take a copy of each element. IOW, that loop actually is:
for(auto it=m_components->begin(); it!=m_components->end(); ++it)
{
std::unique_ptr<Component> componentsIterator=*it;
componentsIterator->DoSomething();
componentsIterator++;
}
As you can see, you are invoking std::unique_ptr<Component>
copy constructor, but the copy constructor of unique_ptr
is deleted (because it is against the unique_ptr
semantic).
Use auto &
to take a reference instead.
(BTW, componentsIterator
there is not a sensible name, since it's not an iterator, it's the actual element)