diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 9030cf5fe7eec..1cf56bcaaacf4 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -541,8 +541,23 @@ struct Index : o2::soa::IndexColumn> { template using is_dynamic_t = framework::is_specialization; +namespace persistent_type_helper +{ +// This checks both for the existence of the ::persistent member in the class T as well as the value returned stored in it. +// Hack: a pointer to any field of type int inside persistent. Both true_type and false_type do not have any int field, but anyways we pass nullptr. +// The compiler picks the version with exact number of arguments when only it can, i.e., when T::persistent is defined. +template +typename T::persistent test(int T::persistent::*); + +template +std::false_type test(...); +} // namespace persistent_type_helper + template -using is_persistent_t = typename std::decay_t::persistent::type; +using is_persistent_t = decltype(persistent_type_helper::test(nullptr)); + +template +using is_persistent_v = typename is_persistent_t::value; template using is_external_index_t = typename std::conditional, std::true_type, std::false_type>::type; @@ -1112,10 +1127,12 @@ class Table auto getId() const { using decayed = std::decay_t; - if constexpr (framework::has_type_v) { + if constexpr (framework::has_type_v) { // index to another table constexpr auto idx = framework::has_type_at_v(bindings_pack_t{}); return framework::pack_element_t::getId(); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { // self index + return this->globalIndex(); + } else if constexpr (is_index_t::value && decayed::mLabel == "Index") { // soa::Index<> return this->globalIndex(); } else { return static_cast(-1); @@ -1505,14 +1522,14 @@ namespace row_helpers template std::array getArrowColumns(arrow::Table* table, framework::pack) { - static_assert(std::conjunction_v, "BinningPolicy: only persistent columns accepted (not dynamic and not index ones"); + static_assert(std::conjunction_v, "Arrow columns: only persistent columns accepted (not dynamic and not index ones"); return std::array{o2::soa::getIndexFromLabel(table, Cs::columnLabel())...}; } template std::array, sizeof...(Cs)> getChunks(arrow::Table* table, framework::pack, uint64_t ci) { - static_assert(std::conjunction_v, "BinningPolicy: only persistent columns accepted (not dynamic and not index ones"); + static_assert(std::conjunction_v, "Arrow chunks: only persistent columns accepted (not dynamic and not index ones"); return std::array, sizeof...(Cs)>{o2::soa::getIndexFromLabel(table, Cs::columnLabel())->chunk(ci)...}; } @@ -1544,8 +1561,10 @@ typename C::type getSingleRowData(arrow::Table* table, T& rowIterator, uint64_t return getSingleRowPersistentData(table, ci, ai); } else if constexpr (o2::soa::is_dynamic_t()) { return getSingleRowDynamicData(rowIterator, globalIndex); - } else if constexpr (o2::soa::is_index_column_v) { + } else if constexpr (o2::soa::is_index_t::value) { return getSingleRowIndexData(rowIterator, globalIndex); + } else { + static_assert(!sizeof(decayed*), "Unrecognized column kind"); // A trick to delay static_assert until we actually instantiate this branch } }