From 8445040fe4859063640235462760aeaa1a4fa163 Mon Sep 17 00:00:00 2001 From: Ahmed Charles Date: Sun, 9 Mar 2014 12:12:23 +0000 Subject: [PATCH] Change documentation based on feedback from Chandler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203393 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/STLExtras.h | 42 ++++++++++++++---------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index 5a3756de3dd..66221de2a48 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -263,40 +263,29 @@ void DeleteContainerSeconds(Container &C) { #if LLVM_HAS_VARIADIC_TEMPLATES -/// Implement make_unique according to N3656. +// Implement make_unique according to N3656. + +/// \brief Constructs a `new T()` with the given args and returns a +/// `unique_ptr` which owns the object. /// -/// template unique_ptr make_unique(Args&&... args); -/// Remarks: This function shall not participate in overload resolution unless -/// T is not an array. -/// Returns: unique_ptr(new T(std::forward(args)...)). -/// -/// template unique_ptr make_unique(size_t n); -/// Remarks: This function shall not participate in overload resolution unless -/// T is an array of unknown bound. -/// Returns: unique_ptr(new typename remove_extent::type[n]()). -/// -/// template unspecified make_unique(Args&&...) = delete; -/// Remarks: This function shall not participate in overload resolution unless -/// T is an array of known bound. -/// -/// Use scenarios: -/// -/// Single object case: -/// -/// auto p0 = make_unique(); -/// -/// auto p2 = make_unique>(0, 1); -/// -/// Array case: -/// -/// auto p1 = make_unique(2); // value-initializes the array with 0's. +/// Example: /// +/// auto p = make_unique(); +/// auto p = make_unique>(0, 1); template typename std::enable_if::value, std::unique_ptr>::type make_unique(Args &&... args) { return std::unique_ptr(new T(std::forward(args)...)); } +/// \brief Constructs a `new T[n]` with the given args and returns a +/// `unique_ptr` which owns the object. +/// +/// \param n size of the new array. +/// +/// Example: +/// +/// auto p = make_unique(2); // value-initializes the array with 0's. template typename std::enable_if::value && std::extent::value == 0, std::unique_ptr>::type @@ -304,6 +293,7 @@ make_unique(size_t n) { return std::unique_ptr(new typename std::remove_extent::type[n]()); } +/// This function isn't used and is only here to provide better compile errors. template typename std::enable_if::value != 0>::type make_unique(Args &&...) LLVM_DELETED_FUNCTION;