Skip to content

Commit

Permalink
Return types
Browse files Browse the repository at this point in the history
  • Loading branch information
taehyounpark committed Feb 16, 2024
1 parent 3a8e3ba commit 2d47b94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions include/ana/interface/column.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ struct equation_traits<std::function<Ret(Args...)>> {
column::equation<std::decay_t<Ret>(std::decay_t<Args>...)>;
};

template <typename Expr> struct equation_traits<expression<Expr>> {
using function_type = typename expression<Expr>::function_type;
using equation_type = typename equation_traits<function_type>::equation_type;
};

template <typename F>
using equation_t = typename equation_traits<F>::equation_type;

Expand Down
17 changes: 11 additions & 6 deletions include/ana/interface/dataflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ class dataflow {
template <typename F> auto _equate(F fn);
template <typename Expr> auto _equate(column::expression<Expr> const &expr);

template <typename Val> auto define(column::constant<Val> const &cnst);
template <typename Val>
auto define(column::constant<Val> const &cnst) -> lazy<column::fixed<Val>>;

template <typename Def, typename... Cols>
auto define(column::definition<Def> const &defn, Cols const &...cols);
auto define(column::definition<Def> const &defn, Cols const &...cols)
-> lazy<Def>;

template <typename Expr, typename... Cols>
auto define(column::expression<Expr> const &expr, Cols const &...cols);
auto define(column::expression<Expr> const &expr, Cols const &...cols)
-> lazy<column::equation_t<ana::column::expression<Expr>>>;

template <typename Sel, typename F>
auto _select(F fn) -> delayed<selection::template custom_applicator_t<F>>;
Expand Down Expand Up @@ -286,19 +289,21 @@ auto ana::dataflow::open(ana::dataset::input<DS> &&input)
}

template <typename Val>
auto ana::dataflow::define(ana::column::constant<Val> const &cnst) {
auto ana::dataflow::define(ana::column::constant<Val> const &cnst)
-> lazy<column::fixed<Val>> {
return cnst._assign(*this);
}

template <typename Def, typename... Cols>
auto ana::dataflow::define(ana::column::definition<Def> const &defn,
Cols const &...cols) {
Cols const &...cols) -> lazy<Def> {
return this->_define(defn).template evaluate(cols...);
}

template <typename Expr, typename... Cols>
auto ana::dataflow::define(ana::column::expression<Expr> const &expr,
Cols const &...cols) {
Cols const &...cols)
-> lazy<column::equation_t<ana::column::expression<Expr>>> {
return this->_equate(expr).template evaluate(cols...);
}

Expand Down

0 comments on commit 2d47b94

Please sign in to comment.