Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TartanLlama/function_ref
A lightweight, non-owning reference to a callable.
https://github.com/TartanLlama/function_ref
Last synced: 28 days ago
JSON representation
A lightweight, non-owning reference to a callable.
- Host: GitHub
- URL: https://github.com/TartanLlama/function_ref
- Owner: TartanLlama
- License: cc0-1.0
- Created: 2017-11-23T16:07:32.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-09-22T11:53:39.000Z (about 3 years ago)
- Last Synced: 2024-11-07T23:43:33.535Z (about 1 month ago)
- Language: C++
- Size: 118 KB
- Stars: 169
- Watchers: 7
- Forks: 23
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
- AwesomeCppGameDev - function_ref - owning reference to a callable. (C++)
README
# function_ref
A lightweight non-owning reference to a callable.
Clang + GCC: [![Linux Build Status](https://travis-ci.org/TartanLlama/function_ref.png?branch=master)](https://travis-ci.org/TartanLlama/function_ref)
MSVC: [![Windows Build Status](https://ci.appveyor.com/api/projects/status/k5x00xa11y3s5wsg?svg=true)](https://ci.appveyor.com/project/TartanLlama/function_ref)Use `tl::function_ref` instead of `std::function` whenever you don't need to own the callable. The most common case for this is function parameters which aren't stored anywhere:
```cpp
void foo (function_ref func) {
std::cout << "Result is " << func(21); //42
}foo([](int i) { return i*2; });
```Full documentation available [here](https://tl.tartanllama.xyz/).
----------
[![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)]("http://creativecommons.org/publicdomain/zero/1.0/")
To the extent possible under law, [Simon Brand](https://twitter.com/TartanLlama) has waived all copyright and related or neighboring rights to the `function_ref` library. This work is published from: United Kingdom.