Skip to content

Commit

Permalink
Remove TODO and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMaracine committed Apr 26, 2024
1 parent 0c1d591 commit 6b7bee5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
40 changes: 31 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
# cpp-shared-ref

A `C++17` compatible, non-atomic reference-counting smart pointer, made for myself as a replacement for the
atomic `std::shared_ptr`.
A cross-platform, `C++17` compatible, non-atomic reference-counting smart pointer, made for myself as a replacement
for the atomic `std::shared_ptr`.

`shared_ref` emulates most of `std::shared_ptr`'s API and functionality, with the most important difference being
that the reference increments and decrements are not atomic. The premise is that a reference-counting smart pointer
can be very useful in contexts outside of threading, in which atomicity is not needed, being just useless overhead.
This is why I tried making my own version of `std::shared_ptr`.
can be very useful in contexts outside of multithreading, in which atomicity is not needed, being just useless
overhead. This is why I tried making my own version of `std::shared_ptr`.

Right now, `shared_ref` doesn't fully conform with the `std::shared_ptr` specification of `C++17`. This is probably
an incomplete list of missing features from my version or differences between the two:
an incomplete list of missing features from my version:

- Not allocator-aware
- No support for arrays
- No support for `shared_from_this`
- `make_shared` doesn't allocate object and control block at the same time
- Missing a few `shared_ref` and `weak_ref` constructors
- Missing `owner_before` methods
- No support for `-fno-exceptions`
- Deprecated features as of `C++17` are missing (for good)

The code is unit-tested. Almost every public functionality is tested in its own unit. Also Valgrind is
regularly used in development to check for memory bugs. Tested compilation on `GCC 13.2` and `MSVC 19.39`.
The code is unit-tested. Almost all public functionality is tested. Also Valgrind is regularly used in development
to check for memory bugs. Tested compilation on `GCC 13.2` and `MSVC 19.39`.

If you need a specific missing feature, or need this library to work on lower versions of C++, feel free to open
up an issue.
Expand All @@ -44,3 +42,27 @@ To build with tests:
```cmake
set(CPP_SHARED_REF_BUILD_TESTS ON)
```

## Example

```cpp
#include <iostream>
#include <cpp_shared_ref/memory.hpp>

int main() {
sm::weak_ref<int> foo;

{
sm::shared_ref<int> bar {sm::make_shared<int>(5)};
std::cout << *bar << '\n';

foo = bar;
}

auto baz {foo.lock()};

if (baz) {
std::cout << "This is never printed\n";
}
}
```
13 changes: 0 additions & 13 deletions TODO

This file was deleted.

0 comments on commit 6b7bee5

Please sign in to comment.