https://github.com/rigtorp/Function
Heap allocation free version of C++11 std::function
https://github.com/rigtorp/Function
Last synced: 17 days ago
JSON representation
Heap allocation free version of C++11 std::function
- Host: GitHub
- URL: https://github.com/rigtorp/Function
- Owner: rigtorp
- License: mit
- Created: 2015-11-24T16:47:44.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-10-06T08:54:24.000Z (over 3 years ago)
- Last Synced: 2025-05-06T06:09:32.721Z (19 days ago)
- Language: C++
- Size: 6.84 KB
- Stars: 55
- Watchers: 6
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCppGameDev - Function
README
# Function.h
Heap allocation free version of C++11 *std::function*.
Function.h stores the closure in an internal buffer instead of heap
allocated memory. This is useful for low latency agent and thread pool
systems. Please note that the captured values can perfom allocations,
for example *std::string*.## Benchmark
*Function.h* is quite a lot faster than *std::function* to
construct. Invocation overhead is the same for both.Compiled with `gcc -O3 -fno-devirtualize` (gcc 5.2).
```
construction overhead
std::function: 42ns/op
Function: 4ns/op
invokation overhead:
std::function: 2ns/op
Function: 2ns/op
virtual: 2ns/op
```