-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (43 loc) · 1.16 KB
/
main.cpp
File metadata and controls
55 lines (43 loc) · 1.16 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
54
55
#include "Bar.hpp"
#include "Foo.hpp"
#include "ContiguousMonostate.hpp"
#include "ContiguousMonostateAllocator.hpp"
#include "StaticMonostate.hpp"
#include "TypeList.hpp"
#include <memory>
int foo_data {1};
int bar_data {2};
void doStaticMonostate() {
using Foo = std::unique_ptr<StaticMonostate<other::Foo>>;
using Bar = std::unique_ptr<StaticMonostate<other::Bar>>;
Foo foo;
{
foo = std::make_unique<StaticMonostate<other::Foo>>(foo_data);
foo->get().doFoo();
}
Bar bar;
{
bar = std::make_unique<StaticMonostate<other::Bar>>(bar_data);
bar->get().doBar();
}
}
void doContiguousMonostate() {
using Types = TypeList<other::Foo, other::Bar>;
using Foo = std::unique_ptr<ContiguousMonostate<other::Foo, Types>>;
using Bar = std::unique_ptr<ContiguousMonostate<other::Bar, Types>>;
Foo foo;
{
foo = std::make_unique<Foo::element_type>(foo_data);
foo->get().doFoo();
}
Bar bar;
{
bar = std::make_unique<Bar::element_type>(bar_data);
bar->get().doBar();
}
}
int main(void) {
doStaticMonostate();
doContiguousMonostate();
std::cin.get();
}