As per N3797, std::make_unique
has three "overloads":
20.8.1.4 unique_ptr creation [unique.ptr.create]
template <class T, class... Args> unique_ptr<T> make_unique(Args&&... args);
1 Remarks: This function shall not participate in overload resolution unless
T
is not an array.2 Returns:
unique_ptr<T>(new T(std::forward<Args>(args)...))
.
template <class T> unique_ptr<T> make_unique(size_t n);
3 Remarks: This function shall not participate in overload resolution unless
T
is an array of unknown bound.4 Returns:
unique_ptr<T>(new remove_extent_t<T>[n]())
.
template <class T, class... Args>
unspecified
make_unique(Args&&...) = delete;
5 Remarks: This function shall not participate in overload resolution unless
T
is an array of known bound.
I don't understand the reason for the third, deleted overload. If T
is an array of known bounds, the first two don't participate in overload resolution anyways, so why does the standard specifies the third one? Isn't this identical to leaving it out and specifying the first two overloads alone?
EDIT: Please note that I know why make_unique<T[N]>
is not allowed. The question is not about that, it's about why the third overloaded is needed. AFAICT, the effect of having or not having it is identical, even wrt make_unique<T[N]>
.