https://github.com/vimpunk/rc
Simple non-atomic reference counted word sized pointer types for C++11
https://github.com/vimpunk/rc
Last synced: 9 months ago
JSON representation
Simple non-atomic reference counted word sized pointer types for C++11
- Host: GitHub
- URL: https://github.com/vimpunk/rc
- Owner: vimpunk
- Created: 2018-11-29T09:11:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-29T09:30:55.000Z (over 7 years ago)
- Last Synced: 2025-04-28T16:55:54.926Z (about 1 year ago)
- Language: C++
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RC
This library provides a simple replacement for when `std::shared_ptr`s are not
suitable. Rc stands for "reference counted" (very creative, I know), inspired by Rust's
`Arc`. The API is similar to that of `std::shared_ptr` and `std::weak_ptr`.
## Why
Rc has two main selling points.
One, both pointer types are *non* atomic (saving some of the associated overhead)--and thus *not* thread safe!
Second, both pointer types (`rc` and`weak_rc`) are the size of
the architecture's word size (i.e. equal to `sizeof(void*)`. Besides saving space, this allows rc pointers to be passed
to C style functions that take a `void*` as their generic parameter. To faciliatate
this, special conversion methods are provided to cast to `void*` and to
reconstruct rc pointers from `void*`.
## Disclaimer
*USE AT YOUR OWN RISK!* This library has not been thoroughly tested, it's a recent experiment that needs further evaluation.