Skip to content

Commit 74a0462

Browse files
committed
use requirements instead of if-constexpr
1 parent e9daf4c commit 74a0462

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

11451148
template <typename CL>
@@ -1152,12 +1155,12 @@ struct TableIterator : IP, C... {
11521155
auto getIndexBindingsImpl(framework::pack<Cs...>) const
11531156
{
11541157
std::vector<o2::soa::Binding> result;
1155-
([this, &result]() {
1156-
if constexpr (is_index_column<Cs> && !is_self_index_column<Cs>) {
1157-
result.emplace_back(static_cast<Cs const&>(*this).getCurrentRaw());
1158-
}
1159-
}(),
1160-
...);
1158+
(framework::overloaded{
1159+
[this, &result]<is_index_column CI> requires(!is_self_index_column<CI>) () mutable {
1160+
result.emplace_back(CI::getCurrentRaw());
1161+
},
1162+
[]<typename CI>(){}
1163+
}.template operator()<Cs>(), ...);
11611164
return result;
11621165
}
11631166

@@ -1175,15 +1178,21 @@ struct TableIterator : IP, C... {
11751178
template <typename... Cs>
11761179
void doSetCurrentIndexRaw(framework::pack<Cs...> p, std::vector<o2::soa::Binding>&& ptrs)
11771180
{
1178-
([&ptrs, p, this]() { if constexpr (is_index_column<Cs> && !is_self_index_column<Cs>) { Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]); } }(), ...);
1181+
(framework::overloaded{
1182+
[&ptrs, p, this]<is_self_index_column CI> requires(!is_self_index_column<CI>) () { CI::setCurrentRaw(ptrs[framework::has_type_at_v<CI>(p)]); },
1183+
[]<typename CI>(){}
1184+
}.template operator()<Cs>(), ...);
11791185
}
11801186

11811187
template <typename... Cs, typename I>
11821188
void doSetCurrentInternal(framework::pack<Cs...>, I const* ptr)
11831189
{
11841190
o2::soa::Binding b;
11851191
b.bind(ptr);
1186-
([&ptr, &b, this]() { if constexpr (is_self_index_column<Cs>) { Cs::setCurrentRaw(b); } }(), ...);
1192+
(framework::overloaded{
1193+
[&ptr, &b, this]<is_self_index_column CI>() { CI::setCurrentRaw(b); },
1194+
[]<typename CI>(){}
1195+
}.template operator()<Cs>(), ...);
11871196
}
11881197

11891198
void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& ptrs)
@@ -1378,13 +1387,19 @@ static constexpr std::string getLabelFromTypeForKey(std::string const& key)
13781387
template <typename B, typename... C>
13791388
consteval static bool hasIndexTo(framework::pack<C...>&&)
13801389
{
1381-
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; } }() || ...);
1390+
return (framework::overloaded{
1391+
[]<is_index_column CI> requires(!is_self_index_column<CI>) () { return o2::soa::is_binding_compatible_v<B, typename CI::binding_t>(); },
1392+
[]<typename CI>(){ return false; }
1393+
}.template operator()<C>() || ...);
13821394
}
13831395

13841396
template <typename B, typename... C>
13851397
consteval static bool hasSortedIndexTo(framework::pack<C...>&&)
13861398
{
1387-
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; } }() || ...);
1399+
return (framework::overloaded{
1400+
[]<is_index_column CI> requires(!is_self_index_column<CI>) () {return (CI::sorted && o2::soa::is_binding_compatible_v<B, typename CI::binding_t>()); },
1401+
[]<typename CI>(){}
1402+
}.template operator()<C>() || ...);
13881403
}
13891404

13901405
template <typename B, typename Z>
@@ -2069,7 +2084,10 @@ class Table
20692084
template <typename... Cs>
20702085
void doBindInternalIndicesExplicit(framework::pack<Cs...>, o2::soa::Binding binding)
20712086
{
2072-
([this, &binding]() { if constexpr (is_self_index_column<Cs>) { static_cast<Cs>(mBegin).setCurrentRaw(binding); } }(), ...);
2087+
(framework::overloaded{
2088+
[this, &binding]<is_self_index_column CI>() { static_cast<CI>(mBegin).setCurrentRaw(binding); },
2089+
[]<typename CI>(){}
2090+
}.template operator()<Cs>(), ...);
20732091
}
20742092

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

0 commit comments

Comments
 (0)