blob: cffc8f56d833e88e173c96d9c2ef66ef3d0da3e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#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) : vref(alloc(new value<T>(val))) { }
vref(ref const & other) : ptr(static_cast<value<T>*>(other.ptr)) { }
operator ref() { return ptr; }
T const & val() { return *ptr; }
// for use by containers
bool operator<(vref<T> const & other) const { return self.ptr < other.ptr; }
value<T> * const ptr;
};
}
}
|