#include <memory>
class Base
{
};
class Derived : public Base
{
};
struct BaseDeleter
{
void operator()(Base* base)
{
// Perform some special deleting
}
};
class Big
{
public:
Big()
{
//pointer.reset(new Derived()); // This works!
pointer = std::make_unique<Derived, BaseDeleter>(); // But this doesn't...
}
private:
std::unique_ptr<Base, BaseDeleter> pointer;
};
int main()
{
Big clazz;
}
I2luY2x1ZGUgPG1lbW9yeT4KCmNsYXNzIEJhc2UKewp9OwoKY2xhc3MgRGVyaXZlZCA6IHB1YmxpYyBCYXNlCnsKfTsKCnN0cnVjdCBCYXNlRGVsZXRlcgp7Cgl2b2lkIG9wZXJhdG9yKCkoQmFzZSogYmFzZSkKCXsKCQkvLyBQZXJmb3JtIHNvbWUgc3BlY2lhbCBkZWxldGluZwoJfQp9OwoKY2xhc3MgQmlnCnsKcHVibGljOgoJQmlnKCkKCXsKCQkvL3BvaW50ZXIucmVzZXQobmV3IERlcml2ZWQoKSk7IC8vIFRoaXMgd29ya3MhCgkJcG9pbnRlciA9IHN0ZDo6bWFrZV91bmlxdWU8RGVyaXZlZCwgQmFzZURlbGV0ZXI+KCk7IC8vIEJ1dCB0aGlzIGRvZXNuJ3QuLi4KCX0KCQpwcml2YXRlOgoJc3RkOjp1bmlxdWVfcHRyPEJhc2UsIEJhc2VEZWxldGVyPiBwb2ludGVyOwp9OwoKaW50IG1haW4oKQp7CglCaWcgY2xheno7Cn0=
prog.cpp: In constructor 'Big::Big()':
prog.cpp:25:52: error: no matching function for call to 'make_unique()'
pointer = std::make_unique<Derived, BaseDeleter>(); // But this doesn't...
^
In file included from /usr/include/c++/5/memory:81:0,
from prog.cpp:1:
/usr/include/c++/5/bits/unique_ptr.h:764:5: note: candidate: typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = Derived; _Args = {BaseDeleter}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<Derived, std::default_delete<Derived> >]
make_unique(_Args&&... __args)
^
/usr/include/c++/5/bits/unique_ptr.h:764:5: note: candidate expects 1 argument, 0 provided
/usr/include/c++/5/bits/unique_ptr.h:770:5: note: candidate: template<class _Tp> typename std::_MakeUniq<_Tp>::__array std::make_unique(std::size_t)
make_unique(size_t __num)
^
/usr/include/c++/5/bits/unique_ptr.h:770:5: note: template argument deduction/substitution failed:
prog.cpp:25:52: error: wrong number of template arguments (2, should be 1)
pointer = std::make_unique<Derived, BaseDeleter>(); // But this doesn't...
^
In file included from /usr/include/c++/5/memory:81:0,
from prog.cpp:1:
/usr/include/c++/5/bits/unique_ptr.h:776:5: note: candidate: template<class _Tp, class ... _Args> typename std::_MakeUniq<_Tp>::__invalid_type std::make_unique(_Args&& ...) <deleted>
make_unique(_Args&&...) = delete;
^
/usr/include/c++/5/bits/unique_ptr.h:776:5: note: template argument deduction/substitution failed:
/usr/include/c++/5/bits/unique_ptr.h: In substitution of 'template<class _Tp, class ... _Args> typename std::_MakeUniq<_Tp>::__invalid_type std::make_unique(_Args&& ...) [with _Tp = Derived; _Args = {BaseDeleter}]':
prog.cpp:25:52: required from here
/usr/include/c++/5/bits/unique_ptr.h:776:5: error: no type named '__invalid_type' in 'struct std::_MakeUniq<Derived>'