@@ -1034,21 +1034,15 @@ concept can_bind = requires(T&& t) {
10341034template <typename ... C>
10351035concept has_index = (is_indexing_column<C> || ...);
10361036
1037- template <is_index_column C>
1038- requires (!is_self_index_column<C>)
1039- consteval auto getBinding () -> typename C::binding_t
1040- {
1041- }
1042-
1043- template <typename C>
1044- consteval auto getBinding () -> void
1045- {
1046- }
1047-
10481037template <typename T, typename ... Cs>
10491038consteval auto inBindings (framework::pack<Cs...>)
10501039{
1051- return framework::has_type_at_v<T>(framework::pack<decltype (getBinding<Cs>())...>{});
1040+ return framework::has_type_at_v<T>(framework::pack<decltype ([]<typename C>(){
1041+ if constexpr (is_index_column<C> && !is_self_index_column<C>) {
1042+ return std::declval<typename C::binding_t >();
1043+ } else {
1044+ return ;
1045+ } }.template operator ()<Cs>())...>{});
10521046}
10531047
10541048template <typename D, typename O, typename IP, typename ... C>
@@ -1153,108 +1147,55 @@ struct TableIterator : IP, C... {
11531147 return CL::getCurrentRaw ();
11541148 }
11551149
1156- auto getIndexBindings () const
1150+ auto getIndexBindings () -> std::vector<o2::soa::Binding> const
11571151 {
1158- std::vector<o2::soa::Binding> result;
1159- (doGetIndexBindingImpl<C>(result), ...);
1160- return result;
1152+ return {[]<soa::is_column CL>(){
1153+ if constexpr (soa::is_index_column<CL> && !soa::is_self_index_column<CL>) {
1154+ return o2::soa::Binding{CL::getCurrentRaw ()};
1155+ } else {
1156+ return o2::soa::Binding{};
1157+ }
1158+ }.template operator ()<C>()...};
11611159 }
11621160
11631161 template <typename ... TA>
11641162 void bindExternalIndices (TA*... current)
11651163 {
11661164 ([this ]<typename ... Cs, typename TT>(framework::pack<Cs...>, TT* t) {
1167- (doSetCurrentIndexImpl<Cs>(t), ...);
1165+ ([]<soa::is_column CL, typename TI>(TI* c){
1166+ if constexpr (soa::is_index_column<CL> && !soa::is_self_index_column<CL>) {
1167+ CL::setCurrent (c);
1168+ }
1169+ }.template operator ()<Cs, TT>(t), ...);
11681170 }(framework::pack<C...>{}, current),
11691171 ...);
11701172 }
11711173
11721174 void bindExternalIndicesRaw (std::vector<o2::soa::Binding>&& bindings)
11731175 {
1174- (doSetCurrentIndexRawImpl<C>(bindings[framework::has_type_at_v<C>(framework::pack<C...>{})]), ...);
1176+ [&bindings]<size_t ... Is>(std::index_sequence<Is...>){
1177+ ([&bindings](){
1178+ using column = typename framework::pack_element_t <Is, framework::pack<C...>>;
1179+ if constexpr (soa::is_index_column<column> && !soa::is_self_index_column<column>) {
1180+ column::setCurrentRaw (bindings[Is]);
1181+ }
1182+ }(), ...);
1183+ }(std::make_index_sequence<sizeof ...(C)>());
11751184 }
11761185
11771186 template <typename I>
11781187 void bindInternalIndices (I const * table)
11791188 {
11801189 o2::soa::Binding b;
11811190 b.bind (table);
1182- (doSetCurrentInternalImpl<C>(b), ...);
1191+ ([]<soa::is_column CL>(o2::soa::Binding const & bb){
1192+ if constexpr (soa::is_self_index_column<CL>) {
1193+ CL::setCurrentRaw (bb);
1194+ }
1195+ }.template operator ()<C>(b), ...);
11831196 }
11841197
11851198 private:
1186- // / Overloaded helpers for index manipulations
1187- template <soa::is_index_column CL, typename TA>
1188- requires (!soa::is_self_index_column<CL>)
1189- void doSetCurrentIndexImpl (TA* current)
1190- {
1191- CL::setCurrent (current);
1192- }
1193-
1194- template <soa::is_column CL, typename TA>
1195- requires (!soa::is_index_column<CL>)
1196- void doSetCurrentIndexImpl (TA*)
1197- {
1198- }
1199-
1200- template <soa::is_index_column CL>
1201- requires (!soa::is_self_index_column<CL>)
1202- auto doGetIndexBindingImpl (std::vector<o2::soa::Binding>& bindings) const
1203- {
1204- bindings.emplace_back (CL::getCurrentRaw ());
1205- }
1206-
1207- template <soa::is_column CL>
1208- requires (!soa::is_index_column<CL>)
1209- auto doGetIndexBindingImpl (std::vector<o2::soa::Binding>& bindings) const
1210- {
1211- bindings.emplace_back ();
1212- }
1213-
1214- template <soa::is_index_column CL>
1215- requires (!soa::is_self_index_column<CL>)
1216- void doSetCurrentIndexRawImpl (o2::soa::Binding const & b)
1217- {
1218- CL::setCurrentRaw (b);
1219- }
1220-
1221- template <soa::is_column CL>
1222- requires (!soa::is_index_column<CL>)
1223- void doSetCurrentIndexRawImpl (o2::soa::Binding const &)
1224- {
1225- }
1226-
1227- template <soa::is_self_index_column CL>
1228- void doSetCurrentInternalImpl (o2::soa::Binding const & b)
1229- {
1230- CL::setCurrentRaw (b);
1231- }
1232-
1233- template <soa::is_column CL>
1234- requires (!soa::is_self_index_column<CL>)
1235- void doSetCurrentInternalImpl (o2::soa::Binding const &)
1236- {
1237- }
1238-
1239- // / Overloaded helpers for column binding
1240- template <soa::is_persistent_column CL>
1241- void doBind ()
1242- {
1243- CL::mColumnIterator .mCurrentPos = &this ->mRowIndex ;
1244- }
1245-
1246- template <soa::is_dynamic_column CL>
1247- void doBind ()
1248- {
1249- bindDynamicColumn<CL>(typename CL::bindings_t {});
1250- }
1251-
1252- template <soa::is_column CL>
1253- requires (!soa::is_persistent_column<CL> && !soa::is_dynamic_column<CL>)
1254- void doBind ()
1255- {
1256- }
1257-
12581199 // / Helper to move at the end of columns which actually have an iterator.
12591200 template <typename ... PC>
12601201 void doMoveToEnd (framework::pack<PC...>)
@@ -1267,37 +1208,35 @@ struct TableIterator : IP, C... {
12671208 void bind ()
12681209 {
12691210 using namespace o2 ::soa;
1270- (doBind<C>(), ...);
1211+ ([this ]<soa::is_column CL>(){
1212+ if constexpr (soa::is_persistent_column<CL>) {
1213+ CL::mColumnIterator .mCurrentPos = &this ->mRowIndex ;
1214+ } else if constexpr (soa::is_dynamic_column<CL>) {
1215+ bindDynamicColumn<CL>(typename CL::bindings_t {});
1216+ }
1217+ }.template operator ()<C>(), ...);
1218+
12711219 if constexpr (has_index<C...>) {
12721220 this ->setIndices (this ->getIndices ());
12731221 this ->setOffsets (this ->getOffsets ());
12741222 }
12751223 }
12761224
1277- template <typename DC, typename ... B>
1278- auto bindDynamicColumn (framework::pack<B...>)
1279- {
1280- DC::boundIterators = std::make_tuple (getDynamicBinding<B>()...);
1281- }
1282-
12831225 // Sometimes dynamic columns are defined for tables in
12841226 // the hope that it will be joined / extended with another one which provides
12851227 // the full set of bindings. This is to avoid a compilation
12861228 // error if constructor for the table or any other thing involving a missing
12871229 // binding is preinstanciated.
1288- template <typename B>
1289- requires (can_bind<self_t , B>)
1290- decltype (auto ) getDynamicBinding()
1291- {
1292- static_assert (std::same_as<decltype (&(static_cast <B*>(this )->mColumnIterator )), std::decay_t <decltype (B::mColumnIterator )>*>, " foo" );
1293- return &(static_cast <B*>(this )->mColumnIterator );
1294- // return static_cast<std::decay_t<decltype(B::mColumnIterator)>*>(nullptr);
1295- }
1296-
1297- template <typename B>
1298- decltype (auto ) getDynamicBinding()
1230+ template <typename DC, typename ... B>
1231+ auto bindDynamicColumn (framework::pack<B...>)
12991232 {
1300- return static_cast <std::decay_t <decltype (B::mColumnIterator )>*>(nullptr );
1233+ DC::boundIterators = std::make_tuple ([this ]<typename Bi>(){
1234+ if constexpr (can_bind<self_t , Bi>) {
1235+ return &(static_cast <B*>(this )->mColumnIterator );
1236+ } else {
1237+ return static_cast <std::decay_t <decltype (B::mColumnIterator )>*>(nullptr );
1238+ }
1239+ }.template operator ()<B>()...);
13011240 }
13021241};
13031242
@@ -1427,44 +1366,28 @@ static constexpr std::string getLabelFromTypeForKey(std::string const& key)
14271366 O2_BUILTIN_UNREACHABLE ();
14281367}
14291368
1430- template <soa::is_index_column CL, typename B>
1431- requires (!soa::is_self_index_column<CL>)
1432- consteval static bool hasIndexToImpl ()
1433- {
1434- return o2::soa::is_binding_compatible_v<B, typename CL::binding_t >();
1435- }
1436-
1437- template <soa::is_column CL, typename B>
1438- requires (!soa::is_index_column<CL>)
1439- consteval static bool hasIndexToImpl ()
1440- {
1441- return false ;
1442- }
1443-
14441369template <typename B, typename ... C>
14451370consteval static bool hasIndexTo (framework::pack<C...>&&)
14461371{
1447- return (hasIndexToImpl<C, B>() || ...);
1448- }
1449-
1450- template <soa::is_index_column CL, typename B>
1451- requires (!soa::is_self_index_column<CL>)
1452- consteval static bool hasSortedIndexToImpl ()
1453- {
1454- return CL::sorted && o2::soa::is_binding_compatible_v<B, typename CL::binding_t >();
1455- }
1456-
1457- template <soa::is_column CL, typename B>
1458- requires (!soa::is_index_column<CL>)
1459- consteval static bool hasSortedIndexToImpl ()
1460- {
1461- return false ;
1372+ return ([]<soa::is_column CC, typename BB>(){
1373+ if constexpr (soa::is_index_column<CC> && !soa::is_self_index_column<CC>) {
1374+ return o2::soa::is_binding_compatible_v<BB, typename CC::binding_t >();
1375+ } else {
1376+ return false ;
1377+ }
1378+ }.template operator ()<C, B>() || ...);
14621379}
14631380
14641381template <typename B, typename ... C>
14651382consteval static bool hasSortedIndexTo (framework::pack<C...>&&)
14661383{
1467- return (hasSortedIndexToImpl<C, B>() || ...);
1384+ return ([]<soa::is_column CC, typename BB>(){
1385+ if constexpr (soa::is_index_column<CC> && !soa::is_self_index_column<CC>) {
1386+ return CC::sorted && o2::soa::is_binding_compatible_v<B, typename CC::binding_t >();
1387+ } else {
1388+ return false ;
1389+ }
1390+ }.template operator ()<C, B>() || ...);
14681391}
14691392
14701393template <typename B, typename Z>
@@ -2133,22 +2056,14 @@ class Table
21332056 doBindInternalIndicesExplicit (columns_t {}, binding);
21342057 }
21352058
2136- template <soa::is_self_index_column CL>
2137- void doBindInternalIndicesExplicitImpl (o2::soa::Binding binding)
2138- {
2139- static_cast <CL>(mBegin ).setCurrentRaw (binding);
2140- }
2141-
2142- template <soa::is_column CL>
2143- requires (!soa::is_self_index_column<CL>)
2144- void doBindInternalIndicesExplicitImpl (o2::soa::Binding)
2145- {
2146- }
2147-
21482059 template <typename ... Cs>
21492060 void doBindInternalIndicesExplicit (framework::pack<Cs...>, o2::soa::Binding binding)
21502061 {
2151- (doBindInternalIndicesExplicitImpl<Cs>(binding), ...);
2062+ ([this ]<soa::is_column CL>(o2::soa::Binding b){
2063+ if constexpr (soa::is_self_index_column<CL>) {
2064+ static_cast <CL>(mBegin ).setCurrentRaw (b);
2065+ }
2066+ }.template operator ()<Cs>(binding), ...);
21522067 }
21532068
21542069 void bindExternalIndicesRaw (std::vector<o2::soa::Binding>&& ptrs)
0 commit comments