fork download
  1. #include <memory>
  2. #include <utility>
  3.  
  4. typedef std::unique_ptr<int> i_ptr;
  5. typedef std::pair<i_ptr, i_ptr> i_pair;
  6.  
  7. i_ptr foo() { i_ptr p; return p; }
  8.  
  9. i_pair bar() { i_pair p; return p; }
  10.  
  11. i_pair bad() { i_ptr p, q; return std::make_pair(p, q); }
  12.  
  13. i_pair better() { i_ptr p, q; return std::make_pair(std::move(p), std::move(q)); }
  14.  
  15. int main() {
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/move.h:38:0,
                 from /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/stl_pair.h:60,
                 from /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/stl_algobase.h:66,
                 from /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/memory:63,
                 from prog.cpp:1:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/type_traits: In instantiation of 'const bool std::__is_convertible_helper<std::unique_ptr<int>&, std::unique_ptr<int>, false>::__value':
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/type_traits:312:5:   instantiated from 'std::is_convertible<std::unique_ptr<int>&, std::unique_ptr<int> >'
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/stl_pair.h:253:49:   instantiated from 'std::pair<typename std::__decay_and_strip<_Tp>::__type, typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = std::unique_ptr<int>&, _T2 = std::unique_ptr<int>&, typename std::__decay_and_strip<_T2>::__type = std::unique_ptr<int>, typename std::__decay_and_strip<_Tp>::__type = std::unique_ptr<int>]'
prog.cpp:11:54:   instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/unique_ptr.h:207:7: error: deleted function 'std::unique_ptr<_Tp, _Tp_Deleter>::unique_ptr(const std::unique_ptr<_Tp, _Tp_Deleter>&) [with _Tp = int, _Tp_Deleter = std::default_delete<int>, std::unique_ptr<_Tp, _Tp_Deleter> = std::unique_ptr<int>]'
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/type_traits:302:71: error: used here
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/type_traits:302:71: error:   initializing argument 1 of 'static std::__sfinae_types::__one std::__is_convertible_helper<_From, _To, false>::__test(_To) [with _From = std::unique_ptr<int>&, _To = std::unique_ptr<int>, std::__sfinae_types::__one = char]'
In file included from /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/stl_algobase.h:66:0,
                 from /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/memory:63,
                 from prog.cpp:1:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/unique_ptr.h: In constructor 'std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 = std::unique_ptr<int>&, _U2 = std::unique_ptr<int>&, <template-parameter-2-3> = void, _T1 = std::unique_ptr<int>, _T2 = std::unique_ptr<int>]':
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/stl_pair.h:253:49:   instantiated from 'std::pair<typename std::__decay_and_strip<_Tp>::__type, typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = std::unique_ptr<int>&, _T2 = std::unique_ptr<int>&, typename std::__decay_and_strip<_T2>::__type = std::unique_ptr<int>, typename std::__decay_and_strip<_Tp>::__type = std::unique_ptr<int>]'
prog.cpp:11:54:   instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/unique_ptr.h:207:7: error: deleted function 'std::unique_ptr<_Tp, _Tp_Deleter>::unique_ptr(const std::unique_ptr<_Tp, _Tp_Deleter>&) [with _Tp = int, _Tp_Deleter = std::default_delete<int>, std::unique_ptr<_Tp, _Tp_Deleter> = std::unique_ptr<int>]'
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/stl_pair.h:109:33: error: used here
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/unique_ptr.h:207:7: error: deleted function 'std::unique_ptr<_Tp, _Tp_Deleter>::unique_ptr(const std::unique_ptr<_Tp, _Tp_Deleter>&) [with _Tp = int, _Tp_Deleter = std::default_delete<int>, std::unique_ptr<_Tp, _Tp_Deleter> = std::unique_ptr<int>]'
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/stl_pair.h:109:33: error: used here
stdout
Standard output is empty