#include <iostream>
#include <deque>
#include <vector>
#include <memory>
using namespace std;
int main() {
using UPtr = std::unique_ptr<int>;
std::deque<UPtr> d;
std::vector<UPtr> v;
for (int i = 0; i < 5; ++i) {
v.emplace_back(new int(i));
}
for (const auto& item : v) {
d.emplace_front(std::move(item));
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZGVxdWU+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxtZW1vcnk+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7Cgl1c2luZyBVUHRyID0gc3RkOjp1bmlxdWVfcHRyPGludD47CgoJc3RkOjpkZXF1ZTxVUHRyPiBkOwoJc3RkOjp2ZWN0b3I8VVB0cj4gdjsKCglmb3IgKGludCBpID0gMDsgaSA8IDU7ICsraSkgewoJCXYuZW1wbGFjZV9iYWNrKG5ldyBpbnQoaSkpOwoJfQoJCglmb3IgKGNvbnN0IGF1dG8mIGl0ZW0gOiB2KSB7CgkJZC5lbXBsYWNlX2Zyb250KHN0ZDo6bW92ZShpdGVtKSk7Cgl9CgoJcmV0dXJuIDA7Cn0=
In file included from /usr/include/i386-linux-gnu/c++/5/bits/c++allocator.h:33:0,
from /usr/include/c++/5/bits/allocator.h:46,
from /usr/include/c++/5/string:41,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::unique_ptr<int>; _Args = {const std::unique_ptr<int, std::default_delete<int> >}; _Tp = std::unique_ptr<int>]':
/usr/include/c++/5/bits/alloc_traits.h:256:4: required from 'static std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::unique_ptr<int>; _Args = {const std::unique_ptr<int, std::default_delete<int> >}; _Alloc = std::allocator<std::unique_ptr<int> >; std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> = void]'
/usr/include/c++/5/bits/alloc_traits.h:402:16: required from 'static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::unique_ptr<int>; _Args = {const std::unique_ptr<int, std::default_delete<int> >}; _Alloc = std::allocator<std::unique_ptr<int> >; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]'
/usr/include/c++/5/bits/deque.tcc:137:30: required from 'void std::deque<_Tp, _Alloc>::emplace_front(_Args&& ...) [with _Args = {const std::unique_ptr<int, std::default_delete<int> >}; _Tp = std::unique_ptr<int>; _Alloc = std::allocator<std::unique_ptr<int> >]'
prog.cpp:19:34: required from here
/usr/include/c++/5/ext/new_allocator.h:120:4: error: use of deleted function 'std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = int; _Dp = std::default_delete<int>]'
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
^
In file included from /usr/include/c++/5/memory:81:0,
from prog.cpp:4:
/usr/include/c++/5/bits/unique_ptr.h:356:7: note: declared here
unique_ptr(const unique_ptr&) = delete;
^