1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #pragma once19 20 #include "../MathBuildConfig.h"21 #include "[MathNamespace.h]"22 #include "../MathGeoLibFwd.h"23 #include <stdint.h>24 #include <cstddef>25 #include "[Reinterpret.h]"26 #include "[simd.h]"27 #include <memory>28 #include <stdexcept>29 30 [MATH_BEGIN_NAMESPACE]31 32 33 void *[AlignedMalloc](size_t size, size_t alignment);34 35 36 template<typename T>37 inline T *[AlignedNew](size_t numElements, size_t alignment) { return reinterpret_cast<T*>([AlignedMalloc](numElements*sizeof(T), alignment)); }38 39 40 template<typename T>41 inline T *[AlignedNew](size_t numElements) { return AlignedNew<T>(numElements, 16); }42 43 44 void [AlignedFree](void *ptr);45 46 template<class T, size_t Alignment>47 struct [AlignedAllocator] : std::allocator<T>48 {49 template<class U>50 struct [rebind] { typedef [AlignedAllocator<U, Alignment>] [other]; };51 52 typedef std::allocator<T> [base];53 54 typedef typename base::const_pointer [const_pointer];55 typedef typename base::pointer [pointer];56 typedef typename base::reference [reference];57 typedef typename base::const_reference [const_reference];58 typedef typename base::value_type [value_type];59 typedef typename base::size_type [size_type];60 typedef typename base::difference_type [difference_type];61 62 [AlignedAllocator](){}63 [AlignedAllocator](const [AlignedAllocator] &):std::allocator<T>(){}64 template<typename U>65 [AlignedAllocator](const [AlignedAllocator<U, Alignment>] &){}66 67 [pointer] [allocate]([size_type] n, const void * = 0)68 {69 return ([pointer])[AlignedMalloc](n*sizeof(T), Alignment);70 }71 72 void [deallocate]([pointer] ptr, [size_type])73 {74 [AlignedFree](ptr);75 }76 };77 78 [MATH_END_NAMESPACE] Go back to previous page