-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cc
More file actions
53 lines (49 loc) · 1.06 KB
/
test.cc
File metadata and controls
53 lines (49 loc) · 1.06 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
#include "libProperty"
#include <iostream>
class test{
public:
test(){
std::cout << "ctor is called!" << std::endl;
}
void func(){
std::cout << "func is called!" << std::endl;
}
void getterTest(){
std::cout << "getterTest is called!" << std::endl;
}
};
class Test{
public:
Property<test*> i{
decltype(i)::get{
[](decltype(i)::BaseType &value){
value->getterTest();
return value;
}
},
decltype(i)::set{
[](test* value){
return value;
}
},
new test{}
};
//the number will plus 1 whenever it was stored
Property<int> j{
{},
decltype(j)::set{
[](int value){
return value + 1;
}
}
};
};
int main(){
Test test;
(test.i)->func();
::test* x = (test.i);
test.j = 0;//j is 0+1
test.j += 1;//j is (1+1)+1
std::cout << test.j << std::endl;
return 1;
}