diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2014-04-15 21:51:14 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2014-04-15 21:51:14 +0000 |
commit | d24010f61aca296aa80ef1c926612484cd25e8c9 (patch) | |
tree | 901f7a545a56d678089b20790aa056cbb11567b1 /include/llvm/Support/Allocator.h | |
parent | 00e4a827f53f13f31e840e3a255754e4bcde37f5 (diff) | |
download | llvm-d24010f61aca296aa80ef1c926612484cd25e8c9.tar.gz llvm-d24010f61aca296aa80ef1c926612484cd25e8c9.tar.bz2 llvm-d24010f61aca296aa80ef1c926612484cd25e8c9.tar.xz |
[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
Diffstat (limited to 'include/llvm/Support/Allocator.h')
-rw-r--r-- | include/llvm/Support/Allocator.h | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index 1c4b9c6552..82c200abd0 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 <typename T> T *Allocate() { - return static_cast<T *>(Allocate(sizeof(T), AlignOf<T>::Alignment)); - } - - /// \brief Allocate space for an array of objects without constructing them. - template <typename T> T *Allocate(size_t Num) { + /// \brief Allocate space for a sequence of objects without constructing them. + template <typename T> T *Allocate(size_t Num = 1) { return static_cast<T *>(Allocate(Num * sizeof(T), AlignOf<T>::Alignment)); } - /// \brief Deallocate space for one object without destroying it. - template <typename T> - typename std::enable_if< - !std::is_same<typename std::remove_cv<T>::type, void>::value, void>::type - Deallocate(T *Ptr) { - Deallocate(static_cast<const void *>(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 T> typename std::enable_if< !std::is_same<typename std::remove_cv<T>::type, void>::value, void>::type - Deallocate(T *Ptr, size_t Num) { + Deallocate(T *Ptr, size_t Num = 1) { Deallocate(static_cast<const void *>(Ptr), Num * sizeof(T)); } }; |