Skip to content

Commit ab5cfe2

Browse files
author
Simon Brand
committed
Update readmeg
1 parent 1c4417d commit ab5cfe2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ A lightweight non-owning reference to a callable.
55
Clang + GCC: [![Linux Build Status](https://travis-ci.org/TartanLlama/function_ref.png?branch=master)](https://travis-ci.org/TartanLlama/function_ref)
66
MSVC: [![Windows Build Status](https://ci.appveyor.com/api/projects/status/k5x00xa11y3s5wsg?svg=true)](https://ci.appveyor.com/project/TartanLlama/function_ref)
77

8+
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:
9+
10+
```cpp
11+
void foo (function_ref<int(int)> func) {
12+
std::cout << "Result is " << func(21); //42
13+
}
14+
15+
foo([](int i) { return i*2; });
16+
```
17+
18+
Full documentation available [here](https://function-ref.tartanllama.xyz/).
19+
820
----------
921
1022
[![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)]("http://creativecommons.org/publicdomain/zero/1.0/")

0 commit comments

Comments
 (0)