13#ifndef CXXUTILS_REFCOUNTEDPTR_H
14#define CXXUTILS_REFCOUNTEDPTR_H
37template <CxxUtils::detail::RefCounted T>
50 template <CxxUtils::detail::RefCounted OTHER>
51 requires std::convertible_to<OTHER*, T*>
61 template <CxxUtils::detail::RefCounted OTHER>
62 requires std::convertible_to<OTHER*, T*>
66 template <CxxUtils::detail::RefCounted OTHER>
67 requires std::convertible_to<OTHER*, T*>
80 template <CxxUtils::detail::RefCounted OTHER>
81 requires std::convertible_to<OTHER*, T*>
85 template <CxxUtils::detail::RefCounted OTHER>
86 requires std::convertible_to<OTHER*, T*>
99 explicit operator bool()
const;
110 operator const T*()
const;
RefCountedPtr(RefCountedPtr< OTHER > &&other)
Move from another RefCountedPtr, with a different type.
const T * operator->() const
T & operator*()
Dereference.
bool isValid() const
Check if the pointer is valid.
RefCountedPtr & operator=(const RefCountedPtr &other)
Assignment.
RefCountedPtr()=default
Default constructor.
friend class RefCountedPtr
void reset(T *ptr=nullptr)
Change the pointer.
RefCountedPtr(const RefCountedPtr< OTHER > &other)
Constructor from another RefCountedPtr, with a different type.
~RefCountedPtr()
Destructor.
const T & operator*() const
bool operator!() const
Check if the pointer is invalid.
RefCountedPtr(T *p)
Constructor from pointer. Adds to the refcount.
RefCountedPtr(std::unique_ptr< OTHER > &&other)
Constructor from unique_ptr. Adds to the refcount.
T * get()
Get the pointer.
T * operator->()
Dereference.
RefCountedPtr(const RefCountedPtr &other)
Copy constructor.
RefCountedPtr(RefCountedPtr &&other)
Move constructor.
A couple standard-library related concepts.