@@ -145,6 +145,10 @@ namespace soagen::detail
145
145
SOAGEN_MAKE_NAMED_COLUMN (soagen::examples::entities, 2 , pos);
146
146
SOAGEN_MAKE_NAMED_COLUMN (soagen::examples::entities, 3 , orient);
147
147
148
+ template <>
149
+ struct is_soa_ <soagen::examples::entities> : std::true_type
150
+ {};
151
+
148
152
template <>
149
153
struct table_traits_type_ <soagen::examples::entities>
150
154
{
@@ -166,10 +170,6 @@ namespace soagen::detail
166
170
{
167
171
using type = table<table_traits_type<soagen::examples::entities>, allocator_type<soagen::examples::entities>>;
168
172
};
169
-
170
- template <>
171
- struct is_soa_ <soagen::examples::entities> : std::true_type
172
- {};
173
173
}
174
174
175
175
// clang-format on
@@ -208,6 +208,7 @@ namespace soagen::examples
208
208
public soagen::mixins::columns<entities>,
209
209
public soagen::mixins::rows<entities>,
210
210
public soagen::mixins::iterators<entities>,
211
+ public soagen::mixins::spans<entities>,
211
212
public soagen::mixins::swappable<entities>)
212
213
{
213
214
public:
@@ -240,12 +241,21 @@ namespace soagen::examples
240
241
// / @brief Row iterators returned by iterator functions.
241
242
using iterator = soagen::iterator_type<entities>;
242
243
243
- // / @brief Row iterators returned by const-qualified iterator functions.
244
- using const_iterator = soagen::iterator_type<const entities>;
245
-
246
244
// / @brief Row iterators returned by rvalue-qualified iterator functions.
247
245
using rvalue_iterator = soagen::iterator_type<entities&&>;
248
246
247
+ // / @brief Row iterators returned by const-qualified iterator functions.
248
+ using const_iterator = soagen::const_iterator_type<entities>;
249
+
250
+ // / @brief Regular (lvalue-qualified) span type.
251
+ using span_type = soagen::span_type<entities>;
252
+
253
+ // / @brief Rvalue-qualified span type.
254
+ using rvalue_span_type = soagen::span_type<entities&&>;
255
+
256
+ // / @brief Const-qualified span type.
257
+ using const_span_type = soagen::const_span_type<entities>;
258
+
249
259
// / @brief Regular (lvalue-qualified) row type used by this class.
250
260
using row_type = soagen::row_type<entities>;
251
261
@@ -332,7 +342,7 @@ namespace soagen::examples
332
342
return table_.get_allocator ();
333
343
}
334
344
335
- // / @name Underlying table access
345
+ // / @name Underlying table
336
346
// / @{
337
347
338
348
// / @brief Returns an lvalue reference to the underlying soagen::table.
@@ -358,21 +368,21 @@ namespace soagen::examples
358
368
359
369
// / @brief Returns an lvalue reference to the underlying soagen::table.
360
370
SOAGEN_PURE_INLINE_GETTER
361
- explicit constexpr operator table_type&() & noexcept
371
+ explicit constexpr operator table_type&() noexcept
362
372
{
363
373
return table_;
364
374
}
365
375
366
376
// / @brief Returns an rvalue reference to the underlying soagen::table.
367
377
SOAGEN_PURE_INLINE_GETTER
368
- explicit constexpr operator table_type&&() && noexcept
378
+ explicit constexpr operator table_type&&() noexcept
369
379
{
370
380
return static_cast <table_type&&>(table_);
371
381
}
372
382
373
383
// / @brief Returns a const lvalue reference to the underlying soagen::table.
374
384
SOAGEN_PURE_INLINE_GETTER
375
- explicit constexpr operator const table_type&() const & noexcept
385
+ explicit constexpr operator const table_type&() const noexcept
376
386
{
377
387
return table_;
378
388
}
@@ -451,7 +461,7 @@ namespace soagen::examples
451
461
noexcept (soagen::has_nothrow_unordered_erase_member<table_type>)
452
462
{
453
463
if (auto moved_pos = table_.unordered_erase (static_cast <size_type>(pos)); moved_pos)
454
- return iterator{ table_ , static_cast <difference_type>(*moved_pos) };
464
+ return iterator{ * this , static_cast <difference_type>(*moved_pos) };
455
465
return {};
456
466
}
457
467
@@ -490,7 +500,7 @@ namespace soagen::examples
490
500
noexcept (soagen::has_nothrow_unordered_erase_member<table_type>)
491
501
{
492
502
if (auto moved_pos = table_.unordered_erase (static_cast <size_type>(pos)); moved_pos)
493
- return const_iterator{ table_ , static_cast <difference_type>(*moved_pos) };
503
+ return const_iterator{ * this , static_cast <difference_type>(*moved_pos) };
494
504
return {};
495
505
}
496
506
@@ -875,7 +885,7 @@ namespace soagen::examples
875
885
876
886
// / @}
877
887
878
- // / @name Column access
888
+ // / @name Columns
879
889
// / @{
880
890
881
891
// / @brief Returns a pointer to the elements of a specific column.
@@ -1060,23 +1070,23 @@ namespace soagen::examples
1060
1070
1061
1071
// / @brief Returns an iterator to the first row in the table.
1062
1072
template <auto ... Columns>
1063
- constexpr soagen::iterator_type< const entities, Columns...> begin () const & noexcept ;
1073
+ constexpr soagen::const_iterator_type< entities, Columns...> begin () const & noexcept ;
1064
1074
1065
1075
// / @brief Returns an iterator to one-past-the-last row in the table.
1066
1076
template <auto ... Columns>
1067
- constexpr soagen::iterator_type< const entities, Columns...> end () const & noexcept ;
1077
+ constexpr soagen::const_iterator_type< entities, Columns...> end () const & noexcept ;
1068
1078
1069
1079
// / @brief Returns an iterator to the first row in the table.
1070
1080
template <auto ... Columns>
1071
- constexpr soagen::iterator_type< const entities, Columns...> cbegin () const noexcept ;
1081
+ constexpr soagen::const_iterator_type< entities, Columns...> cbegin () const noexcept ;
1072
1082
1073
1083
// / @brief Returns an iterator to one-past-the-last row in the table.
1074
1084
template <auto ... Columns>
1075
- constexpr soagen::iterator_type< const entities, Columns...> cend () const noexcept ;
1085
+ constexpr soagen::const_iterator_type< entities, Columns...> cend () const noexcept ;
1076
1086
1077
1087
// / @}
1078
1088
1079
- // / @name Row access
1089
+ // / @name Rows
1080
1090
// / @{
1081
1091
1082
1092
// / @brief Returns the row at the given index.
@@ -1141,6 +1151,23 @@ namespace soagen::examples
1141
1151
1142
1152
// / @}
1143
1153
1154
+ // / @name Spans
1155
+ // / @{
1156
+
1157
+ // / @brief Returns a span of (some part of) the table.
1158
+ span_type subspan (size_type start, size_type count = static_cast <size_type>(-1 )) & noexcept ;
1159
+
1160
+ // / @brief Returns an rvalue-qualified span of (some part of) the table.
1161
+ rvalue_span_type subspan (size_type start, size_type count = static_cast <size_type>(-1 )) && noexcept ;
1162
+
1163
+ // / @brief Returns a const-qualified span of (some part of) the table.
1164
+ const_span_type subspan (size_type start, size_type count = static_cast <size_type>(-1 )) const & noexcept ;
1165
+
1166
+ // / @brief Returns a const-qualified span of (some part of) the table.
1167
+ const_span_type const_subspan (size_type start, size_type count = static_cast <size_type>(-1 )) const noexcept ;
1168
+
1169
+ // / @}
1170
+
1144
1171
#endif
1145
1172
};
1146
1173
0 commit comments