CVPR/LIVE
34
1#pragma once2 3#include <cstddef>4 5/**6 * Python doesn't have a pointer type, therefore we create a pointer wrapper7 * see https://stackoverflow.com/questions/48982143/returning-and-passing-around-raw-pod-pointers-arrays-with-python-c-and-pyb?rq=18 */9template <typename T>10class ptr {11public:12 ptr() : p(nullptr) {}13 ptr(T* p) : p(p) {}14 ptr(std::size_t p) : p((T*)p) {}15 ptr(const ptr& other) : ptr(other.p) {}16 T* operator->() const { return p; }17 T* get() const { return p; }18 void destroy() { delete p; }19 bool is_null() const { return p == nullptr; }20 size_t as_size_t() const {return (size_t)p;}21private:22 T* p;23};24 