From 83b7be31a1d0fc0be4e013dbfc97bb6cdc3600db Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sun, 27 Dec 2020 16:03:58 +0100 Subject: Removed MACRO functions in API, like cvec_size(c), cvec_empty(c). Use cvec_X_size(c) etc. Restructured benchmarks / examples. --- examples/others/sparsepp/spp_smartptr.h | 71 --------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 examples/others/sparsepp/spp_smartptr.h (limited to 'examples/others/sparsepp/spp_smartptr.h') diff --git a/examples/others/sparsepp/spp_smartptr.h b/examples/others/sparsepp/spp_smartptr.h deleted file mode 100644 index fba3acfb..00000000 --- a/examples/others/sparsepp/spp_smartptr.h +++ /dev/null @@ -1,71 +0,0 @@ -#if !defined(spp_smartptr_h_guard) -#define spp_smartptr_h_guard - - -/* ----------------------------------------------------------------------------------------------- - * quick version of intrusive_ptr - * ----------------------------------------------------------------------------------------------- - */ - -#include -#include "spp_config.h" - -// ------------------------------------------------------------------------ -class spp_rc -{ -public: - spp_rc() : _cnt(0) {} - spp_rc(const spp_rc &) : _cnt(0) {} - void increment() const { ++_cnt; } - void decrement() const { assert(_cnt); if (--_cnt == 0) delete this; } - unsigned count() const { return _cnt; } - -protected: - virtual ~spp_rc() {} - -private: - mutable unsigned _cnt; -}; - -// ------------------------------------------------------------------------ -template -class spp_sptr -{ -public: - spp_sptr() : _p(0) {} - spp_sptr(T *p) : _p(p) { if (_p) _p->increment(); } - spp_sptr(const spp_sptr &o) : _p(o._p) { if (_p) _p->increment(); } -#ifndef SPP_NO_CXX11_RVALUE_REFERENCES - spp_sptr(spp_sptr &&o) : _p(o._p) { o._p = (T *)0; } - spp_sptr& operator=(spp_sptr &&o) { this->swap(o); return *this; } -#endif - ~spp_sptr() { if (_p) _p->decrement(); } - spp_sptr& operator=(const spp_sptr &o) { reset(o._p); return *this; } - T* get() const { return _p; } - void swap(spp_sptr &o) { T *tmp = _p; _p = o._p; o._p = tmp; } - void reset(const T *p = 0) - { - if (p == _p) - return; - if (_p) _p->decrement(); - _p = (T *)p; - if (_p) _p->increment(); - } - T* operator->() const { return const_cast(_p); } - bool operator!() const { return _p == 0; } - -private: - T *_p; -}; - -// ------------------------------------------------------------------------ -namespace std -{ - template - inline void swap(spp_sptr &a, spp_sptr &b) - { - a.swap(b); - } -} - -#endif // spp_smartptr_h_guard -- cgit v1.2.3