@@ -32,6 +32,12 @@ namespace internal
32
32
std::optional<MemorySelection> memorySelection;
33
33
};
34
34
35
+ /*
36
+ * Actual data members of `ConfigureLoadStore<>`. They don't depend on the
37
+ * template parameter of that class template, so by extracting the members
38
+ * to this struct, we can pass them around between different instances of
39
+ * the class template.
40
+ */
35
41
struct ConfigureLoadStoreData
36
42
{
37
43
ConfigureLoadStoreData (RecordComponent &);
@@ -42,6 +48,13 @@ namespace internal
42
48
};
43
49
} // namespace internal
44
50
51
+ /* * Basic configuration for a Load/Store operation.
52
+ *
53
+ * @tparam ChildClass CRT pattern.
54
+ * The purpose is that in child classes `return *this` should return
55
+ * an instance of the child class, not of ConfigureLoadStore.
56
+ * Instantiate with void when using without subclass.
57
+ */
45
58
template <typename ChildClass = void >
46
59
class ConfigureLoadStore : protected internal ::ConfigureLoadStoreData
47
60
{
@@ -53,7 +66,7 @@ class ConfigureLoadStore : protected internal::ConfigureLoadStoreData
53
66
ConfigureLoadStore (RecordComponent &rc);
54
67
ConfigureLoadStore (ConfigureLoadStoreData &&);
55
68
56
- auto dim () const -> uint8_t;
69
+ [[nodiscard]] auto dim () const -> uint8_t;
57
70
auto getOffset () -> Offset const &;
58
71
auto getExtent () -> Extent const &;
59
72
auto storeChunkConfig () -> internal::LoadStoreConfig;
@@ -67,34 +80,37 @@ class ConfigureLoadStore : protected internal::ConfigureLoadStoreData
67
80
auto offset (Offset) -> return_type &;
68
81
auto extent (Extent) -> return_type &;
69
82
83
+ /*
84
+ * If the type is non-const, then the return type should be
85
+ * ConfigureLoadStoreFromBuffer<>, ...
86
+ */
70
87
template <typename T>
71
88
struct shared_ptr_return_type_impl
72
89
{
73
- using type = ConfigureLoadStoreFromBuffer<
74
- std::shared_ptr<std::remove_extent_t <T>>>;
90
+ using type = ConfigureLoadStoreFromBuffer<std::shared_ptr<T>>;
75
91
};
92
+ /*
93
+ * ..., but if it is a const type, Load operations make no sense, so the
94
+ * return type should be ConfigureStoreChunkFromBuffer<>.
95
+ */
76
96
template <typename T>
77
97
struct shared_ptr_return_type_impl <T const >
78
98
{
79
99
using type =
80
100
ConfigureStoreChunkFromBuffer<std::shared_ptr<T const >, void >;
81
101
};
82
- template <typename T>
83
- struct shared_ptr_return_type_impl <T const []>
84
- {
85
- using type =
86
- ConfigureStoreChunkFromBuffer<std::shared_ptr<T const >, void >;
87
- };
88
102
89
103
template <typename T>
90
104
using shared_ptr_return_type =
91
- typename shared_ptr_return_type_impl<T >::type;
105
+ typename shared_ptr_return_type_impl<std:: remove_extent_t <T> >::type;
92
106
93
- template <typename T>
94
- using normalize_dataset_type = std::remove_cv_t <std::remove_extent_t <T>>;
107
+ /*
108
+ * As loading into unique pointer types makes no sense, the case is simpler
109
+ * for unique pointers. Just remove the array extents here.
110
+ */
95
111
template <typename T>
96
112
using unique_ptr_return_type = ConfigureStoreChunkFromBuffer<
97
- UniquePtrWithLambda<normalize_dataset_type <T>>,
113
+ UniquePtrWithLambda<std:: remove_extent_t <T>>,
98
114
void >;
99
115
100
116
// @todo rvalue references..?
@@ -127,6 +143,19 @@ class ConfigureLoadStore : protected internal::ConfigureLoadStoreData
127
143
[[nodiscard]] auto enqueueLoadVariant () -> shared_ptr_dataset_types;
128
144
};
129
145
146
+ /* * Configuration for a Store operation with a buffer type.
147
+ *
148
+ * This class does intentionally not support Load operations since there are
149
+ * pointer types (const pointers, unique pointers) where Load operations make no
150
+ * sense. See the \ref ConfigureLoadStoreFromBuffer class template for both
151
+ * Load/Store operations.
152
+ *
153
+ * @tparam Ptr_Type The type of pointer used internally.
154
+ * @tparam ChildClass CRT pattern.
155
+ * The purpose is that in child classes `return *this` should return
156
+ * an instance of the child class, not of ConfigureStoreChunkFromBuffer.
157
+ * Instantiate with void when using without subclass.
158
+ */
130
159
template <typename Ptr_Type, typename ChildClass = void >
131
160
class ConfigureStoreChunkFromBuffer
132
161
: public ConfigureLoadStore<std::conditional_t <
@@ -161,6 +190,12 @@ class ConfigureStoreChunkFromBuffer
161
190
auto as_parent () const & -> parent_t const &;
162
191
163
192
auto enqueueStore () -> void;
193
+
194
+ /* * This intentionally shadows the parent class's enqueueLoad method in
195
+ * order to show a compile error when using enqueueLoad() on an object of
196
+ * this class. The parent method can still be accessed through as_parent()
197
+ * if needed.
198
+ */
164
199
template <typename X = void >
165
200
auto enqueueLoad ()
166
201
{
@@ -171,6 +206,14 @@ class ConfigureStoreChunkFromBuffer
171
206
}
172
207
};
173
208
209
+ /* * Configuration for a Load/Store operation with a buffer type.
210
+ *
211
+ * Only instantiated for pointer types where Load operations make sense (e.g. no
212
+ * const pointers and no unique pointers).
213
+ * \ref ConfigureStoreChunkFromBuffer is used otherwise.
214
+ *
215
+ * @tparam Ptr_Type The type of pointer used internally.
216
+ */
174
217
template <typename Ptr_Type>
175
218
class ConfigureLoadStoreFromBuffer
176
219
: public ConfigureStoreChunkFromBuffer<
0 commit comments