More improvements of functor implementation
Reduce the amount of memory consumed by the compiler when compiling functors:
- Implement >= and > in terms of <= and < to reduce the number of types required
- Move PreparedFunctor to internal prepared_type to clarify it is an internal type not to be used by 'other code'
- Move prepared call into prepared_xxx functions to simplify argument forwarding
- Move optional handling of prepared functors to prepared wrapper to reduce the number of places where this has to be dealt with
- Replace the non-trivial recursive
chain
implementation with a very neat (local!) binary right-fold expression, which avoids generating nested template instances. This changes thechain
implementation from being one of the most complicated bits of code to being (almost) the simplest. - Pass operators by value instead of by type so we can do constant propagation and avoid promoting constants to the
NumericalValue
functor, and instead bind them directly to the operator, simplifying the type generated for binary expressions such asM < 1600
by effectively changing them to unary predicates ( in effect, changeM < 1600
into (the logical equivalent to)(<1600) @ M
instead of< ( M, NumericalValue(1600) )
. - Prefer variadic lambda capture (when available) over capturing a
std::tuple
to reduce the compile time overhead ofstd::tuple
(see here for more information). - Introduce
Tuplet
- an extremely minimalstd::tuple
replacement implemented as a lambda with variadic capture . It only supportapply
, but if that is all that is needed, it is a drop-in replacement. It requires much less resources to compile thanstd::tuple
! - Use
Tuplet
(instead ofstd::tuple
) to carry the payload of composed functors (when available). - prefer
apply
with (local) lambda over explicit helpers withstd::index_sequence<I...>
arguments - fix (expensive) copy in RecSummary functor
Edited by Gerhard Raven