*/
template<typename T, typename Dp = std::default_delete<T>, typename... Args>
-std::unique_ptr<T, Dp> make_unique(Args&&... args) {
+typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T, Dp>>::type
+make_unique(Args&&... args) {
return std::unique_ptr<T, Dp>(new T(std::forward<Args>(args)...));
}
+// Allows 'make_unique<T[]>(10)'. (N3690 s20.9.1.4 p3-4)
+template<typename T, typename Dp = std::default_delete<T>>
+typename std::enable_if<std::is_array<T>::value, std::unique_ptr<T, Dp>>::type
+make_unique(const size_t n) {
+ return std::unique_ptr<T, Dp>(new typename std::remove_extent<T>::type[n]());
+}
+
+// Disallows 'make_unique<T[10]>()'. (N3690 s20.9.1.4 p5)
+template<typename T, typename Dp = std::default_delete<T>, typename... Args>
+typename std::enable_if<
+ std::extent<T>::value != 0, std::unique_ptr<T, Dp>>::type
+make_unique(Args&&...) = delete;
+
/**
* A SimpleAllocator must provide two methods:
*