-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.h
More file actions
41 lines (34 loc) · 703 Bytes
/
test.h
File metadata and controls
41 lines (34 loc) · 703 Bytes
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
41
#pragma once
#include "Property.h"
namespace test{
using namespace tower120::utils;
struct In{
int x;
int y;
};
class Data{
In m_i;
public:
auto j() {
return Property(
[&]() -> const auto& { return m_i; },
[&](const auto& i) { m_i = i; }
);
}
auto j() const {
return const_cast<Data&>(*this).j().make_const();
}
};
void main(){
{
// read
const Data data{};
std::cout << data.j()->x;
}
{
// write
Data data{};
data.j() = In{1,2};
}
}
}