118 data_ = std::move(other.data_);
122 explicit operator bool()
const {
return data_ &&
data_->object_; }
173 const unsigned previous_value =
data_->counter_.fetch_sub(1);
174 if(previous_value == 1) {
175 delete data_->object_;
176 data_->object_ =
nullptr;
184template<
typename T,
typename... Args>
186 return CyclicPtr<T>(
new T(std::forward<Args>(args)...));
A smart pointer class that allows to work with complex cycles without using weak_ptrs.
CyclicPtr(const CyclicPtr &source)
CyclicPtr(CyclicPtr &&source)
CyclicState Freeze() const
Freeze the reference counter.
CyclicPtr(std::nullptr_t)
CyclicPtr & operator=(const CyclicPtr &other)
void Unfreeze(const CyclicState &frozen_state)
Continue 'normal' reference counting.
std::shared_ptr< Data > data_
friend bool operator!=(const CyclicPtr< T > &lhs, const CyclicPtr< T > &rhs)
CyclicPtr & operator=(CyclicPtr &&other)
friend bool operator==(const CyclicPtr< T > &lhs, const CyclicPtr< T > &rhs)
Class to hold the state returned by CyclicPtr::Freeze().
~CyclicState() noexcept=default
CyclicPtr< T > MakeCyclic(Args &&... args)
void move(TYPE *target, int npixels) const
NewDelAllocator< T > NewDelAllocator< T >::value
Define real & complex conjugation for non-complex types and put comparisons into std namespace.
std::atomic< unsigned > counter_