#include <iostream>
#include <memory>
using namespace std;
class asd
{
public:
asd(int a) : c(a) {}
int c;
};
int main() {
// your code goes here
std::unique_ptr<asd*> a(new asd(2));
std::cout << a->c;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWVtb3J5Pgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgYXNkCnsKcHVibGljOgoJYXNkKGludCBhKSA6IGMoYSkge30KCWludCBjOwp9OwoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCglzdGQ6OnVuaXF1ZV9wdHI8YXNkKj4gYShuZXcgYXNkKDIpKTsKCXN0ZDo6Y291dCA8PCBhLT5jOwp9
prog.cpp: In function ‘int main()’:
prog.cpp:14:36: error: no matching function for call to ‘std::unique_ptr<asd*>::unique_ptr(asd*)’
std::unique_ptr<asd*> a(new asd(2));
^
In file included from /usr/include/c++/6/memory:81:0,
from prog.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:231: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++/6/bits/unique_ptr.h:231:2: note: template argument deduction/substitution failed:
prog.cpp:14:36: note: mismatched types ‘std::auto_ptr<_Up>’ and ‘asd*’
std::unique_ptr<asd*> a(new asd(2));
^
In file included from /usr/include/c++/6/memory:81:0,
from prog.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:223: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++/6/bits/unique_ptr.h:223:2: note: template argument deduction/substitution failed:
prog.cpp:14:36: note: mismatched types ‘std::unique_ptr<_Tp, _Dp>’ and ‘asd*’
std::unique_ptr<asd*> a(new asd(2));
^
In file included from /usr/include/c++/6/memory:81:0,
from prog.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:209:7: note: candidate: std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = asd*; _Dp = std::default_delete<asd*>]
unique_ptr(unique_ptr&& __u) noexcept
^~~~~~~~~~
/usr/include/c++/6/bits/unique_ptr.h:209:7: note: no known conversion for argument 1 from ‘asd*’ to ‘std::unique_ptr<asd*>&&’
/usr/include/c++/6/bits/unique_ptr.h:204:17: note: candidate: constexpr std::unique_ptr<_Tp, _Dp>::unique_ptr(std::nullptr_t) [with _Tp = asd*; _Dp = std::default_delete<asd*>; std::nullptr_t = std::nullptr_t]
constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
^~~~~~~~~~
/usr/include/c++/6/bits/unique_ptr.h:204:17: note: no known conversion for argument 1 from ‘asd*’ to ‘std::nullptr_t’
/usr/include/c++/6/bits/unique_ptr.h:197:7: note: candidate: std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer, typename std::remove_reference<_To>::type&&) [with _Tp = asd*; _Dp = std::default_delete<asd*>; std::unique_ptr<_Tp, _Dp>::pointer = asd**; typename std::remove_reference<_To>::type = std::default_delete<asd*>]
unique_ptr(pointer __p,
^~~~~~~~~~
/usr/include/c++/6/bits/unique_ptr.h:197:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/6/bits/unique_ptr.h:185: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 = asd*; _Dp = std::default_delete<asd*>; std::unique_ptr<_Tp, _Dp>::pointer = asd**; typename std::conditional<std::is_reference<_Dp>::value, _Dp, const _Dp&>::type = const std::default_delete<asd*>&]
unique_ptr(pointer __p,
^~~~~~~~~~
/usr/include/c++/6/bits/unique_ptr.h:185:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/6/bits/unique_ptr.h:170:7: note: candidate: std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer) [with _Tp = asd*; _Dp = std::default_delete<asd*>; std::unique_ptr<_Tp, _Dp>::pointer = asd**]
unique_ptr(pointer __p) noexcept
^~~~~~~~~~
/usr/include/c++/6/bits/unique_ptr.h:170:7: note: no known conversion for argument 1 from ‘asd*’ to ‘std::unique_ptr<asd*>::pointer {aka asd**}’
/usr/include/c++/6/bits/unique_ptr.h:158:17: note: candidate: constexpr std::unique_ptr<_Tp, _Dp>::unique_ptr() [with _Tp = asd*; _Dp = std::default_delete<asd*>]
constexpr unique_ptr() noexcept
^~~~~~~~~~
/usr/include/c++/6/bits/unique_ptr.h:158:17: note: candidate expects 0 arguments, 1 provided
prog.cpp:15:18: error: request for member ‘c’ in ‘* a.std::unique_ptr<_Tp, _Dp>::operator-><asd*, std::default_delete<asd*> >()’, which is of pointer type ‘asd*’ (maybe you meant to use ‘->’ ?)
std::cout << a->c;
^