fork download
  1. #include <initializer_list>
  2. #include <list>
  3. #include <memory>
  4.  
  5. using Ints_t = std::list<std::unique_ptr<int>>;
  6.  
  7. Ints_t::value_type Build()
  8. {
  9. return Ints_t::value_type(new int);
  10. }
  11.  
  12. int main()
  13. {
  14. Ints_t a;
  15. a = Ints_t{Build(), Build(), Build(), Build(), Build()};
  16. }
  17.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/4.7/list:64:0,
                 from prog.cpp:2:
/usr/include/c++/4.7/bits/stl_list.h: In instantiation of ‘std::_List_node<_Tp>::_List_node(_Args&& ...) [with _Args = {const std::unique_ptr<int, std::default_delete<int> >&}; _Tp = std::unique_ptr<int>]’:
/usr/include/c++/4.7/ext/new_allocator.h:110:4:   required from ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::_List_node<std::unique_ptr<int> >; _Args = {const std::unique_ptr<int, std::default_delete<int> >&}; _Tp = std::_List_node<std::unique_ptr<int> >]’
/usr/include/c++/4.7/bits/stl_list.h:503:8:   required from ‘std::list<_Tp, _Alloc>::_Node* std::list<_Tp, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {const std::unique_ptr<int, std::default_delete<int> >&}; _Tp = std::unique_ptr<int>; _Alloc = std::allocator<std::unique_ptr<int> >; std::list<_Tp, _Alloc>::_Node = std::_List_node<std::unique_ptr<int> >]’
/usr/include/c++/4.7/bits/stl_list.h:1533:63:   required from ‘void std::list<_Tp, _Alloc>::_M_insert(std::list<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {const std::unique_ptr<int, std::default_delete<int> >&}; _Tp = std::unique_ptr<int>; _Alloc = std::allocator<std::unique_ptr<int> >; std::list<_Tp, _Alloc>::iterator = std::_List_iterator<std::unique_ptr<int> >]’
/usr/include/c++/4.7/bits/stl_list.h:997:9:   required from ‘void std::list<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::unique_ptr<int>; _Alloc = std::allocator<std::unique_ptr<int> >; std::list<_Tp, _Alloc>::value_type = std::unique_ptr<int>]’
/usr/include/c++/4.7/bits/stl_list.h:1466:6:   required from ‘void std::list<_Tp, _Alloc>::_M_initialize_dispatch(_InputIterator, _InputIterator, std::__false_type) [with _InputIterator = const std::unique_ptr<int>*; _Tp = std::unique_ptr<int>; _Alloc = std::allocator<std::unique_ptr<int> >]’
/usr/include/c++/4.7/bits/stl_list.h:606:9:   required from ‘std::list<_Tp, _Alloc>::list(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::unique_ptr<int>; _Alloc = std::allocator<std::unique_ptr<int> >; std::list<_Tp, _Alloc>::allocator_type = std::allocator<std::unique_ptr<int> >]’
prog.cpp:15:59:   required from here
/usr/include/c++/4.7/bits/stl_list.h:115:71: 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>; std::unique_ptr<_Tp, _Dp> = std::unique_ptr<int>]’
In file included from /usr/include/c++/4.7/memory:86:0,
                 from prog.cpp:3:
/usr/include/c++/4.7/bits/unique_ptr.h:262:7: error: declared here
stdout
Standard output is empty