Skip to content

Commit c67d408

Browse files
committed
use requirements instead of if-constexpr
1 parent 4d3fa45 commit c67d408

File tree

1 file changed

+30
-12
lines changed
  • Framework/Core/include/Framework

1 file changed

+30
-12
lines changed

Framework/Core/include/Framework/ASoA.h

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,10 @@ struct TableIterator : IP, C... {
11471147
template <typename... CL, typename TA>
11481148
void doSetCurrentIndex(framework::pack<CL...>, TA* current)
11491149
{
1150-
([&current, this]() { if constexpr (is_index_column<CL> && !is_self_index_column<CL>) {CL::setCurrent(current);} }(), ...);
1150+
(framework::overloaded{
1151+
[&current, this]<is_index_column CI> requires(!is_self_index_column<CI>) () { CI::setCurrent(current); },
1152+
[]<typename CI>(){}
1153+
}.template operator()<CL>(), ...);
11511154
}
11521155

11531156
template <typename CL>
@@ -1160,12 +1163,12 @@ struct TableIterator : IP, C... {
11601163
auto getIndexBindingsImpl(framework::pack<Cs...>) const
11611164
{
11621165
std::vector<o2::soa::Binding> result;
1163-
([this, &result]() {
1164-
if constexpr (is_index_column<Cs> && !is_self_index_column<Cs>) {
1165-
result.emplace_back(static_cast<Cs const&>(*this).getCurrentRaw());
1166-
}
1167-
}(),
1168-
...);
1166+
(framework::overloaded{
1167+
[this, &result]<is_index_column CI> requires(!is_self_index_column<CI>) () mutable {
1168+
result.emplace_back(CI::getCurrentRaw());
1169+
},
1170+
[]<typename CI>(){}
1171+
}.template operator()<Cs>(), ...);
11691172
return result;
11701173
}
11711174

@@ -1183,15 +1186,21 @@ struct TableIterator : IP, C... {
11831186
template <typename... Cs>
11841187
void doSetCurrentIndexRaw(framework::pack<Cs...> p, std::vector<o2::soa::Binding>&& ptrs)
11851188
{
1186-
([&ptrs, p, this]() { if constexpr (is_index_column<Cs> && !is_self_index_column<Cs>) { Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]); } }(), ...);
1189+
(framework::overloaded{
1190+
[&ptrs, p, this]<is_self_index_column CI> requires(!is_self_index_column<CI>) () { CI::setCurrentRaw(ptrs[framework::has_type_at_v<CI>(p)]); },
1191+
[]<typename CI>(){}
1192+
}.template operator()<Cs>(), ...);
11871193
}
11881194

11891195
template <typename... Cs, typename I>
11901196
void doSetCurrentInternal(framework::pack<Cs...>, I const* ptr)
11911197
{
11921198
o2::soa::Binding b;
11931199
b.bind(ptr);
1194-
([&ptr, &b, this]() { if constexpr (is_self_index_column<Cs>) { Cs::setCurrentRaw(b); } }(), ...);
1200+
(framework::overloaded{
1201+
[&ptr, &b, this]<is_self_index_column CI>() { CI::setCurrentRaw(b); },
1202+
[]<typename CI>(){}
1203+
}.template operator()<Cs>(), ...);
11951204
}
11961205

11971206
void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& ptrs)
@@ -1386,13 +1395,19 @@ static constexpr std::string getLabelFromTypeForKey(std::string const& key)
13861395
template <typename B, typename... C>
13871396
consteval static bool hasIndexTo(framework::pack<C...>&&)
13881397
{
1389-
return ([]() { if constexpr (is_index_column<C> && !is_self_index_column<C>) { return o2::soa::is_binding_compatible_v<B, typename C::binding_t>(); } else { return false; } }() || ...);
1398+
return (framework::overloaded{
1399+
[]<is_index_column CI> requires(!is_self_index_column<CI>) () { return o2::soa::is_binding_compatible_v<B, typename CI::binding_t>(); },
1400+
[]<typename CI>(){ return false; }
1401+
}.template operator()<C>() || ...);
13901402
}
13911403

13921404
template <typename B, typename... C>
13931405
consteval static bool hasSortedIndexTo(framework::pack<C...>&&)
13941406
{
1395-
return ([]() {if constexpr (is_index_column<C> && !is_self_index_column<C>) { return (C::sorted && o2::soa::is_binding_compatible_v<B, typename C::binding_t>()); } else { return false; } }() || ...);
1407+
return (framework::overloaded{
1408+
[]<is_index_column CI> requires(!is_self_index_column<CI>) () {return (CI::sorted && o2::soa::is_binding_compatible_v<B, typename CI::binding_t>()); },
1409+
[]<typename CI>(){}
1410+
}.template operator()<C>() || ...);
13961411
}
13971412

13981413
template <typename B, typename Z>
@@ -2062,7 +2077,10 @@ class Table
20622077
template <typename... Cs>
20632078
void doBindInternalIndicesExplicit(framework::pack<Cs...>, o2::soa::Binding binding)
20642079
{
2065-
([this, &binding]() { if constexpr (is_self_index_column<Cs>) { static_cast<Cs>(mBegin).setCurrentRaw(binding); } }(), ...);
2080+
(framework::overloaded{
2081+
[this, &binding]<is_self_index_column CI>() { static_cast<CI>(mBegin).setCurrentRaw(binding); },
2082+
[]<typename CI>(){}
2083+
}.template operator()<Cs>(), ...);
20662084
}
20672085

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

0 commit comments

Comments
 (0)