#include <memory>
int main()
{
std::unique_ptr<int[]> arr(new int[1]);
std::shared_ptr<int> ptr(std::move(arr));
}
I2luY2x1ZGUgPG1lbW9yeT4KCmludCBtYWluKCkKewogICAgc3RkOjp1bmlxdWVfcHRyPGludFtdPiBhcnIobmV3IGludFsxXSk7CiAgICBzdGQ6OnNoYXJlZF9wdHI8aW50PiBwdHIoc3RkOjptb3ZlKGFycikpOwp9
prog.cpp: In function ‘int main()’:
prog.cpp:6:44: error: no matching function for call to ‘std::shared_ptr<int>::shared_ptr(std::remove_reference<std::unique_ptr<int []>&>::type)’
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:367:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Tp>&, std::nothrow_t) [with _Tp = int]’
shared_ptr(const weak_ptr<_Tp>& __r, std::nothrow_t)
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:367:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/8/bits/shared_ptr.h:358:2: note: candidate: ‘template<class _Alloc, class ... _Args> std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...)’
shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args)
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:358:2: note: template argument deduction/substitution failed:
prog.cpp:6:44: note: ‘std::unique_ptr<int []>’ is not derived from ‘std::_Sp_alloc_shared_tag<_Tp>’
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:307:17: note: candidate: ‘constexpr std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t) [with _Tp = int; std::nullptr_t = std::nullptr_t]’
constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { }
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:307:17: note: no known conversion for argument 1 from ‘std::remove_reference<std::unique_ptr<int []>&>::type’ {aka ‘std::unique_ptr<int []>’} to ‘std::nullptr_t’
/usr/include/c++/8/bits/shared_ptr.h:299:2: note: candidate: ‘template<class _Yp, class _Del, std::shared_ptr<int>::_Constructible<std::unique_ptr<_Tp, _Dp>, std::__sp_array_delete>* <anonymous> > std::shared_ptr<_Tp>::shared_ptr(std::unique_ptr<_Up, _Ep>&&)’
shared_ptr(unique_ptr<_Yp, _Del>&& __r)
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:299:2: note: template argument deduction/substitution failed:
/usr/include/c++/8/bits/shared_ptr.h:290:2: note: candidate: ‘template<class _Yp, class _Del, class> std::shared_ptr<_Tp>::shared_ptr(std::unique_ptr<_Up, _Ep>&&)’
shared_ptr(unique_ptr<_Yp, _Del>&& __r)
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:290:2: note: template argument deduction/substitution failed:
/usr/include/c++/8/bits/shared_ptr.h:282:2: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Up>&&)’
shared_ptr(auto_ptr<_Yp>&& __r);
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:282:2: note: template argument deduction/substitution failed:
prog.cpp:6:44: note: ‘std::remove_reference<std::unique_ptr<int []>&>::type’ {aka ‘std::unique_ptr<int []>’} is not derived from ‘std::auto_ptr<_Up>’
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:275:11: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Yp>&)’
explicit shared_ptr(const weak_ptr<_Yp>& __r)
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:275:11: note: template argument deduction/substitution failed:
prog.cpp:6:44: note: ‘std::remove_reference<std::unique_ptr<int []>&>::type’ {aka ‘std::unique_ptr<int []>’} is not derived from ‘const std::weak_ptr<_Tp>’
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:263:2: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::shared_ptr<_Yp>&&)’
shared_ptr(shared_ptr<_Yp>&& __r) noexcept
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:263:2: note: template argument deduction/substitution failed:
prog.cpp:6:44: note: ‘std::remove_reference<std::unique_ptr<int []>&>::type’ {aka ‘std::unique_ptr<int []>’} is not derived from ‘std::shared_ptr<_Tp>’
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:254:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(std::shared_ptr<_Tp>&&) [with _Tp = int]’
shared_ptr(shared_ptr&& __r) noexcept
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:254:7: note: no known conversion for argument 1 from ‘std::remove_reference<std::unique_ptr<int []>&>::type’ {aka ‘std::unique_ptr<int []>’} to ‘std::shared_ptr<int>&&’
/usr/include/c++/8/bits/shared_ptr.h:246:2: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Yp>&)’
shared_ptr(const shared_ptr<_Yp>& __r) noexcept
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:246:2: note: template argument deduction/substitution failed:
prog.cpp:6:44: note: ‘std::remove_reference<std::unique_ptr<int []>&>::type’ {aka ‘std::unique_ptr<int []>’} is not derived from ‘const std::shared_ptr<_Tp>’
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:234:2: note: candidate: ‘template<class _Yp> std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Yp>&, std::shared_ptr<_Tp>::element_type*)’
shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) noexcept
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:234:2: note: template argument deduction/substitution failed:
prog.cpp:6:44: note: ‘std::remove_reference<std::unique_ptr<int []>&>::type’ {aka ‘std::unique_ptr<int []>’} is not derived from ‘const std::shared_ptr<_Tp>’
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:212:2: note: candidate: ‘template<class _Deleter, class _Alloc> std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t, _Deleter, _Alloc)’
shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:212:2: note: template argument deduction/substitution failed:
prog.cpp:6:44: note: candidate expects 3 arguments, 1 provided
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:193:2: note: candidate: ‘template<class _Yp, class _Deleter, class _Alloc, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter, _Alloc)’
shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a)
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:193:2: note: template argument deduction/substitution failed:
prog.cpp:6:44: note: mismatched types ‘_Yp*’ and ‘std::unique_ptr<int []>’
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:173:2: note: candidate: ‘template<class _Deleter> std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t, _Deleter)’
shared_ptr(nullptr_t __p, _Deleter __d)
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:173:2: note: template argument deduction/substitution failed:
prog.cpp:6:44: note: candidate expects 2 arguments, 1 provided
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:156:2: note: candidate: ‘template<class _Yp, class _Deleter, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter)’
shared_ptr(_Yp* __p, _Deleter __d)
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:156:2: note: template argument deduction/substitution failed:
prog.cpp:6:44: note: mismatched types ‘_Yp*’ and ‘std::unique_ptr<int []>’
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:139:2: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*)’
shared_ptr(_Yp* __p) : __shared_ptr<_Tp>(__p) { }
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:139:2: note: template argument deduction/substitution failed:
prog.cpp:6:44: note: mismatched types ‘_Yp*’ and ‘std::unique_ptr<int []>’
std::shared_ptr<int> ptr(std::move(arr));
^
In file included from /usr/include/c++/8/memory:81,
from prog.cpp:1:
/usr/include/c++/8/bits/shared_ptr.h:129:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Tp>&) [with _Tp = int]’
shared_ptr(const shared_ptr&) noexcept = default;
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:129:7: note: no known conversion for argument 1 from ‘std::remove_reference<std::unique_ptr<int []>&>::type’ {aka ‘std::unique_ptr<int []>’} to ‘const std::shared_ptr<int>&’
/usr/include/c++/8/bits/shared_ptr.h:127:17: note: candidate: ‘constexpr std::shared_ptr<_Tp>::shared_ptr() [with _Tp = int]’
constexpr shared_ptr() noexcept : __shared_ptr<_Tp>() { }
^~~~~~~~~~
/usr/include/c++/8/bits/shared_ptr.h:127:17: note: candidate expects 0 arguments, 1 provided