fork(7) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <memory>
  5. #include <map>
  6.  
  7. using namespace std;
  8.  
  9. struct ptrwrap
  10. {
  11. unique_ptr<int> foo;
  12. };
  13.  
  14. template <typename T>
  15. struct holder
  16. {
  17. holder() = default;
  18.  
  19. holder(const holder& b)
  20. : t(b.t)
  21. {
  22. }
  23.  
  24. holder(holder&& b)
  25. : t(std::move(b.t))
  26. {
  27. }
  28.  
  29. holder& operator=(const holder& h)
  30. {
  31. t = h.t;
  32. return *this;
  33. }
  34.  
  35. holder& operator=(holder&& h)
  36. {
  37. t = std::move(h.t);
  38. return *this;
  39. }
  40.  
  41. T t;
  42. };
  43.  
  44. struct y_u_no_elision
  45. {
  46. holder<ptrwrap> elem;
  47. };
  48.  
  49. typedef map<std::string, y_u_no_elision> mymap;
  50.  
  51. mymap foo();
  52.  
  53. int main()
  54. {
  55. auto m = foo();
  56. m = foo();
  57. return 0;
  58. }
  59.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'holder<T>::holder(const holder<T>&) [with T = ptrwrap]':
prog.cpp:44:8:   required from 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::pair<const std::basic_string<char>, y_u_no_elision>; _Args = {const std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, y_u_no_elision>&}; _Tp = std::_Rb_tree_node<std::pair<const std::basic_string<char>, y_u_no_elision> >]'
/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::pair<const std::basic_string<char>, y_u_no_elision>; _Args = {const std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, y_u_no_elision>&}; _Alloc = std::allocator<std::_Rb_tree_node<std::pair<const std::basic_string<char>, y_u_no_elision> > >; 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::pair<const std::basic_string<char>, y_u_no_elision>; _Args = {const std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, y_u_no_elision>&}; _Alloc = std::allocator<std::_Rb_tree_node<std::pair<const std::basic_string<char>, y_u_no_elision> > >; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]'
/usr/include/c++/5/bits/stl_tree.h:529:32:   required from 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type, _Args&& ...) [with _Args = {const std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, y_u_no_elision>&}; _Key = std::basic_string<char>; _Val = std::pair<const std::basic_string<char>, y_u_no_elision>; _KeyOfValue = std::_Select1st<std::pair<const std::basic_string<char>, y_u_no_elision> >; _Compare = std::less<std::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::basic_string<char>, y_u_no_elision> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const std::basic_string<char>, y_u_no_elision> >*]'
/usr/include/c++/5/bits/stl_tree.h:398:3:   required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Reuse_or_alloc_node::operator()(_Arg&&) [with _Arg = const std::pair<const std::basic_string<char>, y_u_no_elision>&; _Key = std::basic_string<char>; _Val = std::pair<const std::basic_string<char>, y_u_no_elision>; _KeyOfValue = std::_Select1st<std::pair<const std::basic_string<char>, y_u_no_elision> >; _Compare = std::less<std::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::basic_string<char>, y_u_no_elision> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const std::basic_string<char>, y_u_no_elision> >*]'
/usr/include/c++/5/bits/stl_tree.h:1410:21:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::operator=(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&&)::<lambda(const value_type&)> [with _Key = std::basic_string<char>; _Val = std::pair<const std::basic_string<char>, y_u_no_elision>; _KeyOfValue = std::_Select1st<std::pair<const std::basic_string<char>, y_u_no_elision> >; _Compare = std::less<std::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::basic_string<char>, y_u_no_elision> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::value_type = std::pair<const std::basic_string<char>, y_u_no_elision>]'
/usr/include/c++/5/bits/stl_tree.h:1407:8:   required from 'struct std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::operator=(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&&) [with _Key = std::basic_string<char>; _Val = std::pair<const std::basic_string<char>, y_u_no_elision>; _KeyOfValue = std::_Select1st<std::pair<const std::basic_string<char>, y_u_no_elision> >; _Compare = std::less<std::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::basic_string<char>, y_u_no_elision> >]::<lambda(const value_type&)>'
/usr/include/c++/5/bits/stl_tree.h:1411:6:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::operator=(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&&) [with _Key = std::basic_string<char>; _Val = std::pair<const std::basic_string<char>, y_u_no_elision>; _KeyOfValue = std::_Select1st<std::pair<const std::basic_string<char>, y_u_no_elision> >; _Compare = std::less<std::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::basic_string<char>, y_u_no_elision> >]'
/usr/include/c++/5/bits/stl_map.h:96:11:   required from here
prog.cpp:20:16: error: use of deleted function 'ptrwrap::ptrwrap(const ptrwrap&)'
         : t(b.t)
                ^
prog.cpp:9:8: note: 'ptrwrap::ptrwrap(const ptrwrap&)' is implicitly deleted because the default definition would be ill-formed:
 struct ptrwrap
        ^
prog.cpp:9:8: 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>]'
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