acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
single.h
1#pragma once
2
3
4#define MAKE_SINGLE(SINGLE, T, MEMBER) \
5class SINGLE \
6{ \
7public: \
8 \
9 \
10 using TYPE = T; \
11 using ARG_TYPE = argument_of < TYPE >; \
12\
13\
14 T MEMBER; \
15\
16\
17 TYPE & element() { return MEMBER; } \
18 const TYPE & element() const { return MEMBER; } \
19 \
20 \
21SINGLE() {} \
22SINGLE(ARG_TYPE t) : MEMBER(t) {} \
23\
24\
25}
26
27
28template < typename T >
29MAKE_SINGLE(single, T, m_element);
30
31
32template < typename SINGLE >
33struct make_single :
34 public SINGLE
35{
36public:
37
38
39 using TYPE = typename SINGLE::TYPE;
40 using ARG_TYPE = typename SINGLE::ARG_TYPE;
41
42 using ELEMENT1 = TYPE;
43 using ARG_ELEMENT1 = ARG_TYPE;
44 using ELEMENT2 = TYPE;
45 using ARG_ELEMENT2 = ARG_TYPE;
46
47
48 using KEY = TYPE;
49 using ARG_KEY = ARG_TYPE;
50 using PAYLOAD = TYPE;
51 using ARG_PAYLOAD = ARG_TYPE;
52
53
54 inline auto & topic() { return *this;}
55 inline auto & item() { return this->element(); }
56
57 inline auto & topic() const { return *this; }
58 inline auto & item() const { return this->element(); }
59
60 inline auto & key() { return this->element();}
61 inline auto & key() const { return this->element(); }
62
63 inline auto & payload() { return this->element(); }
64 inline auto & payload() const { return this->element(); }
65
66
67
68 make_single() {}
69 make_single(ARG_TYPE t) : SINGLE(t) {}
70
71
72 void defer_set_payload(ARG_PAYLOAD)
73 {
74
75
76 }
77
78
79};
80
81
82
83
Definition _template_forward_declaration.h:304