Skip to content

Commit 334d186

Browse files
committed
avoid overloaded{}; fix index binding ignored in certain cases
1 parent 644b18d commit 334d186

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
@@ -1139,13 +1139,7 @@ struct TableIterator : IP, C... {
11391139
template <typename... CL, typename TA>
11401140
void doSetCurrentIndex(framework::pack<CL...>, TA* current)
11411141
{
1142-
(framework::overloaded{
1143-
[&current, this]<is_index_column CI>
1144-
requires(!is_self_index_column<CI>)
1145-
() { CI::setCurrent(current); },
1146-
[]<typename CI>() {}}
1147-
.template operator()<CL>(),
1148-
...);
1142+
(doSetCurrentIndexImpl<CL>(current), ...);
11491143
}
11501144

11511145
template <typename CL>
@@ -1158,15 +1152,7 @@ struct TableIterator : IP, C... {
11581152
auto getIndexBindingsImpl(framework::pack<Cs...>) const
11591153
{
11601154
std::vector<o2::soa::Binding> result;
1161-
(framework::overloaded{
1162-
[this, &result]<is_index_column CI>
1163-
requires(!is_self_index_column<CI>)
1164-
() mutable {
1165-
result.emplace_back(CI::getCurrentRaw());
1166-
},
1167-
[]<typename CI>() {}}
1168-
.template operator()<Cs>(),
1169-
...);
1155+
(doGetIndexBindingImpl<Cs>(result), ...);
11701156
return result;
11711157
}
11721158

@@ -1182,32 +1168,22 @@ struct TableIterator : IP, C... {
11821168
}
11831169

11841170
template <typename... Cs>
1185-
void doSetCurrentIndexRaw(framework::pack<Cs...> p, std::vector<o2::soa::Binding>&& ptrs)
1171+
void doSetCurrentIndexRaw(framework::pack<Cs...> p, std::vector<o2::soa::Binding>&& bindings)
11861172
{
1187-
(framework::overloaded{
1188-
[&ptrs, p, this]<is_self_index_column CI>
1189-
requires(!is_self_index_column<CI>)
1190-
() { CI::setCurrentRaw(ptrs[framework::has_type_at_v<CI>(p)]); },
1191-
[]<typename CI>() {}}
1192-
.template operator()<Cs>(),
1193-
...);
1173+
(doSetCurrentIndexRawImpl<Cs>(bindings[framework::has_type_at_v<Cs>(p)]), ...);
11941174
}
11951175

11961176
template <typename... Cs, typename I>
11971177
void doSetCurrentInternal(framework::pack<Cs...>, I const* ptr)
11981178
{
11991179
o2::soa::Binding b;
12001180
b.bind(ptr);
1201-
(framework::overloaded{
1202-
[&ptr, &b, this]<is_self_index_column CI>() { CI::setCurrentRaw(b); },
1203-
[]<typename CI>() {}}
1204-
.template operator()<Cs>(),
1205-
...);
1181+
(doSetCurrentInternalImpl<Cs>(b), ...);
12061182
}
12071183

1208-
void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& ptrs)
1184+
void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& bindings)
12091185
{
1210-
doSetCurrentIndexRaw(all_columns{}, std::forward<std::vector<o2::soa::Binding>>(ptrs));
1186+
doSetCurrentIndexRaw(all_columns{}, std::forward<std::vector<o2::soa::Binding>>(bindings));
12111187
}
12121188

12131189
template <typename I>
@@ -1217,6 +1193,78 @@ struct TableIterator : IP, C... {
12171193
}
12181194

