Smart-pointers

Conception

Kind of smart pointers:

Weak::Ptr

This is the only reference pointer.

Unique::Ptr

Takes an ownership of object or array of objects

Shared::Ptr

Takes a partial ownership of object or array of objects by using extrusive reference-counting.

Intrusive::Ptr

The same as Shared::Ptr but uses intrusive reference-counting.

Reference

It’s a specialization of the Intrusive::Ptr.

Const::Ptr

An adaptor that makes a base pointer a constant.

Reverse::Ptr

An adaptor that reverses the increment and decrement operation of the base pointer.

Member map

Operators/Functionality Smart pointers
Reference Ownership Adaptors
Weak:: Unique:: Shared:: TS::Shared::
Intrusive:: Reference:: Const:: Reverse::
Ptr<T> Ptr<T[]>
Ptr<T> Ptr<T[]>
Ptr<T> Ptr<T[]>
Ptr<T> Ptr<T[]>
Ptr<T> Ptr<T>
Ptr<T> Ptr<T[]>
Ptr<T> Ptr<T[]>
Optional template parameters <…, Deleter>
<…, Deleter, Counter, DynamicAllocator>
<…, Adjuster>
Type typename Ptr::Type Base
Construction Ptr ptr(ptr’)
Ptr ptr = ptr’
Ptr ptr(T*)
Ptr ptr(null)
Ptr ptr = null
Ptr ptr(Ptr<U>(…));
Ptr ptr = Ptr<U>(…);
Ptr ptr(…[, Deleter]) Ptr ptr(…[, Deleter[, DynamicAlocator]])
Destruction ~Ptr() *this = null
Assignment ptr = ptr’ Copies a reference Moves an object Copyies an object’s reference and increments a counter
ptr = null Releases a reference Releases an object if (0 == —counter) { releases an object }
Pointer Specific
Dereference *ptr
Member access ptr.operator→()
Comparison
Equal ptr == ptr’
ptr == null
null == ptr
Not equal ptr != ptr’
ptr != null
null != ptr
Subcription ptr [Int(index)]
Arithmetic
Addition ptr + Int(index)
Subtraction ptr – Int(index)
Incrementing ptr++
++ptr
Decrementing ptr—
—ptr
Compound
assignment
ptr += Int(index)
ptr -= Int(index)
Relational
Subtraction ptr – ptr’
Greate than ptr > ptr’
Greate than
or equal to
ptr >= ptr’
Less than ptr < ptr’
Less than
or equal to
ptr <= ptr’
Particular
Detaching ptr.Weak() = null
Ownership object
(deleter)
ptr.owner()
Uniqueness ptr.unique()