blob: 1eb701dfaf8aca48fc978e43eb0910da6f8377ca (
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
33
|
#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>*>((concept*)other)) { }
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; }
protected:
value<T> * const ptr;
};
}
}
|