I have a vector of unique_ptr's and I want to append them to another vector of unique_ptrs. I would normally do a simple insert:
std::vector<std::unique_ptr<foo>> bar;
bar.push_back(std::unique_ptr<foo>(new foo(1)));
std::vector<std::unique_ptr<foo>> baz;
baz.push_back(std::unique_ptr<foo>(new foo(2)));
bar.insert(bar.end(), baz.begin(), baz.end());
However this gives me compile errors similar to this:
/usr/include/c++/4.8/bits/stl_algobase.h:335: error: use of deleted function 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = foo; _Dp = std::default_delete<foo>]'
*__result = *__first;
^
Is there a convenient way to insert or do I have to iterate over baz and push_back on bar? I'm currently using gcc 4.8.1.
Thanks