Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justasmasiulis/args
Header only library for binding, reordering and currying of function arguments without cost
https://github.com/justasmasiulis/args
bind binder cpp cpp14 currying easy-to-use fast functional functional-programming header-only modern modern-cpp monadic optimization reorder reordering simple small type-erasure
Last synced: 16 days ago
JSON representation
Header only library for binding, reordering and currying of function arguments without cost
- Host: GitHub
- URL: https://github.com/justasmasiulis/args
- Owner: JustasMasiulis
- Created: 2018-05-25T19:55:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-20T17:04:39.000Z (over 6 years ago)
- Last Synced: 2024-01-30T00:43:09.423Z (10 months ago)
- Topics: bind, binder, cpp, cpp14, currying, easy-to-use, fast, functional, functional-programming, header-only, modern, modern-cpp, monadic, optimization, reorder, reordering, simple, small, type-erasure
- Language: C++
- Homepage:
- Size: 14.6 KB
- Stars: 15
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# args
A header only functional programming support library without type erasure.```cpp
void foo(int, float, const char*);// all of the examples below call foo(1, 2.f, "3") and are optimized out in release builds
auto reordered = args::reorder<2, 0, 1>(foo);
reordered("3", 1, 2.f);auto bound = args::bind<1>(foo, 2.f);
bound(1, "hello");auto curried = args::curry<0, 2>(foo);
auto bound2 = curried(1, "3");
bound2(2.f);
```## quick documentation
* Both functions and arguments are stored by value. Use std::ref to avoid copies.
* Chaining of the library functions is possible.
* Type erasure is not performed.```cpp
template
constexpr /* callable object */ reorder(Fn&& function);reorder<2, 0, 1>(void(int, float, const char*)) -> void(const char*, int, float)
``````cpp
template
constexpr /* callable object */ bind(Fn&& function, Args&&... values_to_bind);bind<1>(void(int, float, const char*), float) -> void(int, const char*)
``````cpp
template
constexpr /* callable object */ curry(Fn&& function);curry<2>(void(int, float, const char*)) -> (void(int, float))(const char*)
```