Header-only C++17/C++20 smart pointer library with explicit ownership and safe observation.
API documentation | 中文说明 | Contributing
All public types live in namespace prtm. Implementation details are in prtm::detail.
| Type | Description |
|---|---|
OwnerPtr<T, Deleter> |
Owning smart pointer. Move-only. Supports custom deleters. |
ShadowPtr<T> |
Non-owning observer. Detects when the target object is destroyed. |
EnableShadowFromThis<T> |
CRTP base. Lets an object create ShadowPtr from this. |
The entire implementation lives in include/PrettyMemory.h.
Requires: CMake 3.28+, C++17 compiler. C++20 enables concepts and the <=> spaceship operator.
cmake -S . -B build
cmake --build build
ctest --test-dir build --output-on-failureRun a single test by name pattern:
ctest --test-dir build -R ShadowPtrTest --output-on-failureList discovered tests without running:
ctest --test-dir build -NPython helper scripts wrap CMake. Default build config is RelWithDebInfo:
pipenv run build # configure + build (RelWithDebInfo)
pipenv run test # run tests
pipenv run build_release # build Release
pipenv run test_release # test Release
pipenv run clean # remove build/, bin/, .vs/, .idea/
pipenv run doc # generate Doxygen docsCI builds in Release with -G "Visual Studio 17 2022" -A x64. Both C++17 and C++20 are supported; C++20 enables concepts and the <=> spaceship operator.
Doxygen generates the API reference from comments in include/PrettyMemory.h.
cmake -S . -B build\docs -DBUILD_DOCS=ON
cmake --build build\docs --target docsOr use the helper script:
pipenv run docOutput goes to doc/html. The generated site does not expose absolute local file paths.
include/PrettyMemory.h public API and header-only implementation
test/ GoogleTest-based unit tests (one file per type)
CMakeLists.txt top-level build: C++ standard, output dirs, BUILD_TESTS option
Pipfile Python helper scripts for build/test/clean/doc
#include <PrettyMemory.h>
struct Object
{
int Value{ 0 };
};
auto owner = prtm::OwnerPtr<Object>::Create();
owner->Value = 42;
auto shadow = owner.Shadow();
owner.Reset();
bool expired = shadow.Expired();.github/workflows/ci.yml— builds and tests on Windows for pushes tomain/masterand pull requests..github/workflows/deploy-docs.yml— regenerates docs on push tomain, deploys to GitHub Pages.
First-time Pages setup: set Settings > Pages > Source to GitHub Actions.