Automatically adjust the prototype of functors for CwiseNullaryOp
@ggael
Submitted by Gael GuennebaudAssigned to Nobody
Link to original bugzilla bug (#1286)
Version: 3.3 (current stable)
Description
Created attachment 726
patch
Current functors passed to NullaryExpr must implement both operator()(i) and operator()(i,j) plus specialize internal::functor_has_linear_access<> for non trivial functors. This is rather painful and cumbersome to document (hence, this is currently not really documented!).
The proposed patch automatically detect whether the functor expose one or multiple of the following operators:
operator()()
operator()(i)
operator()(i,j)
and then a little helper augments the input functors with the missing operators.
With this change, no need to provide operator()(i,j) if nor i nor j are required (e.g., for random, and constant).
I'd like to push this change in 3.3 as it considerably help in documenting and using NullaryExpr.
Patch 726, "patch":
nullary_expr_auto_linear_access.diff