fork download
  1. #include <memory>
  2. void abc(int *ptr) {
  3. delete ptr;
  4. }
  5. int main() {
  6. std::unique_ptr<int, decltype(abc)> p = std::unique_ptr<int, decltype(abc)>(new int());
  7. return 0;
  8. }
  9.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/8/bits/unique_ptr.h:37,
                 from /usr/include/c++/8/memory:80,
                 from prog.cpp:1:
/usr/include/c++/8/tuple: In instantiation of ‘struct std::_Head_base<1, void(int*), false>’:
/usr/include/c++/8/tuple:343:12:   required from ‘struct std::_Tuple_impl<1, void(int*)>’
/usr/include/c++/8/tuple:185:12:   required from ‘struct std::_Tuple_impl<0, int*, void(int*)>’
/usr/include/c++/8/tuple:907:11:   required from ‘class std::tuple<int*, void(int*)>’
/usr/include/c++/8/bits/unique_ptr.h:155:27:   required from ‘class std::__uniq_ptr_impl<int, void(int*)>’
/usr/include/c++/8/bits/unique_ptr.h:166:33:   required from ‘class std::unique_ptr<int, void(int*)>’
prog.cpp:6:38:   required from here
/usr/include/c++/8/tuple:165:13: error: field ‘std::_Head_base<1, void(int*), false>::_M_head_impl’ invalidly declared function type
       _Head _M_head_impl;
             ^~~~~~~~~~~~
prog.cpp: In function ‘int main()’:
prog.cpp:6:87: error: no matching function for call to ‘std::unique_ptr<int, void(int*)>::unique_ptr(int*)’
  std::unique_ptr<int, decltype(abc)> p = std::unique_ptr<int, decltype(abc)>(new int());
                                                                                       ^
In file included from /usr/include/c++/8/memory:80,
                 from prog.cpp:1:
/usr/include/c++/8/bits/unique_ptr.h:265:2: note: candidate: ‘template<class _Up, class> std::unique_ptr<_Tp, _Dp>::unique_ptr(std::auto_ptr<_Up>&&)’
  unique_ptr(auto_ptr<_Up>&& __u) noexcept;
  ^~~~~~~~~~
/usr/include/c++/8/bits/unique_ptr.h:265:2: note:   template argument deduction/substitution failed:
prog.cpp:6:87: note:   mismatched types ‘std::auto_ptr<_Up>’ and ‘int*’
  std::unique_ptr<int, decltype(abc)> p = std::unique_ptr<int, decltype(abc)>(new int());
                                                                                       ^
In file included from /usr/include/c++/8/memory:80,
                 from prog.cpp:1:
/usr/include/c++/8/bits/unique_ptr.h:255:2: note: candidate: ‘template<class _Up, class _Ep, class> std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Up, _Ep>&&)’
  unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
  ^~~~~~~~~~
/usr/include/c++/8/bits/unique_ptr.h:255:2: note:   template argument deduction/substitution failed:
prog.cpp:6:87: note:   mismatched types ‘std::unique_ptr<_Tp, _Dp>’ and ‘int*’
  std::unique_ptr<int, decltype(abc)> p = std::unique_ptr<int, decltype(abc)>(new int());
                                                                                       ^
In file included from /usr/include/c++/8/memory:80,
                 from prog.cpp:1:
/usr/include/c++/8/bits/unique_ptr.h:241:7: note: candidate: ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = int; _Dp = void(int*)]’
       unique_ptr(unique_ptr&& __u) noexcept
       ^~~~~~~~~~
/usr/include/c++/8/bits/unique_ptr.h:241:7: note:   no known conversion for argument 1 from ‘int*’ to ‘std::unique_ptr<int, void(int*)>&&’
/usr/include/c++/8/bits/unique_ptr.h:236:12: note: candidate: ‘template<class _Up, class> constexpr std::unique_ptr<_Tp, _Dp>::unique_ptr(std::nullptr_t)’
  constexpr unique_ptr(nullptr_t) noexcept : _M_t() { }
            ^~~~~~~~~~
/usr/include/c++/8/bits/unique_ptr.h:236:12: note:   template argument deduction/substitution failed:
prog.cpp:6:87: note:   cannot convert ‘(operator new(4), (<statement>, ((int*)<anonymous>)))’ (type ‘int*’) to type ‘std::nullptr_t’
  std::unique_ptr<int, decltype(abc)> p = std::unique_ptr<int, decltype(abc)>(new int());
                                                                                       ^
