Skip to content

Commit f09930a

Browse files
committed
avoid overloaded{}; fix index binding ignored in certain cases
1 parent 8234bde commit f09930a

File tree

2 files changed

+135
-64
lines changed

2 files changed

+135
-64
lines changed

Framework/Core/include/Framework/ASoA.h

Lines changed: 123 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,13 +1147,7 @@ struct TableIterator : IP, C... {
11471147
template <typename... CL, typename TA>
11481148
void doSetCurrentIndex(framework::pack<CL...>, TA* current)
11491149
{
1150-
(framework::overloaded{
1151-
[&current, this]<is_index_column CI>
1152-
requires(!is_self_index_column<CI>)
1153-
() { CI::setCurrent(current); },
1154-
[]<typename CI>() {}}
1155-
.template operator()<CL>(),
1156-
...);
1150+
(doSetCurrentIndexImpl<CL>(current), ...);
11571151
}
11581152

11591153
template <typename CL>
@@ -1166,15 +1160,7 @@ struct TableIterator : IP, C... {
11661160
auto getIndexBindingsImpl(framework::pack<Cs...>) const
11671161
{
11681162
std::vector<o2::soa::Binding> result;
1169-
(framework::overloaded{
1170-
[this, &result]<is_index_column CI>
1171-
requires(!is_self_index_column<CI>)
1172-
() mutable {
1173-
result.emplace_back(CI::getCurrentRaw());
1174-
},
1175-
[]<typename CI>() {}}
1176-
.template operator()<Cs>(),
1177-
...);
1163+
(doGetIndexBindingImpl<Cs>(result), ...);
11781164
return result;
11791165
}
11801166

@@ -1190,32 +1176,22 @@ struct TableIterator : IP, C... {
11901176
}
11911177

11921178
template <typename... Cs>
1193-
void doSetCurrentIndexRaw(framework::pack<Cs...> p, std::vector<o2::soa::Binding>&& ptrs)
1179+
void doSetCurrentIndexRaw(framework::pack<Cs...> p, std::vector<o2::soa::Binding>&& bindings)
11941180
{
1195-
(framework::overloaded{
1196-
[&ptrs, p, this]<is_self_index_column CI>
1197-
requires(!is_self_index_column<CI>)
1198-
() { CI::setCurrentRaw(ptrs[framework::has_type_at_v<CI>(p)]); },
1199-
[]<typename CI>() {}}
1200-
.template operator()<Cs>(),
1201-
...);
1181+
(doSetCurrentIndexRawImpl<Cs>(bindings[framework::has_type_at_v<Cs>(p)]), ...);
12021182
}
12031183

12041184
template <typename... Cs, typename I>
12051185
void doSetCurrentInternal(framework::pack<Cs...>, I const* ptr)
12061186
{
12071187
o2::soa::Binding b;
12081188
b.bind(ptr);
1209-
(framework::overloaded{
1210-
[&ptr, &b, this]<is_self_index_column CI>() { CI::setCurrentRaw(b); },
1211-
[]<typename CI>() {}}
1212-
.template operator()<Cs>(),
1213-
...);
1189+
(doSetCurrentInternalImpl<Cs>(b), ...);
12141190
}
12151191

1216-
void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& ptrs)
1192+
void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& bindings)
12171193
{
1218-
doSetCurrentIndexRaw(all_columns{}, std::forward<std::vector<o2::soa::Binding>>(ptrs));
1194+
doSetCurrentIndexRaw(all_columns{}, std::forward<std::vector<o2::soa::Binding>>(bindings));
12191195
}
12201196

12211197
template <typename I>
@@ -1225,6 +1201,78 @@ struct TableIterator : IP, C... {
12251201
}
12261202

