7 #ifndef NAZARA_MEMORYHELPER_HPP 8 #define NAZARA_MEMORYHELPER_HPP 10 #if defined(NAZARA_COMPILER_MSVC) || defined(NAZARA_COMPILER_MINGW) 14 #define NAZARA_ALLOCA(size) _alloca(size) 15 #define NAZARA_ALLOCA_SUPPORT 17 #elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) 20 #define NAZARA_ALLOCA(size) alloca(size) 21 #define NAZARA_ALLOCA_SUPPORT 25 #ifdef NAZARA_ALLOCA_SUPPORT 26 #define NazaraStackAllocation(T, size) Nz::StackArray<T>(static_cast<T*>(NAZARA_ALLOCA((size) * sizeof(T))), size) 27 #define NazaraStackAllocationNoInit(T, size) Nz::StackArray<T>(static_cast<T*>(NAZARA_ALLOCA((size) * sizeof(T))), size, Nz::NoInitTag()) 29 #define NazaraStackAllocation(T, size) Nz::StackArray<T>(static_cast<T*>(Nz::OperatorNew((size) * sizeof(T))), size) 30 #define NazaraStackAllocationNoInit(T, size) Nz::StackArray<T>(static_cast<T*>(Nz::OperatorNew((size) * sizeof(T))), size, Nz::NoInitTag()) 41 template<
typename T,
typename... Args>
54 using const_iterator =
const value_type*;
55 using const_pointer =
const value_type*;
56 using const_reference =
const value_type&;
57 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
58 using difference_type = std::ptrdiff_t;
59 using iterator = value_type*;
60 using pointer = value_type*;
61 using reference = value_type&;
62 using reverse_iterator = std::reverse_iterator<iterator>;
63 using size_type = std::size_t;
66 StackArray(T* stackMemory, std::size_t size, NoInitTag);
70 const_reference back()
const;
72 iterator begin() noexcept;
73 const_iterator begin()
const noexcept;
75 const_iterator cbegin()
const noexcept;
76 const_iterator cend()
const noexcept;
77 const_reverse_iterator crbegin()
const noexcept;
78 const_reverse_iterator crend()
const noexcept;
81 const T* data()
const noexcept;
83 bool empty()
const noexcept;
85 iterator end() noexcept;
86 const_iterator end()
const noexcept;
88 void fill(
const T& value);
90 reference front() noexcept;
91 const_reference front()
const noexcept;
93 size_type max_size()
const noexcept;
95 reverse_iterator rbegin() noexcept;
96 const_reverse_iterator rbegin()
const noexcept;
98 reverse_iterator rend() noexcept;
99 const_reverse_iterator rend()
const noexcept;
101 size_type size()
const noexcept;
103 reference operator[](size_type pos);
104 const_reference operator[](size_type pos)
const;
113 #include <Nazara/Core/MemoryHelper.inl> 115 #endif // NAZARA_MEMORYHELPER_HPP TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
void PlacementDestroy(T *ptr)
Calls the object destructor explicitly.
Definition: MemoryHelper.inl:75
T * PlacementNew(T *ptr, Args &&... args)
Constructs the object inplace.
Definition: MemoryHelper.inl:64
void OperatorDelete(void *ptr)
Calls the operator delete on the pointer.
Definition: MemoryHelper.inl:33
void * OperatorNew(std::size_t size)
Calls the operator new on the pointer.
Definition: MemoryHelper.inl:47
Core class that represents a stack-allocated (if alloca is present) array.
Definition: MemoryHelper.hpp:50