#ifndef PFOR_PFOR_USEROP_H #define PFOR_PFOR_USEROP_H #include "expression/expression.h" namespace pfor { template struct UserOperator { F f; template>* = nullptr> inline decltype(auto) eval(Args&&... args) { return f(std::forward(args).eval()...); } template inline decltype(auto) eval(std::size_t i, Args&&... args) { return f(std::forward(args)[i]...); } }; /** * @brief make an operator from a function * * @param[in] f a function * * @return an operator (UserOperator) */ template auto makeOperator(F&& f) { return [f = std::forward(f)](auto&&... args) { using Op = UserOperator; using Expr = pfor::expr::Expression>...>; return Expr{{f}, decltype(args)(args)...}; }; } } #endif