Skip to content
Vlad Riscutia edited this page Nov 9, 2016 · 4 revisions

pipe

Pipe is an experimental algorithm library for C++ generators. It leverages the "pipe" operator| to compose generator operations and create functional-style pipelines. For example, here is a sum of squares from 1 to 10 using Pipe:

auto sum_of_squares = count(1)            // start counting from 1
    | take_n(10)                          // take the first 10 yielded elements 
    | map([](auto& i) { return i * i; })  // square them
    | fold(std::plus<> { });              // fold them with std::plus

The library requires coroutines (see the Coroutines Techincal Specification) currently available in VS 2015 Update 3 with the /await compiler option.

Getting Started

Pipe is a header only library. Get it from this repository:

git clone https://github.com/vladris/pipe

Add the include directory to the compiler include path. Using VS 2015 Update 3, make sure to add the /await flag to the compiler to enable experimental coroutine support. Other compilers are not yet supported.

Pipe library

The library has the following public headers:

Pipe works out of the box with std::(experimental::)generator but can also support using custom generator types.

Clone this wiki locally