Plasma Engine  2.0
Loading...
Searching...
No Matches
StaticArray_inl.h
1
2template <typename T, plUInt32 C>
4{
5 PL_ASSERT_DEBUG(this->m_pElements == nullptr, "static arrays should not use m_pElements");
6 this->m_uiCapacity = C;
7}
8
9template <typename T, plUInt32 C>
11{
12 PL_ASSERT_DEBUG(this->m_pElements == nullptr, "static arrays should not use m_pElements");
13 this->m_uiCapacity = C;
14 *this = (plArrayPtr<const T>)rhs; // redirect this to the plArrayPtr version
15}
16
17template <typename T, plUInt32 C>
18template <plUInt32 OtherCapacity>
20{
21 static_assert(OtherCapacity <= C);
22
23 PL_ASSERT_DEBUG(this->m_pElements == nullptr, "static arrays should not use m_pElements");
24 this->m_uiCapacity = C;
25
26 *this = (plArrayPtr<const T>)rhs; // redirect this to the plArrayPtr version
27}
28
29template <typename T, plUInt32 C>
31{
32 PL_ASSERT_DEBUG(this->m_pElements == nullptr, "static arrays should not use m_pElements");
33 this->m_uiCapacity = C;
34
35 *this = rhs;
36}
37
38template <typename T, plUInt32 C>
40{
41 this->Clear();
42 PL_ASSERT_DEBUG(this->m_pElements == nullptr, "static arrays should not use m_pElements");
43}
44
45template <typename T, plUInt32 C>
46PL_ALWAYS_INLINE T* plStaticArray<T, C>::GetStaticArray()
47{
48 return reinterpret_cast<T*>(m_Data);
49}
50
51template <typename T, plUInt32 C>
52PL_FORCE_INLINE const T* plStaticArray<T, C>::GetStaticArray() const
53{
54 return reinterpret_cast<const T*>(m_Data);
55}
56
57template <typename T, plUInt32 C>
58PL_FORCE_INLINE void plStaticArray<T, C>::Reserve(plUInt32 uiCapacity)
59{
60 PL_ASSERT_DEV(uiCapacity <= C, "The static array has a fixed capacity of {0}, cannot reserve more elements than that.", C);
61 // Nothing to do here
62}
63
64template <typename T, plUInt32 C>
65PL_ALWAYS_INLINE void plStaticArray<T, C>::operator=(const plStaticArray<T, C>& rhs)
66{
67 *this = (plArrayPtr<const T>)rhs; // redirect this to the plArrayPtr version
68}
69
70template <typename T, plUInt32 C>
71template <plUInt32 OtherCapacity>
73{
74 *this = (plArrayPtr<const T>)rhs; // redirect this to the plArrayPtr version
75}
76
77template <typename T, plUInt32 C>
78PL_ALWAYS_INLINE void plStaticArray<T, C>::operator=(const plArrayPtr<const T>& rhs)
79{
81}
82
83template <typename T, plUInt32 C>
84PL_FORCE_INLINE T* plStaticArray<T, C>::GetElementsPtr()
85{
86 return GetStaticArray();
87}
88
89template <typename T, plUInt32 C>
90PL_FORCE_INLINE const T* plStaticArray<T, C>::GetElementsPtr() const
91{
92 return GetStaticArray();
93}
Base class for all array containers. Implements all the basic functionality that only requires a poin...
Definition ArrayBase.h:19
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Wraps a C-style array, which has a fixed size at compile-time, with a more convenient interface.
Definition StaticArray.h:13
void Reserve(plUInt32 uiCapacity)
For the static array Reserve is a no-op. However the function checks if the requested capacity is bel...
Definition StaticArray_inl.h:58
plStaticArray()
Creates an empty array.
Definition StaticArray_inl.h:3
~plStaticArray()
Destroys all objects.
Definition StaticArray_inl.h:39
void operator=(const plStaticArray< T, Capacity > &rhs)
Copies the data from some other contiguous array into this one.