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

Classes

struct  handlegraph::return_type_of< Function >
 
struct  handlegraph::return_type_of< Returns(Owner::*)(Args...) const >
 
struct  handlegraph::return_type_of< Returns(Owner::*)(Args...)>
 
struct  handlegraph::return_type_of< Returns(*)(Args...)>
 
struct  handlegraph::BoolReturningWrapper< Iteratee, ReturnsBool >
 
struct  handlegraph::BoolReturningWrapper< Iteratee, true >
 
struct  handlegraph::BoolReturningWrapper< Iteratee, false >
 

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.