12271203
private:
1204+
/// Overloaded helpers for index manipulations
1205+
template <soa::is_index_column CL, typename TA>
1206+
requires(!soa::is_self_index_column<CL>)
1207+
void doSetCurrentIndexImpl(TA* current)
1208+
{
1209+
CL::setCurrent(current);
1210+
}
1211+
1212+
template <soa::is_column CL, typename TA>
1213+
requires(!soa::is_index_column<CL>)
1214+
void doSetCurrentIndexImpl(TA*)
1215+
{
1216+
}
1217+
1218+
template <soa::is_index_column CL>
1219+
requires(!soa::is_self_index_column<CL>)
1220+
auto doGetIndexBindingImpl(std::vector<o2::soa::Binding>& bindings) const
1221+
{
1222+
bindings.emplace_back(CL::getCurrentRaw());
1223+
}
1224+
1225+
template <soa::is_column CL>
1226+
requires(!soa::is_index_column<CL>)
1227+
auto doGetIndexBindingImpl(std::vector<o2::soa::Binding>& bindings) const
1228+
{
1229+
bindings.emplace_back();
1230+
}
1231+
1232+
template <soa::is_index_column CL>
1233+
requires(!soa::is_self_index_column<CL>)
1234+
void doSetCurrentIndexRawImpl(o2::soa::Binding const& b)
1235+
{
1236+
CL::setCurrentRaw(b);
1237+
}
1238+
1239+
template <soa::is_column CL>
1240+
requires(!soa::is_index_column<CL>)
1241+
void doSetCurrentIndexRawImpl(o2::soa::Binding const&)
1242+
{
1243+
}
1244+
1245+
template <soa::is_self_index_column CL>
1246+
void doSetCurrentInternalImpl(o2::soa::Binding const& b)
1247+
{
1248+
CL::setCurrentRaw(b);
1249+
}
1250+
1251+
template <soa::is_column CL>
1252+
requires(!soa::is_self_index_column<CL>)
1253+
void doSetCurrentInternalImpl(o2::soa::Binding const&)
1254+
{
1255+
}
1256+
1257+
///Overloaded helpers for column binding
1258+
template <soa::is_persistent_column CL>
1259+
void doBind()
1260+
{
1261+
CL::mColumnIterator.mCurrentPos = &this->mRowIndex;
1262+
}
1263+
1264+
template <soa::is_dynamic_column CL>
1265+
void doBind()
1266+
{
1267+
bindDynamicColumn<CL>(typename CL::bindings_t{});
1268+
}
1269+
1270+
template <soa::is_column CL>
1271+
requires(!soa::is_persistent_column<CL> && !soa::is_dynamic_column<CL>)
1272+
void doBind()
1273+
{
1274+
}
1275+
12281276
/// Helper to move at the end of columns which actually have an iterator.
12291277
template <typename... PC>
12301278
void doMoveToEnd(framework::pack<PC...>)
@@ -1237,12 +1285,7 @@ struct TableIterator : IP, C... {
12371285
void bind()
12381286
{
12391287
using namespace o2::soa;
1240-
auto f = framework::overloaded{
1241-
[this]<soa::is_persistent_column T>(T*) -> void { T::mColumnIterator.mCurrentPos = &this->mRowIndex; },
1242-
[this]<soa::is_dynamic_column T>(T*) -> void { bindDynamicColumn<T>(typename T::bindings_t{}); },
1243-
[this]<typename T>(T*) -> void {},
1244-
};
1245-
(f(static_cast<C*>(nullptr)), ...);
1288+
(doBind<C>(), ...);
12461289
if constexpr (has_index<C...>) {
12471290
this->setIndices(this->getIndices());
12481291
this->setOffsets(this->getOffsets());
@@ -1402,28 +1445,44 @@ static constexpr std::string getLabelFromTypeForKey(std::string const& key)
14021445
O2_BUILTIN_UNREACHABLE();
14031446
}
14041447

1448+
template <soa::is_index_column CL, typename B>
1449+
requires(!soa::is_self_index_column<CL>)
1450+
consteval static bool hasIndexToImpl()
1451+
{
1452+
return o2::soa::is_binding_compatible_v<B, typename CL::binding_t>();
1453+
}
1454+
1455+
template <soa::is_column CL, typename B>
1456+
requires(!soa::is_index_column<CL>)
1457+
consteval static bool hasIndexToImpl()
1458+
{
1459+
return false;
1460+
}
1461+
14051462
template <typename B, typename... C>
14061463
consteval static bool hasIndexTo(framework::pack<C...>&&)
14071464
{
1408-
return (framework::overloaded{
1409-
[]<is_index_column CI>
1410-
requires(!is_self_index_column<CI>)
1411-
() { return o2::soa::is_binding_compatible_v<B, typename CI::binding_t>(); },
1412-
[]<typename CI>() { return false; }}
1413-
.template operator()<C>() ||
1414-
...);
1465+
return (hasIndexToImpl<C, B>() || ...);
1466+
}
1467+
1468+
template <soa::is_index_column CL, typename B>
1469+
requires(!soa::is_self_index_column<CL>)
1470+
consteval static bool hasSortedIndexToImpl()
1471+
{
1472+
return CL::sorted && o2::soa::is_binding_compatible_v<B, typename CL::binding_t>();
1473+
}
1474+
1475+
template <soa::is_column CL, typename B>
1476+
requires(!soa::is_index_column<CL>)
1477+
consteval static bool hasSortedIndexToImpl()
1478+
{
1479+
return false;
14151480
}
14161481

14171482
template <typename B, typename... C>
14181483
consteval static bool hasSortedIndexTo(framework::pack<C...>&&)
14191484
{
1420-
return (framework::overloaded{
1421-
[]<is_index_column CI>
1422-
requires(!is_self_index_column<CI>)
1423-
() { return (CI::sorted && o2::soa::is_binding_compatible_v<B, typename CI::binding_t>()); },
1424-
[]<typename CI>() {}}
1425-
.template operator()<C>() ||
1426-
...);
1485+
return (hasSortedIndexToImpl<C, B>() || ...);
14271486
}
14281487

14291488
template <typename B, typename Z>
@@ -2090,14 +2149,22 @@ class Table
20902149
doBindInternalIndicesExplicit(columns_t{}, binding);
20912150
}
20922151

2152+
template <soa::is_self_index_column CL>
2153+
void doBindInternalIndicesExplicitImpl(o2::soa::Binding binding)
2154+
{
2155+
static_cast<CL>(mBegin).setCurrentRaw(binding);
2156+
}
2157+
2158+
template <soa::is_column CL>
2159+
requires(!soa::is_self_index_column<CL>)
2160+
void doBindInternalIndicesExplicitImpl(o2::soa::Binding)
2161+
{
2162+
}
2163+
20932164
template <typename... Cs>
20942165
void doBindInternalIndicesExplicit(framework::pack<Cs...>, o2::soa::Binding binding)
20952166
{
2096-
(framework::overloaded{
2097-
[this, &binding]<is_self_index_column CI>() { static_cast<CI>(mBegin).setCurrentRaw(binding); },
2098-
[]<typename CI>() {}}
2099-
.template operator()<Cs>(),
2100-
...);
2167+
(doBindInternalIndicesExplicitImpl<Cs>(binding), ...);
21012168
}
21022169

21032170
void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& ptrs)