In file included from /usr/include/c++/8/memory:80,
                 from prog.cpp:1:
/usr/include/c++/8/bits/unique_ptr.h:227:7: note: candidate: ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer, typename std::remove_reference<_Dp>::type&&) [with _Tp = int; _Dp = void(int*); std::unique_ptr<_Tp, _Dp>::pointer = int*; typename std::remove_reference<_Dp>::type = void(int*)]’
       unique_ptr(pointer __p,
       ^~~~~~~~~~
/usr/include/c++/8/bits/unique_ptr.h:227:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/8/bits/unique_ptr.h:215:7: note: candidate: ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer, typename std::conditional<std::is_reference<_Dp>::value, _Dp, const _Dp&>::type) [with _Tp = int; _Dp = void(int*); std::unique_ptr<_Tp, _Dp>::pointer = int*; typename std::conditional<std::is_reference<_Dp>::value, _Dp, const _Dp&>::type = void (&)(int*)]’
       unique_ptr(pointer __p,
       ^~~~~~~~~~
/usr/include/c++/8/bits/unique_ptr.h:215:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/8/bits/unique_ptr.h:204:2: note: candidate: ‘template<class _Up, class> std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer)’
  unique_ptr(pointer __p) noexcept
  ^~~~~~~~~~
/usr/include/c++/8/bits/unique_ptr.h:204:2: note:   template argument deduction/substitution failed:
/usr/include/c++/8/bits/unique_ptr.h:191:12: note: candidate: ‘template<class _Up, class> constexpr std::unique_ptr<_Tp, _Dp>::unique_ptr()’
  constexpr unique_ptr() noexcept
            ^~~~~~~~~~
/usr/include/c++/8/bits/unique_ptr.h:191:12: note:   template argument deduction/substitution failed:
prog.cpp:6:87: note:   candidate expects 0 arguments, 1 provided
  std::unique_ptr<int, decltype(abc)> p = std::unique_ptr<int, decltype(abc)>(new int());
                                                                                       ^
In file included from /usr/include/c++/8/bits/unique_ptr.h:37,
                 from /usr/include/c++/8/memory:80,
                 from prog.cpp:1:
/usr/include/c++/8/tuple: In instantiation of ‘static constexpr _Head& std::_Head_base<_Idx, _Head, false>::_M_head(std::_Head_base<_Idx, _Head, false>&) [with long unsigned int _Idx = 1; _Head = void(int*)]’:
/usr/include/c++/8/tuple:351:65:   required from ‘static constexpr _Head& std::_Tuple_impl<_Idx, _Head>::_M_head(std::_Tuple_impl<_Idx, _Head>&) [with long unsigned int _Idx = 1; _Head = void(int*)]’
/usr/include/c++/8/tuple:1304:56:   required from ‘constexpr _Head& std::__get_helper(std::_Tuple_impl<_Idx, _Head, _Tail ...>&) [with long unsigned int __i = 1; _Head = void(int*); _Tail = {}]’
/usr/include/c++/8/tuple:1315:36:   required from ‘constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(std::tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {int*, void(int*)}; std::__tuple_element_t<__i, std::tuple<_Elements ...> > = void(int*)]’
/usr/include/c++/8/bits/unique_ptr.h:151:51:   required from ‘_Dp& std::__uniq_ptr_impl<_Tp, _Dp>::_M_deleter() [with _Tp = int; _Dp = void(int*)]’
/usr/include/c++/8/bits/unique_ptr.h:348:32:   required from ‘std::unique_ptr<_Tp, _Dp>::deleter_type& std::unique_ptr<_Tp, _Dp>::get_deleter() [with _Tp = int; _Dp = void(int*); std::unique_ptr<_Tp, _Dp>::deleter_type = void(int*)]’
/usr/include/c++/8/bits/unique_ptr.h:274:17:   required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = int; _Dp = void(int*)]’
prog.cpp:6:87:   required from here
/usr/include/c++/8/tuple:160:54: error: invalid initialization of reference of type ‘void (&)(int*)’ from expression of type ‘void (*)(int*)’
       _M_head(_Head_base& __b) noexcept { return __b._M_head_impl; }
                                                  ~~~~^~~~~~~~~~~~
stdout
Standard output is empty