diff options
Diffstat (limited to 'splitmemdict.hpp')
-rw-r--r-- | splitmemdict.hpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/splitmemdict.hpp b/splitmemdict.hpp index 6631947..45a9ee1 100644 --- a/splitmemdict.hpp +++ b/splitmemdict.hpp @@ -21,7 +21,7 @@ #include "alee.hpp" -#include <cstring> +#include <algorithm> #ifndef MEMDICTSIZE #define MEMDICTSIZE (65536) @@ -32,14 +32,21 @@ template<unsigned long int RON> class SplitMemDict : public Dictionary { const uint8_t *rodict; - uint8_t rwdict[MemDictSize]; + uint8_t rwdict[MemDictSize - Dictionary::Begin] = {0}; uint8_t extra[Dictionary::Begin]; public: - constexpr SplitMemDict(const uint8_t *rod): + constexpr explicit SplitMemDict(const uint8_t *rod): rodict(rod) { - std::memcpy(extra, rodict, sizeof(extra)); + std::copy(rodict, rodict + sizeof(extra), extra); + } + + constexpr SplitMemDict(const SplitMemDict<RON>& spd): + SplitMemDict(spd.rodict) {} + constexpr auto& operator=(const SplitMemDict<RON>& spd) { + *this = SplitMemDict(spd.rodict); + return *this; } virtual Cell read(Addr addr) const noexcept final { |