Skip to content

Commit 0684d49

Browse files
committed
use requirements instead of if-constexpr
1 parent 6ee07cb commit 0684d49

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
@@ -1144,7 +1144,10 @@ struct TableIterator : IP, C... {
11441144
template <typename... CL, typename TA>
11451145
void doSetCurrentIndex(framework::pack<CL...>, TA* current)
11461146
{
1147-
([&current, this]() { if constexpr (is_index_column<CL> && !is_self_index_column<CL>) {CL::setCurrent(current);} }(), ...);
1147+
(framework::overloaded{
1148+
[&current, this]<is_index_column CI> requires(!is_self_index_column<CI>) () { CI::setCurrent(current); },
1149+
[]<typename CI>(){}
1150+
}.template operator()<CL>(), ...);
11481151
}
11491152

11501153
template <typename CL>
@@ -1157,12 +1160,12 @@ struct TableIterator : IP, C... {
11571160
auto getIndexBindingsImpl(framework::pack<Cs...>) const
11581161
{
11591162
std::vector<o2::soa::Binding> result;
1160-
([this, &result]() {
1161-
if constexpr (is_index_column<Cs> && !is_self_index_column<Cs>) {
1162-
result.emplace_back(static_cast<Cs const&>(*this).getCurrentRaw());
1163-
}
1164-
}(),
1165-
...);
1163+
(framework::overloaded{
1164+
[this, &result]<is_index_column CI> requires(!is_self_index_column<CI>) () mutable {
1165+
result.emplace_back(CI::getCurrentRaw());
1166+
},
1167+
[]<typename CI>(){}
1168+
}.template operator()<Cs>(), ...);
11661169
return result;
11671170
}
11681171

@@ -1180,15 +1183,21 @@ struct TableIterator : IP, C... {
11801183
template <typename... Cs>
11811184
void doSetCurrentIndexRaw(framework::pack<Cs...> p, std::vector<o2::soa::Binding>&& ptrs)
11821185
{
1183-
([&ptrs, p, this]() { if constexpr (is_index_column<Cs> && !is_self_index_column<Cs>) { Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]); } }(), ...);
1186+
(framework::overloaded{
1187+
[&ptrs, p, this]<is_self_index_column CI> requires(!is_self_index_column<CI>) () { CI::setCurrentRaw(ptrs[framework::has_type_at_v<CI>(p)]); },
1188+
[]<typename CI>(){}
1189+
}.template operator()<Cs>(), ...);
11841190
}
11851191

11861192
template <typename... Cs, typename I>
11871193
void doSetCurrentInternal(framework::pack<Cs...>, I const* ptr)
11881194
{
11891195
o2::soa::Binding b;
11901196
b.bind(ptr);
1191-
([&ptr, &b, this]() { if constexpr (is_self_index_column<Cs>) { Cs::setCurrentRaw(b); } }(), ...);
1197+
(framework::overloaded{
1198+
[&ptr, &b, this]<is_self_index_column CI>() { CI::setCurrentRaw(b); },
1199+
[]<typename CI>(){}
1200+
}.template operator()<Cs>(), ...);
11921201
}
11931202

11941203
void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& ptrs)
@@ -1383,13 +1392,19 @@ static constexpr std::string getLabelFromTypeForKey(std::string const& key)
13831392
template <typename B, typename... C>
13841393
consteval static bool hasIndexTo(framework::pack<C...>&&)
13851394
{
1386-
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; } }() || ...);
1395+
return (framework::overloaded{
1396+
[]<is_index_column CI> requires(!is_self_index_column<CI>) () { return o2::soa::is_binding_compatible_v<B, typename CI::binding_t>(); },
1397+
[]<typename CI>(){ return false; }
1398+
}.template operator()<C>() || ...);
13871399
}
13881400

13891401
template <typename B, typename... C>
13901402
consteval static bool hasSortedIndexTo(framework::pack<C...>&&)
13911403
{
1392-
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; } }() || ...);
1404+
return (framework::overloaded{
1405+
[]<is_index_column CI> requires(!is_self_index_column<CI>) () {return (CI::sorted && o2::soa::is_binding_compatible_v<B, typename CI::binding_t>()); },
1406+
[]<typename CI>(){}
1407+
}.template operator()<C>() || ...);
13931408
}
13941409

13951410
template <typename B, typename Z>
@@ -2059,7 +2074,10 @@ class Table
20592074
template <typename... Cs>
20602075
void doBindInternalIndicesExplicit(framework::pack<Cs...>, o2::soa::Binding binding)
20612076
{
2062-
([this, &binding]() { if constexpr (is_self_index_column<Cs>) { static_cast<Cs>(mBegin).setCurrentRaw(binding); } }(), ...);
2077+
(framework::overloaded{
2078+
[this, &binding]<is_self_index_column CI>() { static_cast<CI>(mBegin).setCurrentRaw(binding); },
2079+
[]<typename CI>(){}
2080+
}.template operator()<Cs>(), ...);
20632081
}
20642082

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

0 commit comments

Comments
 (0)