File indexing completed on 2025-01-18 10:04:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _NCollection_Allocator_HeaderFile
0015 #define _NCollection_Allocator_HeaderFile
0016
0017 #include <Standard.hxx>
0018 #include <NCollection_BaseAllocator.hxx>
0019
0020 #include <utility>
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 template <typename ItemType>
0036 class NCollection_Allocator
0037 {
0038 public:
0039 typedef ItemType value_type;
0040 typedef value_type* pointer;
0041 typedef const value_type* const_pointer;
0042 typedef value_type& reference;
0043 typedef const value_type& const_reference;
0044 typedef size_t size_type;
0045 typedef ptrdiff_t difference_type;
0046
0047 template <typename OtherType>
0048 struct rebind
0049 {
0050 typedef NCollection_Allocator<OtherType> other;
0051 };
0052
0053
0054
0055
0056 NCollection_Allocator() noexcept
0057 {}
0058
0059
0060 NCollection_Allocator(const Handle(NCollection_BaseAllocator)&) noexcept
0061 {}
0062
0063
0064 template <typename OtherType>
0065 NCollection_Allocator& operator=(const NCollection_Allocator<OtherType>&) noexcept
0066 {
0067 return *this;
0068 }
0069
0070
0071
0072 template <typename OtherType>
0073 NCollection_Allocator(const NCollection_Allocator<OtherType>&) noexcept
0074 {}
0075
0076
0077 pointer address(reference theItem) const
0078 {
0079 return &theItem;
0080 }
0081
0082
0083 const_pointer address(const_reference theItem) const
0084 {
0085 return &theItem;
0086 }
0087
0088
0089 pointer allocate(const size_type theSize, const void* = 0) const
0090 {
0091 return static_cast<pointer>(Standard::AllocateOptimal(theSize * sizeof(ItemType)));
0092 }
0093
0094
0095 void deallocate(pointer thePnt, const size_type) const
0096 {
0097 Standard::Free(static_cast<Standard_Address>(thePnt));
0098 }
0099
0100
0101 pointer reallocate(pointer thePnt, const size_type theSize) const
0102 {
0103 return static_cast<pointer>(Standard::Reallocate(thePnt, theSize * sizeof(ItemType)));
0104 }
0105
0106
0107
0108 template<class _Objty, class... _Types>
0109 void construct(_Objty* _Ptr, _Types&&... _Args)
0110 {
0111 ::new ((void*)_Ptr) _Objty(std::forward<_Types>(_Args)...);
0112 }
0113
0114
0115
0116 void destroy(pointer thePnt)
0117 {
0118 (void)thePnt; thePnt->~value_type();
0119 }
0120
0121 bool operator==(const NCollection_Allocator&) const
0122 {
0123 return true;
0124 }
0125
0126 template<class U>
0127 bool operator==(const NCollection_Allocator<U>&) const noexcept
0128 {
0129 return true;
0130 }
0131
0132 bool operator!=(const NCollection_Allocator&) const noexcept
0133 {
0134 return false;
0135 }
0136
0137 template<class U>
0138 bool operator!=(const NCollection_Allocator<U>&) const noexcept
0139 {
0140 return false;
0141 }
0142
0143 };
0144
0145 template<class U, class V>
0146 bool operator==(const NCollection_Allocator<U>&, const NCollection_Allocator<V>&)
0147 {
0148 return true;
0149 }
0150
0151 #endif