blob: ef31c17b10b8803612bf4ce45a91fb6c41f82553 (
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
34
35
36
37
38
39
40
|
#pragma once
#include <memory>
#include "ValueBroker.h"
namespace crepe {
template <typename T>
ValueBroker<T>::ValueBroker(T & value) :
value(value),
setter([] (T & value, const T & target) {
value = std::move(target);
}),
getter([] (T & value) -> const int & {
return value;
})
{
}
template <typename T>
ValueBroker<T>::ValueBroker(T & value, const setter_t & setter, const getter_t & getter) :
value(value),
setter(setter),
getter(getter)
{
}
template <typename T>
const T & ValueBroker<T>::get() {
return this->getter(this->value);
}
template <typename T>
void ValueBroker<T>::set(const T & value) {
this->setter(this->value, value);
}
}
|