I don't really understand what you're trying to do, but assuming the Sound
class is copyable, this will compile:
currentfootsteps.clear();
for(auto const& up : footstep_a) {
currentfootsteps.push_back(*up);
}
Note that you're making a copy of each element in footstep_a
and adding it to currentfootsteps
.
If Sound
is move-only, or you want to avoid copies, use this instead:
currentfootsteps.clear();
for(auto&& up : footstep_a) {
currentfootsteps.push_back(std::move(*up));
}
But it also seems you should be able to avoid all this by making currentfootsteps
a pointer, and simply pointing to one of the vector
s depending on whatever condition is satisfied.
vector< unique_ptr <Sound> > *currentfootsteps = nullptr;
if ( walkingarea == a ) {
currentfootsteps = &footstep_a;
} else if ...