diff options
author | 2016-05-29 19:30:05 +0200 | |
---|---|---|
committer | 2016-06-07 21:41:54 +0200 | |
commit | 3d3f5761f0b0419581762f72ea0984e047d3e55c (patch) | |
tree | 9330381da7fef4e9c9013809bba28f2a272da505 /src/lib/netlist/plib/plists.h | |
parent | b27790890530b658e178846e7da01045185f0fce (diff) |
- Added constructors to prepare to move terminal setup into constructor.
- Reworked twoterm setup. Fixed some timebombs along the way.
- Fix r2r dac. Remove dead code.
- analog_outputs now created in constructor.
- moved analog_input creation into constructor.
- moved logic output creation to constructor.
- moved all logic inputs into constructor.
- Completely removed init_object. Finally.
[Couriersud]
Diffstat (limited to 'src/lib/netlist/plib/plists.h')
-rw-r--r-- | src/lib/netlist/plib/plists.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index 4e1454a7d30..718aab95cb8 100644 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -13,6 +13,7 @@ #include <algorithm> #include <stack> #include <vector> +#include <type_traits> #include "palloc.h" #include "pstring.h" @@ -105,22 +106,25 @@ public: ~uninitialised_array_t() { for (std::size_t i=0; i<N; i++) - { - C &r = (*this)[i]; - r.~C(); - } + (*this)[i].~C(); } size_t size() { return N; } C& operator[](const std::size_t &index) { - return *reinterpret_cast<C *>(reinterpret_cast<char *>(m_buf) + index * sizeof(C)); + return *reinterpret_cast<C *>(&m_buf[index]); } const C& operator[](const std::size_t &index) const { - return *reinterpret_cast<C *>(reinterpret_cast<char *>(m_buf) + index * sizeof(C)); + return *reinterpret_cast<C *>(&m_buf[index]); + } + + template<typename... Args> + void emplace(const std::size_t index, Args&&... args) + { + new (&m_buf[index]) C(std::forward<Args>(args)...); } protected: @@ -128,7 +132,7 @@ protected: private: /* ensure proper alignment */ - UINT64 m_buf[(N * sizeof(C) + sizeof(UINT64) - 1) / sizeof(UINT64)]; + typename std::aligned_storage<sizeof(C), alignof(C)>::type m_buf[N]; }; // ---------------------------------------------------------------------------------------- |