diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 9cc7e0c71f939..93960c75b11b7 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -21,6 +21,7 @@ #include "Framework/ArrowTypes.h" #include "Framework/ArrowTableSlicingCache.h" #include "Framework/SliceCache.h" +#include "Framework/VariantHelpers.h" #include #include #include @@ -558,6 +559,9 @@ using is_persistent_t = decltype(persistent_type_helper::test(nullptr)); template constexpr auto is_persistent_v = is_persistent_t::value; +template +constexpr auto is_dynamic_v = is_dynamic_t::value; + template using is_external_index_t = typename std::conditional, std::true_type, std::false_type>::type; @@ -784,7 +788,6 @@ struct RowViewCore : public IP, C... { using table_t = o2::soa::Table; using all_columns = framework::pack; using persistent_columns_t = framework::selected_pack; - using dynamic_columns_t = framework::selected_pack; using index_columns_t = framework::selected_pack; constexpr inline static bool has_index_v = framework::pack_size(index_columns_t{}) > 0; using external_index_columns_t = framework::selected_pack; @@ -794,8 +797,7 @@ struct RowViewCore : public IP, C... { : IP{policy}, C(columnData[framework::has_type_at_v(all_columns{})])... { - bindIterators(persistent_columns_t{}); - bindAllDynamicColumns(dynamic_columns_t{}); + bind(); // In case we have an index column might need to constrain the actual // number of rows in the view to the range provided by the index. // FIXME: we should really understand what happens to an index when we @@ -810,16 +812,14 @@ struct RowViewCore : public IP, C... { : IP{static_cast(other)}, C(static_cast(other))... { - bindIterators(persistent_columns_t{}); - bindAllDynamicColumns(dynamic_columns_t{}); + bind(); } RowViewCore& operator=(RowViewCore other) { IP::operator=(static_cast(other)); (void(static_cast(*this) = static_cast(other)), ...); - bindIterators(persistent_columns_t{}); - bindAllDynamicColumns(dynamic_columns_t{}); + bind(); return *this; } @@ -827,8 +827,7 @@ struct RowViewCore : public IP, C... { : IP{static_cast(other)}, C(static_cast(other))... { - bindIterators(persistent_columns_t{}); - bindAllDynamicColumns(dynamic_columns_t{}); + bind(); } RowViewCore& operator++() @@ -947,18 +946,15 @@ struct RowViewCore : public IP, C... { /// Helper which binds all the ColumnIterators to the /// index of a the associated RowView - template - auto bindIterators(framework::pack) - { - using namespace o2::soa; - (void(PC::mColumnIterator.mCurrentPos = &this->mRowIndex), ...); - } - - template - auto bindAllDynamicColumns(framework::pack) + void bind() { using namespace o2::soa; - (bindDynamicColumn(typename DC::bindings_t{}), ...); + auto f = framework::overloaded { + [this](T*) -> void requires is_persistent_v { T::mColumnIterator.mCurrentPos = &this->mRowIndex; }, + [this](T*) -> void requires is_dynamic_v { bindDynamicColumn(typename T::bindings_t{});}, + [this](T*) -> void {}, + }; + (f(static_cast(nullptr)), ...); if constexpr (has_index_v) { this->setIndices(this->getIndices()); this->setOffsets(this->getOffsets());