-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.cpp
More file actions
56 lines (41 loc) · 781 Bytes
/
example.cpp
File metadata and controls
56 lines (41 loc) · 781 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "refl_builder.hpp"
namespace rb = refl_builder;
class Base
{
[[=rb::BuilderParam]]
int c_ = 10;
private:
[[=rb::BuilderMethod, =rb::Required]]
void withBar(int bar) {
c_ = bar * 2;
}
};
class Derived : public Base
{
private:
[[=rb::BuilderParam]]
int b_ = 10;
public:
static auto& builder()
{
return rb::makeUniqueBuilder<Derived>();
}
int getB() const {
return b_;
}
private:
[[=rb::BuilderMethod, =rb::Required]]
void withFoo(int a) {
b_ += a;
}
};
int main() {
auto a = Derived::builder()
.withFoo(10)
.withBar(10)
.withB(19)
.withC(20)
.build();
std::cout << a->getB() << std::endl;
return 1978;
}