vg
tools for working with variation graphs
|
#include <functional>
Namespaces | |
handlegraph | |
Defines tools for implementing the iteratee pattern, with optional eraly stopping.
The basic idea of the iteratee pattern is that we have a function that takes an "iteratee" lambda and calls it, possibly in parallel, with a bunch of items. The iteratee can either be void-returning or bool-returning. If it is bool-returning, when it returns false, the iteration will stop.
This is tricky to implement in C++ because we can't overload on bool-vs-void return type of std::function, as described in https://stackoverflow.com/a/6194623; we use templates that get instantiated over unique passed-in lambda types to work around this.
HandleGraph interfaces will require a for_each_whatever_impl virtual protected method to be implemented by implementations, always operating oin a bool-returning iteratee, and expose public non-virtual for_each_whatever templates that manage the wraping of void-returning iteratees.