Framework/Core/include/Framework/GroupedCombinations.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,22 @@ auto interleaveTuples(std::tuple<T1s...>& t1, std::tuple<T2s...>& t2)
3434
return interleaveTuplesImpl(t1, t2, std::index_sequence_for<T1s...>());
3535
}
3636

37-
template <soa::is_index_column T, typename G>
38-
requires(!soa::is_self_index_column<T>)
37+
template <soa::is_index_column T, soa::is_table G>
38+
requires(!soa::is_self_index_column<T> && o2::soa::is_binding_compatible_v<std::decay_t<G>, typename std::decay_t<T>::binding_t>())
3939
consteval auto isIndexTo()
4040
{
41-
if constexpr (o2::soa::is_binding_compatible_v<G, typename T::binding_t>()) {
42-
return std::true_type{};
43-
} else {
44-
return std::false_type{};
45-
}
41+
return std::true_type{};
4642
}
4743

48-
template <typename T, typename G>
44+
template <soa::is_index_column T, soa::is_table G>
45+
requires(!soa::is_self_index_column<T> && !o2::soa::is_binding_compatible_v<std::decay_t<G>, typename std::decay_t<T>::binding_t>())
46+
consteval auto isIndexTo()
47+
{
48+
return std::false_type{};
49+
}
50+
51+
template <soa::is_column T, soa::is_table G>
52+
requires(!soa::is_index_column<T>)
4953
consteval auto isIndexTo()
5054
{
5155
return std::false_type{};

0 commit comments

Comments
 (0)