12191195
private:
1196+
/// Overloaded helpers for index manipulations
1197+
template <soa::is_index_column CL, typename TA>
1198+
requires(!soa::is_self_index_column<CL>)
1199+
void doSetCurrentIndexImpl(TA* current)
1200+
{
1201+
CL::setCurrent(current);
1202+
}
1203+
1204+
template <soa::is_column CL, typename TA>
1205+
requires(!soa::is_index_column<CL>)
1206+
void doSetCurrentIndexImpl(TA*)
1207+
{
1208+
}
1209+
1210+
template <soa::is_index_column CL>
1211+
requires(!soa::is_self_index_column<CL>)
1212+
auto doGetIndexBindingImpl(std::vector<o2::soa::Binding>& bindings) const
1213+
{
1214+
bindings.emplace_back(CL::getCurrentRaw());
1215+
}
1216+
1217+
template <soa::is_column CL>
1218+
requires(!soa::is_index_column<CL>)
1219+
auto doGetIndexBindingImpl(std::vector<o2::soa::Binding>& bindings) const
1220+
{
1221+
bindings.emplace_back();
1222+
}
1223+
1224+
template <soa::is_index_column CL>
1225+
requires(!soa::is_self_index_column<CL>)
1226+
void doSetCurrentIndexRawImpl(o2::soa::Binding const& b)
1227+
{
1228+
CL::setCurrentRaw(b);
1229+
}
1230+
1231+
template <soa::is_column CL>
1232+
requires(!soa::is_index_column<CL>)
1233+
void doSetCurrentIndexRawImpl(o2::soa::Binding const&)
1234+
{
1235+
}
1236+
1237+
template <soa::is_self_index_column CL>
1238+
void doSetCurrentInternalImpl(o2::soa::Binding const& b)
1239+
{
1240+
CL::setCurrentRaw(b);
1241+
}
1242+
1243+
template <soa::is_column CL>
1244+
requires(!soa::is_self_index_column<CL>)
1245+
void doSetCurrentInternalImpl(o2::soa::Binding const&)
1246+
{
1247+
}
1248+
1249+
///Overloaded helpers for column binding
1250+
template <soa::is_persistent_column CL>
1251+
void doBind()
1252+
{
1253+
CL::mColumnIterator.mCurrentPos = &this->mRowIndex;
1254+
}
1255+
1256+
template <soa::is_dynamic_column CL>
1257+
void doBind()
1258+
{
1259+
bindDynamicColumn<CL>(typename CL::bindings_t{});
1260+
}
1261+
1262+
template <soa::is_column CL>
1263+
requires(!soa::is_persistent_column<CL> && !soa::is_dynamic_column<CL>)
1264+
void doBind()
1265+
{
1266+
}
1267+
12201268
/// Helper to move at the end of columns which actually have an iterator.
12211269
template <typename... PC>
12221270
void doMoveToEnd(framework::pack<PC...>)
@@ -1229,12 +1277,7 @@ struct TableIterator : IP, C... {
12291277
void bind()
12301278
{
12311279
using namespace o2::soa;
1232-
auto f = framework::overloaded{
1233-
[this]<soa::is_persistent_column T>(T*) -> void { T::mColumnIterator.mCurrentPos = &this->mRowIndex; },
1234-
[this]<soa::is_dynamic_column T>(T*) -> void { bindDynamicColumn<T>(typename T::bindings_t{}); },
1235-
[this]<typename T>(T*) -> void {},
1236-
};
1237-
(f(static_cast<C*>(nullptr)), ...);
1280+
(doBind<C>(), ...);
12381281
if constexpr (has_index<C...>) {
12391282
this->setIndices(this->getIndices());
12401283
this->setOffsets(this->getOffsets());
@@ -1394,28 +1437,44 @@ static constexpr std::string getLabelFromTypeForKey(std::string const& key)
13941437
O2_BUILTIN_UNREACHABLE();
13951438
}
13961439

1440+
template <soa::is_index_column CL, typename B>
1441+
requires(!soa::is_self_index_column<CL>)
1442+
consteval static bool hasIndexToImpl()
1443+
{
1444+
return o2::soa::is_binding_compatible_v<B, typename CL::binding_t>();
1445+
}
1446+
1447+
template <soa::is_column CL, typename B>
1448+
requires(!soa::is_index_column<CL>)
1449+
consteval static bool hasIndexToImpl()
1450+
{
1451+
return false;
1452+
}
1453+
13971454
template <typename B, typename... C>
13981455
consteval static bool hasIndexTo(framework::pack<C...>&&)
13991456
{
1400-
return (framework::overloaded{
1401-
[]<is_index_column CI>
1402-
requires(!is_self_index_column<CI>)
1403-
() { return o2::soa::is_binding_compatible_v<B, typename CI::binding_t>(); },
1404-
[]<typename CI>() { return false; }}
1405-
.template operator()<C>() ||
1406-
...);
1457+
return (hasIndexToImpl<C, B>() || ...);
1458+
}
1459+
1460+
template <soa::is_index_column CL, typename B>
1461+
requires(!soa::is_self_index_column<CL>)
1462+
consteval static bool hasSortedIndexToImpl()
1463+
{
1464+
return CL::sorted && o2::soa::is_binding_compatible_v<B, typename CL::binding_t>();
1465+
}
1466+
1467+
template <soa::is_column CL, typename B>
1468+
requires(!soa::is_index_column<CL>)
1469+
consteval static bool hasSortedIndexToImpl()
1470+
{
1471+
return false;
14071472
}
14081473

14091474
template <typename B, typename... C>
14101475
consteval static bool hasSortedIndexTo(framework::pack<C...>&&)
14111476
{
1412-
return (framework::overloaded{
1413-
[]<is_index_column CI>
1414-
requires(!is_self_index_column<CI>)
1415-
() { return (CI::sorted && o2::soa::is_binding_compatible_v<B, typename CI::binding_t>()); },
1416-
[]<typename CI>() {}}
1417-
.template operator()<C>() ||
1418-
...);
1477+
return (hasSortedIndexToImpl<C, B>() || ...);
14191478
}
14201479

14211480
template <typename B, typename Z>
@@ -2097,14 +2156,22 @@ class Table
20972156
doBindInternalIndicesExplicit(columns_t{}, binding);
20982157
}
20992158

2159+
template <soa::is_self_index_column CL>
2160+
void doBindInternalIndicesExplicitImpl(o2::soa::Binding binding)
2161+
{
2162+
static_cast<CL>(mBegin).setCurrentRaw(binding);
2163+
}
2164+
2165+
template <soa::is_column CL>
2166+
requires(!soa::is_self_index_column<CL>)
2167+
void doBindInternalIndicesExplicitImpl(o2::soa::Binding)
2168+
{
2169+
}
2170+
21002171
template <typename... Cs>
21012172
void doBindInternalIndicesExplicit(framework::pack<Cs...>, o2::soa::Binding binding)
21022173
{
2103-
(framework::overloaded{
2104-
[this, &binding]<is_self_index_column CI>() { static_cast<CI>(mBegin).setCurrentRaw(binding); },
2105-
[]<typename CI>() {}}
2106-
.template operator()<Cs>(),
2107-
...);
2174+
(doBindInternalIndicesExplicitImpl<Cs>(binding), ...);
21082175
}
21092176

21102177
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)