I have not been able to find any documentation about what happens if I pass a null pointer to std::make_unique.
Is an exception thrown?
std::make_unique forwards all the arguments passed to a matching target constructor.
Therefore, if you pass nullptr, it will search for a constructor that accepts nullptr_t (or any matching constructor). If it is not there, it will fail to compile.
class A
{
public:
A(void*) { ... } // could also be A(int*) or template <typename T> A(T*)
};
...
std::make_unique<A>(nullptr); // constructs an A by calling A(void*), passing nullptr.
make_unique? How is passing null pointer different from passing, say.42or"Hello World"?make_uniquedoes not take a pointer and "make it unique", it creates ("makes") an object that has unique and transferrable ownership.std::make_unique<int*>(nullptr)creates a nullint*with those properties.std::make_unqiue<Type>creates a dynamicTypeinstance and assigns ownership to the then-returnedstd::unique_ptr<Type>object. This sounds like you thinkstd::make_uniquedoes something else, or your confusingstd::make_uniquewith the constructor forstd::unique_ptr; they're different beasts.