vg
tools for working with variation graphs
Classes | Namespaces
iteratee.hpp File Reference
#include <functional>

Classes

struct  handlegraph::BoolReturningWrapper< Iteratee, Iterated, IterateeReturnType >
 
struct  handlegraph::BoolReturningWrapper< Iteratee, Iterated, void >
 This specialization handles wrapping void-returning callables. More...
 
struct  handlegraph::BoolReturningWrapper< Iteratee, Iterated, bool >
 This specialization handles wrapping bool-returning callables. More...
 

Namespaces

 handlegraph
 

Detailed Description

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.