Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/program--/pipe

A forward-pipe for C++14
https://github.com/program--/pipe

cpp cpp14 header-only pipeline

Last synced: about 2 months ago
JSON representation

A forward-pipe for C++14

Awesome Lists containing this project

README

        

# pipe: an over-engineered forward-pipe C++14 library

## Usage

`pipe::with` describes your initial input value. This can then be piped into objects that provide an `operator()` member, such as lambdas, using the `|` operator. Finally, adding `| pipe::done` signals that the operation is complete, and should be evaluated.

If the piped functors are `constexpr`-able, then the entire pipeline is `constexpr`-able.

### Example

```cpp
// example.cpp
#include "pipe.hpp"

#include
#include

int print_string(const std::string& msg)
{
std::cout << msg << std::endl;
return 1;
}

int main() {
pipe::with(3)
| [](double v) -> double { return v + 10; }
| [](double v) -> char { return static_cast(v); }
| [](char c) -> std::string { return std::to_string(c); }
| [](const std::string& msg) { return print_string(msg); }
| pipe::done;
}
```