Skip to content

Instantly share code, notes, and snippets.

@2bbb
Created June 16, 2017 04:20
Show Gist options
  • Save 2bbb/d06f6d201a83f8910004f0006ba44e56 to your computer and use it in GitHub Desktop.
Save 2bbb/d06f6d201a83f8910004f0006ba44e56 to your computer and use it in GitHub Desktop.
pipe example
#include <bbb/pipe.hpp>
#include <iostream>
int main(int argc, char *argv[]) {
std::string str = "a/b/cdcd/ezzzf/ghi/azzz/czzzd/ef";
auto res = str
| bbb::replace("zzz", "Z") // "a/b/cdcd/eZf/ghi/aZ/cZd/ef"
| bbb::split("/") // {"a", "b", "cdcd", "eZf", "ghi", "aZ", "cZd", "ef"}
| bbb::filter([](std::string str) { return str.length() < 3; }) // {"a", "b", "aZ", "ef"}
| bbb::map([](std::string str) { return str | bbb::reverse(); }) // {"a", "b", "Za", "fe"}
| bbb::join(" ") // "a b Za fe"
| bbb::reverse(); // "ef aZ b a"
std::cout << res << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment