Skip to content

eoan-ermine/deep_ptr

Repository files navigation

deep_ptr

clang gcc msvc

Deep pointers for C++14 and above.

Usage (godbolt)

#include <deep_ptr/deep_ptr.hpp>
#include <iostream>

struct A {
  struct B {
    int p{5};
  } b;
};

int main() {
  A obj;
  deep_ptr<decltype(&A::b), decltype(&A::B::p)> ptr{&A::b, &A::B::p};
  int a = ptr.get(obj);
  std::cout << a << '\n'; // Output: 5
}

CMake integration

CMake variables

Option Description Default value
CMAKE_BUILD_TYPE (type: STRING) This configures the optimization level for make or ninja builds (possible values: Release, Debug, RelWithDebInfo, MinSizeRel) ""
CMAKE_INSTALL_PREFIX (type: PATH) Install path prefix /usr/local
deepptr_BUILD_EXAMPLES (type: BOOLEAN) Build deep_ptr examples OFF
deepptr_BUILD_TESTS (type: BOOLEAN) Build deep_ptr tests ON
include(FetchContent)

FetchContent_Declare(
  deep_ptr
  GIT_REPOSITORY https://github.com/eoan-ermine/deep_ptr.git
  GIT_TAG master
  GIT_SHALLOW TRUE
)

FetchContent_MakeAvailable(deep_ptr)

target_link_libraries(${PROJECT_NAME} PRIVATE deep_ptr::deep_ptr)
include(cmake/CPM.cmake)

CPMAddPackage("gh:eoan-ermine/deep_ptr#master")

target_link_libraries(${PROJECT_NAME} PRIVATE deep_ptr::deep_ptr)

Contributing

To set up the development environment, run:

git clone git@github.com:eoan-ermine/deep_ptr.git
cd deep_ptr
pip install pre-commit
pre-commit install

Once the environment is set up, you can build the project with:

cmake -Ddeepptr_BUILD_EXAMPLES=1 -B build -G "Ninja Multi-Config"
cmake --build build --config Debug

You can run tests with:

ctest -C Debug --test-dir build/tests/

About

Deep pointers for C++14 and above

Topics

Resources

License

Stars

Watchers

Forks

Contributors