Extracting move only type from std::set

Viewed 2833

I have a std::set<std::unique_ptr<T>> and I'd like to move it to a std::vector<std::unique_ptr<T>>

#include <set>
#include <vector>
#include <memory>

class C {};

int main()
{
  std::set<std::unique_ptr<const C>> s;
  std::vector<std::unique_ptr<const C>> v;
  std::move(s.begin(), s.end(), std::back_inserter(v));
}

This gives the following error on VS2017:

error C2280: 'std::unique_ptr>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)': attempting to reference a deleted function

Can't we make move iterators to non-const variables from a std::set? What could be a viable solution to this problem?

1 Answers
Related