For unique_ptr, the deleter is part of the type:
template <
class T,
class Deleter = std::default_delete<T>
> class unique_ptr;
As such, when you're constructing an object, you need to specify its type. The line you're writing:
std::unique_ptr<int> x(new int, custom_deleter);
is equivalent to:
std::unique_ptr<int, std::default_delete<int> > x(new int, custom_deleter);
And you cannot construct a std::default_delete<int> from custom_deleter.
The only way to infer the deleter type is to use template deduction on that part too:
template <typename T, typename Deleter>
std::unique_ptr<T, Deleter> make_unique_ptr(T* ptr, Deleter deleter) {
return std::unique_ptr<T, Deleter>(ptr, deleter);
}