5#ifndef GEOMODELUTILITIES_TRANSIENTCONSTSHAREDPTR_H
6#define GEOMODELUTILITIES_TRANSIENTCONSTSHAREDPTR_H
29 template <
typename DerivType>
31 requires(std::is_base_of_v<Obj, DerivType>):
m_ptr{
std::move(ptr)} {}
33 template <
typename DerivType>
35 requires(std::is_base_of_v<Obj, DerivType>) :
m_ptr{
std::move(ptr)} {}
42 template <
typename DerivType>
44 requires(std::is_base_of_v<Obj, DerivType>) :
47 template <
typename DerivType>
49 requires(std::is_base_of_v<Obj, DerivType>) :
53 template <
typename DerivType>
55 requires(std::is_base_of_v<Obj, DerivType>) {
61 template <
typename DerivType>
63 requires(std::is_base_of_v<Obj, DerivType>) {
68 template <
typename DerivType>
70 requires(std::is_base_of_v<Obj, DerivType>) {
71 m_ptr = std::move(other.m_ptr);
74 template <
typename DerivType>
76 requires(std::is_base_of_v<Obj, DerivType>) {
77 m_ptr = std::move(other);
80 template <
typename DerivType>
82 requires(std::is_base_of_v<Obj, DerivType>) {
83 m_ptr = std::move(other);
87 template <
typename DerivType>
88 void reset(std::unique_ptr<DerivType> newObj)
89 requires(std::is_base_of_v<Obj, DerivType>) {
90 m_ptr = std::move(newObj);
92 template <
typename DerivType>
93 void reset(std::shared_ptr<DerivType>&& newObj)
94 requires(std::is_base_of_v<Obj, DerivType>) {
95 m_ptr = std::move(newObj);
97 template <
typename DerivType>
98 void reset(
const std::shared_ptr<DerivType>& newObj)
99 requires(std::is_base_of_v<Obj, DerivType>) {
100 m_ptr = std::move(newObj);
106 operator bool()
const {
return m_ptr.get() !=
nullptr; }
113 return get() < other.get();
117 return other.get() ==
get();
120 return other.get() !=
get();
The TransientConstSharedPtr allows non-const access if the pointer itself is non-const but in the con...
const Obj * operator->() const
bool operator<(const TransientConstSharedPtr &other) const
Smaller operator to insert the pointer into sets.
TransientConstSharedPtr(Obj *ptr)
Constructor from raw ptr.
TransientConstSharedPtr & operator=(const std::shared_ptr< DerivType > &other)
bool operator!=(const TransientConstSharedPtr &other) const
std::shared_ptr< DeltaMap > m_ptr
TransientConstSharedPtr & operator=(const TransientConstSharedPtr< DerivType > &other)
Assignment operator.
void reset(std::unique_ptr< DerivType > newObj)
Overload the pointer.
friend class GeoModel::TransientConstSharedPtr
Obj * get()
Get (non-const) access to the underlying object.
void reset(const std::shared_ptr< DerivType > &newObj)
TransientConstSharedPtr & operator=(TransientConstSharedPtr< DerivType > &&other)
Move assignment operator.
TransientConstSharedPtr()=default
Standard constructor.
TransientConstSharedPtr(std::unique_ptr< DerivType > ptr)
Constructor from a unique_ptr.
const Obj & operator*() const
Dereference operator.
TransientConstSharedPtr(TransientConstSharedPtr< DerivType > &&other)
Standard move constructor.
bool operator==(const TransientConstSharedPtr &other) const
Equal operator.
size_t use_count() const
How many clients does the pointer have.
TransientConstSharedPtr & operator=(std::shared_ptr< DerivType > &&other)
std::shared_ptr< const Obj > release()
Release the memory.
TransientConstSharedPtr & operator=(std::unique_ptr< DerivType > &&other)
const Obj * get() const
Get const access to the underlying object.
TransientConstSharedPtr(std::shared_ptr< DerivType > ptr)
Constructor from shared_ptr.
void reset(std::shared_ptr< DerivType > &&newObj)
TransientConstSharedPtr(const TransientConstSharedPtr< DerivType > &other)
Delete the copy constructor if the object is const.