summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-04-15 21:51:14 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-04-15 21:51:14 +0000
commita073f253f334efcf28143f602128197a4cbc1d28 (patch)
tree331aa7e4433ab7c2604e25653bd2c494b18594a4 /llvm/include
parent1fc97224af0a7b9052eb52927fc28c322894dc80 (diff)
downloadbcm5719-llvm-a073f253f334efcf28143f602128197a4cbc1d28.tar.gz
bcm5719-llvm-a073f253f334efcf28143f602128197a4cbc1d28.zip
[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. llvm-svn: 206327
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/Support/Allocator.h21
1 files changed, 4 insertions, 17 deletions
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h
index 1c4b9c6552e..82c200abd06 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/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));
}
};
OpenPOWER on IntegriCloud