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
chainimplementation with a very neat (local!) binary right-fold expression, which avoids generating nested template instances. This changes thechainimplementation 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
NumericalValuefunctor, and instead bind them directly to the operator, simplifying the type generated for binary expressions such asM < 1600by effectively changing them to unary predicates ( in effect, changeM < 1600into (the logical equivalent to)(<1600) @ Minstead of< ( M, NumericalValue(1600) ). - Prefer variadic lambda capture (when available) over capturing a
std::tupleto reduce the compile time overhead ofstd::tuple(see here for more information). - Introduce
Tuplet- an extremely minimalstd::tuplereplacement 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
applywith (local) lambda over explicit helpers withstd::index_sequence<I...>arguments - fix (expensive) copy in RecSummary functor
Edited by Gerhard Raven