diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-24 13:22:55 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-24 13:22:55 -0800 |
commit | 9a14918abec434d8463e07635daef380ad630649 (patch) | |
tree | fa1a5200da88ad6065092b05dc063a8a80df8faa /starts/meaning-vm/level-0/vref.hpp | |
parent | 50be8bb8697b23ff469de142eaebe9666c2a9537 (diff) | |
download | standingwithresilience-9a14918abec434d8463e07635daef380ad630649.tar.gz standingwithresilience-9a14918abec434d8463e07635daef380ad630649.zip |
breaking into levels
Diffstat (limited to 'starts/meaning-vm/level-0/vref.hpp')
-rw-r--r-- | starts/meaning-vm/level-0/vref.hpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/starts/meaning-vm/level-0/vref.hpp b/starts/meaning-vm/level-0/vref.hpp new file mode 100644 index 0000000..7fe2045 --- /dev/null +++ b/starts/meaning-vm/level-0/vref.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "common.hpp" +#include "memorystore.hpp" +#include "ref.hpp" +#include "value.hpp" + +namespace intellect { +namespace level0 { + +template <typename T> +struct vref +{ + vref(value<T> *p) : ptr(p) { } + value<T>* operator->() { return ptr; } + operator T const &() const { return *ptr; } + + vref(T const & val) : ptr(alloc(new value<T>(val))) { } + + vref(ref const & other) : ptr(static_cast<value<T>*>(other.ptr)) { } + operator ref() { return ptr; } + + // for use by containers + bool operator<(vref<T> const & other) const { return self.ptr < other.ptr; } + + value<T> * const ptr; +}; + + +} +} |