diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-05 16:08:26 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-05 16:08:26 +0300 |
commit | 247a28f242c2c0a8931a84df0db6e60763642f30 (patch) | |
tree | cdd5721ab333967a5b4e0489ded5f29bf48610b4 /source/blender/blenlib/BLI_memory_utils.hh | |
parent | 5d79f9f276b4b3e6289308c534c58e7ee3bb5e2d (diff) |
Revert "BLI: refactor how buffers for small object optimization are stored"
This reverts commit 5d79f9f276b4b3e6289308c534c58e7ee3bb5e2d.
This was introducing build errors in windows. Need a bit more time to check it.
Diffstat (limited to 'source/blender/blenlib/BLI_memory_utils.hh')
-rw-r--r-- | source/blender/blenlib/BLI_memory_utils.hh | 67 |
1 files changed, 5 insertions, 62 deletions
diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh index 5e713461083..44d25340778 100644 --- a/source/blender/blenlib/BLI_memory_utils.hh +++ b/source/blender/blenlib/BLI_memory_utils.hh @@ -218,8 +218,12 @@ template<typename T> struct DestructValueAtAddress { template<typename T> using destruct_ptr = std::unique_ptr<T, DestructValueAtAddress<T>>; /** - * An `AlignedBuffer` is a byte array with at least the given size and alignment. The buffer will + * An `AlignedBuffer` is simply a byte array with the given size and alignment. The buffer will * not be initialized by the default constructor. + * + * This can be used to reserve memory for C++ objects whose lifetime is different from the + * lifetime of the object they are embedded in. It's used by containers with small buffer + * optimization and hash table implementations. */ template<size_t Size, size_t Alignment> class alignas(Alignment) AlignedBuffer { private: @@ -227,16 +231,6 @@ template<size_t Size, size_t Alignment> class alignas(Alignment) AlignedBuffer { char buffer_[(Size > 0) ? Size : 1]; public: - operator void *() - { - return (void *)buffer_; - } - - operator const void *() const - { - return (void *)buffer_; - } - void *ptr() { return (void *)buffer_; @@ -249,57 +243,6 @@ template<size_t Size, size_t Alignment> class alignas(Alignment) AlignedBuffer { }; /** - * This can be used to reserve memory for C++ objects whose lifetime is different from the - * lifetime of the object they are embedded in. It's used by containers with small buffer - * optimization and hash table implementations. - */ -template<typename T, size_t Size = 1> class TypedBuffer { - private: - AlignedBuffer<sizeof(T) * Size, alignof(T)> buffer_; - - public: - operator T *() - { - return (T *)&buffer_; - } - - operator const T *() const - { - return (const T *)&buffer_; - } - - T *operator->() - { - return (T *)&buffer_; - } - - const T *operator->() const - { - return (const T *)&buffer_; - } - - T &operator*() - { - return *(T *)&buffer_; - } - - const T &operator*() const - { - return *(const T *)&buffer_; - } - - T *ptr() - { - return (T *)&buffer_; - } - - const T *ptr() const - { - return (const T *)&buffer_; - } -}; - -/** * This can be used by container constructors. A parameter of this type should be used to indicate * that the constructor does not construct the elements. */ |