ae2f::Core
Loading...
Searching...
No Matches
Pack.hpp
Go to the documentation of this file.
1
5
6namespace ae2f { namespace Ds { namespace Arr {
7
12 template<typename __el_t>
13 struct __def {
14 public:
16 static constexpr size_t ElSize = sizeof(__el_t);
17
19 using El_t = __el_t;
20
23 };
24
25
31 template<typename T>
32 union Pack {
33 private:
34 friend __Refer<T, 0>;
35 friend __Owner<T, 0>;
36
39 uint8_t c[sizeof(T) + 1];
40
43 constexpr uint8_t& _isvalid() noexcept {
44 return c[sizeof(T)];
45 }
46
49 constexpr const uint8_t& _isvalid() const noexcept {
50 return c[sizeof(T)];
51 }
52
53 template<int d = 0>
54 inline Pack() noexcept : c{0, } {
55 for(size_t i = 0; i < sizeof(T) + 1; i++)
56 c[i] = 0;
57 }
58
59 public:
60
63 T Obj;
64
67 constexpr bool isvalid() const noexcept {
68 return c[sizeof(T)];
69 }
70 inline ~Pack() {}
71 };
72}}}
Definition Alloc.hpp:6
Definition Defs.hpp:39
Definition Defs.hpp:22
A helper class for getting element type and element size.
Definition Pack.hpp:13
__el_t El_t
Defined element type.
Definition Pack.hpp:19
static constexpr size_t ElSize
Pre-defined element size.
Definition Pack.hpp:16
A value package for non-trivial classes. Which will not call the destructor of [T].
Definition Pack.hpp:32
T Obj
Definition Pack.hpp:63
constexpr bool isvalid() const noexcept
Check if ae2f::Ds::Arr::Pack<T>::Obj is valid.
Definition Pack.hpp:67
~Pack()
Definition Pack.hpp:70