mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-24 09:29:42 +00:00
[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
This commit is contained in:
parent
00e4a827f5
commit
d24010f61a
@ -78,29 +78,16 @@ public:
|
|||||||
// The rest of these methods are helpers that redirect to one of the above
|
// The rest of these methods are helpers that redirect to one of the above
|
||||||
// core methods.
|
// core methods.
|
||||||
|
|
||||||
/// \brief Allocate space for one object without constructing it.
|
/// \brief Allocate space for a sequence of objects without constructing them.
|
||||||
template <typename T> T *Allocate() {
|
template <typename T> T *Allocate(size_t Num = 1) {
|
||||||
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) {
|
|
||||||
return static_cast<T *>(Allocate(Num * sizeof(T), AlignOf<T>::Alignment));
|
return static_cast<T *>(Allocate(Num * sizeof(T), AlignOf<T>::Alignment));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Deallocate space for one object without destroying it.
|
/// \brief Deallocate space for a sequence of objects without constructing them.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
!std::is_same<typename std::remove_cv<T>::type, void>::value, void>::type
|
!std::is_same<typename std::remove_cv<T>::type, void>::value, void>::type
|
||||||
Deallocate(T *Ptr) {
|
Deallocate(T *Ptr, size_t Num = 1) {
|
||||||
Deallocate(static_cast<const void *>(Ptr), sizeof(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Allocate space for an array 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(static_cast<const void *>(Ptr), Num * sizeof(T));
|
Deallocate(static_cast<const void *>(Ptr), Num * sizeof(T));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user