Skip to content

Commit

Permalink
DPL: properly handle getting non-existing bindinds
Browse files Browse the repository at this point in the history
The current code only works because the template specialization happens
late enough.

This might or might not be the case, depending for example if one decides to
force a given table's code out-of-line.
  • Loading branch information
ktf committed Jul 1, 2024
1 parent 045c239 commit d72f22a
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Framework/Core/include/Framework/ASoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,11 @@ struct ColumnDataHolder {
arrow::ChunkedArray* second;
};

template <typename T, typename B>
concept CanBind = requires(T&& t) {
{ t.B::mColumnIterator };
};

template <typename IP, typename... C>
struct RowViewCore : public IP, C... {
public:
Expand Down Expand Up @@ -964,7 +969,27 @@ struct RowViewCore : public IP, C... {
template <typename DC, typename... B>
auto bindDynamicColumn(framework::pack<B...>)
{
DC::boundIterators = std::make_tuple(&(B::mColumnIterator)...);
DC::boundIterators = std::make_tuple(getDynamicBinding<B>()...);
}

// Sometimes dynamic columns are defined for tables in
// the hope that it will be joined / extended with another one which provides
// the full set of bindings. This is to avoid a compilation
// error if constructor for the table or any other thing involving a missing
// binding is preinstanciated.
template <typename B>
requires(CanBind<typename table_t::iterator, B>)
decltype(auto) getDynamicBinding()
{
static_assert(std::is_same_v<decltype(&(static_cast<B*>(this)->mColumnIterator)), std::decay_t<decltype(B::mColumnIterator)>*>, "foo");
return &(static_cast<B*>(this)->mColumnIterator);
//return static_cast<std::decay_t<decltype(B::mColumnIterator)>*>(nullptr);
}

template <typename B>
decltype(auto) getDynamicBinding()
{
return static_cast<std::decay_t<decltype(B::mColumnIterator)>*>(nullptr);
}
};

Expand Down

0 comments on commit d72f22a

Please sign in to comment.