diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-25 05:02:10 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-25 05:02:10 -0800 |
commit | 520119a6f6ed418b8ae45bfde8239bbb532562cd (patch) | |
tree | 6cc381877adb5ddfaf131415c64f87eca5649676 /starts/meaning-vm/level-0/ref-mixin.hpp | |
parent | cd03e291664cb102bde61d86a15f0add11809766 (diff) | |
download | standingwithresilience-520119a6f6ed418b8ae45bfde8239bbb532562cd.tar.gz standingwithresilience-520119a6f6ed418b8ae45bfde8239bbb532562cd.zip |
cleanup mixin pointer mess for refs
Diffstat (limited to 'starts/meaning-vm/level-0/ref-mixin.hpp')
-rw-r--r-- | starts/meaning-vm/level-0/ref-mixin.hpp | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/starts/meaning-vm/level-0/ref-mixin.hpp b/starts/meaning-vm/level-0/ref-mixin.hpp deleted file mode 100644 index 15e5abe..0000000 --- a/starts/meaning-vm/level-0/ref-mixin.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include <map> -#include <vector> - -namespace intellect { -namespace level0 { - -template <typename ref, template<typename> typename vref> -struct refmixin { - using links_t = std::multimap<ref, ref>; - using array = std::vector<ref>; - - void link(ref const & type, ref const & target) { p()->link(conv<r>(type), conv<r>(target)); } - void unlink(ref const & type, ref const & target) { p()->unlink(conv<r>(type), conv<r>(target)); } - void unlink(ref const & type) { p()->unlink(conv<r>(type)); } - - bool linked(ref const & type) const { return p()->linked(conv<r>(type)); } - bool linked(ref const & type, ref const & target) const { return p()->linked(conv<r>(type), conv<r>(target)); } - - array getAll(ref const & type) const { return conv<array>(p()->getAll(conv<r>(type))); } - - links_t & links() const { return *(links_t*)&(p()->links); } - - ref get(ref const & type) const { return conv<ref>(p()->get(conv<r>(type))); } - void set(ref const & type, ref const & target) { p()->set(conv<r>(type), conv<r>(target)); } - - template <typename T> - vref<T> vget(ref const & type) const { return conv<vref<T>>(get(type)); } - - bool operator==(ref const & other) const { return self.p() == other.p(); } - bool operator!=(ref const & other) const { return self.p() == other.p(); } - bool operator<(ref const & other) const { return self.p() < other.p(); } - -private: - inline concept * p() const { return *conv<concept**>(this); } - using r = level0::ref; - template <typename OUT, typename IN> - static inline OUT conv(IN r) { return *(OUT*)&r; } -}; -} -} |