Use generic type-erasure functor wrapper when composing REQUIRE_ALL
Assuming that the memory usage during compilation of functors is mainly due to the combinatoric explosion of types during compositing, it may be helpful to be able to 'wrap' generic functors into more specific, constrained functors which erase the type of the underlying functor prior to composition. This avoids the above combinatoric explosion of types at the cost of making it impossible for the compiler to 'inter-functor' optimize the code (as now the to-be-composited functors effectively turn into black boxes). Note that the compositing targeted here is mainly &&
, i.e. REQUIRE_ALL
, as in that case, all elements must have the same signature. Compositing where there is a clear pipeline (i.e. @
) where the type passed along changes is obviously not a use-case for this.
This requires implementing a generic wrapper which a-priori will only be callable with a single argument type (to be specified as template argument), and which can be constructed from 'any' functor provided it can satisfy the required calling signature, and then type-erase the 'inner' functor (using some SBO, as most functors are 'small') -- likely PreparedFunctor
(see here can serve for this 'as-is'...