56template <
class T>
class ptr {
57 friend struct std::less<
ptr<T>>;
70 explicit ptr(T &t) noexcept :
p(&t) {
p->add_reference(); }
72 ptr(
const ptr & other) noexcept :
p(other.p) {
p->add_reference(); }
76 if (
p->remove_reference() == 0)
86 otherp->add_reference();
87 if (
p->remove_reference() == 0)
102 if (
p->get_refcount() > 1) {
103 T *p2 =
p->duplicate();
105 p->remove_reference();
158template <
class T>
struct less<
GiNaC::ptr<T>> {
161 return less<T*>()(
lhs.p,
rhs.p);
Assertion macro definition.
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
Class of (intrusively) reference-counted pointers that support copy-on-write semantics.
friend bool operator==(const U *lhs, const ptr &rhs) noexcept
bool operator!=(const ptr< U > &rhs) const noexcept
friend bool operator!=(const ptr &lhs, const U *rhs) noexcept
friend bool operator!=(const U *lhs, const ptr &rhs) noexcept
ptr(T *t) noexcept
Bind ptr to newly created object, start reference counting.
friend std::ostream & operator<<(std::ostream &os, const ptr< T > &rhs)
bool operator==(const ptr< U > &rhs) const noexcept
ptr(const ptr &other) noexcept
void swap(ptr &other) noexcept
Swap the bound object of this ptr with another ptr.
T * operator->() const noexcept
void makewritable()
Announce your intention to modify the object bound to this ptr.
ptr & operator=(const ptr &other)
friend bool operator==(const ptr &lhs, const U *rhs) noexcept
T & operator*() const noexcept
friend T * get_pointer(const ptr &x) noexcept
ptr(T &t) noexcept
Bind ptr to existing reference-counted object.
Base class for reference-counted objects.
unsigned int refcount
reference counter
void set_refcount(unsigned int r) noexcept
unsigned int get_refcount() const noexcept
unsigned int add_reference() noexcept
unsigned int remove_reference() noexcept
bool operator()(const GiNaC::ptr< T > &lhs, const GiNaC::ptr< T > &rhs) const