fork(1) download
  1. #include <iostream>
  2. #include <deque>
  3. #include <vector>
  4. #include <memory>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. using UPtr = std::unique_ptr<int>;
  10.  
  11. std::deque<UPtr> d;
  12. std::vector<UPtr> v;
  13.  
  14. for (int i = 0; i < 5; ++i) {
  15. v.emplace_back(new int(i));
  16. }
  17.  
  18. for (const auto& item : v) {
  19. d.emplace_front(std::move(item));
  20. }
  21.  
  22. return 0;
  23. }
Compilation error #stdin compilation error #stdout 0s 3412KB
stdin
Standard input is empty
compilation info
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;
       ^
stdout
Standard output is empty