From: Chandler Carruth Date: Tue, 15 Apr 2014 21:51:14 +0000 (+0000) Subject: [Allocator] Fold the two templated overloads into a single one with X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d24010f61aca296aa80ef1c926612484cd25e8c9;p=oota-llvm.git [Allocator] Fold the two templated overloads into a single one with a default argument. The allocator interface we're modeling doesn't distinguish between array and non-array allocation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206327 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index 1c4b9c6552e..82c200abd06 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -78,29 +78,16 @@ public: // The rest of these methods are helpers that redirect to one of the above // core methods. - /// \brief Allocate space for one object without constructing it. - template T *Allocate() { - return static_cast(Allocate(sizeof(T), AlignOf::Alignment)); - } - - /// \brief Allocate space for an array of objects without constructing them. - template T *Allocate(size_t Num) { + /// \brief Allocate space for a sequence of objects without constructing them. + template T *Allocate(size_t Num = 1) { return static_cast(Allocate(Num * sizeof(T), AlignOf::Alignment)); } - /// \brief Deallocate space for one object without destroying it. - template - typename std::enable_if< - !std::is_same::type, void>::value, void>::type - Deallocate(T *Ptr) { - Deallocate(static_cast(Ptr), sizeof(T)); - } - - /// \brief Allocate space for an array of objects without constructing them. + /// \brief Deallocate space for a sequence of objects without constructing them. template typename std::enable_if< !std::is_same::type, void>::value, void>::type - Deallocate(T *Ptr, size_t Num) { + Deallocate(T *Ptr, size_t Num = 1) { Deallocate(static_cast(Ptr), Num * sizeof(T)); } };