6#ifndef EGT_DETAIL_COW_H
7#define EGT_DETAIL_COW_H
9#include <egt/detail/meta.h>
49 explicit operator bool()
const
72 return m_ptr.operator->();
79 return m_ptr.operator->();
87 m_ptr = std::make_shared<T>();
94 else if (m_ptr && !m_ptr.unique())
95 m_ptr = std::make_shared<T>(*m_ptr);
98 std::shared_ptr<T> m_ptr;
Copy-On-Write wrapper for an object or container.
Definition cow.h:33
CopyOnWriteAllocate(const std::shared_ptr< T > &refptr)
Construct with a shared_ptr to the object.
Definition cow.h:44
const T & operator*() const
Dereference operator. This will allocate.
Definition cow.h:55
T & operator*()
Dereference operator.
Definition cow.h:62
T * operator->()
Arrow operator.
Definition cow.h:76
CopyOnWriteAllocate()=default
const T * operator->() const
Arrow operator.
Definition cow.h:69
CopyOnWriteAllocate(T *t)
Construct with a pointer to the object. This now owns the pointer.
Definition cow.h:39
EGT framework namespace.
Definition animation.h:24