CopperSpice API  2.0.0
QSharedArrayPointer< T > Class Template Reference

Stores a shared pointer to a dynamically allocated array of objects. More...

Inheritance diagram for QSharedArrayPointer< T >:
QSharedPointer< T >

Public Typedefs

using element_type = typename std::shared_ptr< cs_add_missing_extent_t< T > >::element_type
 
using ElementType = element_type
 
using pointer = typename std::shared_ptr< cs_add_missing_extent_t< T > >::pointer
 
using Pointer = pointer
 
using weak_type = QWeakPointer< cs_add_missing_extent_t< T > >
 
using WeakType = weak_type
 
- Public Typedefs inherited from QSharedPointer< T >
using element_type = typename std::shared_ptr< T >::element_type
 
using ElementType = element_type
 
using pointer = element_type *
 
using Pointer = pointer
 
using weak_type = QWeakPointer< T >
 
using WeakType = weak_type
 

Public Methods

 QSharedArrayPointer (const QSharedArrayPointer< element_type > &other)
 
 QSharedArrayPointer (const QSharedArrayPointer< element_type[]> &other)
 
 QSharedArrayPointer (QSharedArrayPointer< element_type > &&other)
 
 QSharedArrayPointer (QSharedArrayPointer< element_type[]> &&other)
 
 ~QSharedArrayPointer ()
 
bool isNull () const
 
element_typeoperator* () const noexcept
 
QSharedArrayPointer & operator= (const QSharedArrayPointer< element_type > &other)
 
QSharedArrayPointer & operator= (const QSharedArrayPointer< element_type[]> &other)
 
QSharedArrayPointer & operator= (QSharedArrayPointer< element_type > &&other)
 
QSharedArrayPointer & operator= (QSharedArrayPointer< element_type[]> &&other)
 
element_typeoperator[] (std::size_t index) const noexcept
 
void swap (QSharedArrayPointer &other)
 
- Public Methods inherited from QSharedPointer< T >
constexpr QSharedPointer () noexcept
 
 QSharedPointer (const QSharedPointer< T > &other) = default
 
template<typename U >
 QSharedPointer (const QSharedPointer< U > &p) noexcept
 
template<typename U >
 QSharedPointer (const QSharedPointer< U > &p1, element_type *p2) noexcept
 
template<typename U >
 QSharedPointer (const QWeakPointer< U > &p)
 
template<typename U >
 QSharedPointer (const std::shared_ptr< U > &p) noexcept
 
 QSharedPointer (QSharedPointer< T > &&other) = default
 
template<typename U >
 QSharedPointer (QSharedPointer< U > &&p) noexcept
 
template<typename U >
 QSharedPointer (QSharedPointer< U > &&p1, element_type *p2) noexcept
 
template<typename U , typename Deleter >
 QSharedPointer (QUniquePointer< U, Deleter > &&p)
 
constexpr QSharedPointer (std::nullptr_t) noexcept
 
template<typename Deleter >
 QSharedPointer (std::nullptr_t, Deleter d)
 
template<typename Deleter , typename Alloc >
 QSharedPointer (std::nullptr_t, Deleter d, Alloc a)
 
template<typename U >
 QSharedPointer (std::shared_ptr< U > &&p) noexcept
 
template<typename U >
 QSharedPointer (U *p)
 
template<typename U , typename Deleter >
 QSharedPointer (U *p, Deleter d)
 
template<typename U , typename Deleter , typename Alloc >
 QSharedPointer (U *p, Deleter d, Alloc a)
 
 ~QSharedPointer ()
 
void clear ()
 
template<typename U >
QSharedPointer< U > constCast () const
 
QSharedPointer< T > create (Args &&...args)
 
T * data () const
 
template<typename U >
QSharedPointer< U > dynamicCast () const
 
bool isNull () const
 
template<typename U >
QSharedPointer< U > objectCast () const
 
 operator bool () const
 
bool operator! () const
 
bool operator!= (const QSharedPointer< T > &other) const
 
bool operator!= (const T *ptr) const
 
bool operator!= (std::nullptr_t) const
 
T & operator* () const
 
T * operator-> () const
 
bool operator< (const QSharedPointer< T > &other) const
 
bool operator< (const T *ptr) const
 
bool operator< (std::nullptr_t) const
 
bool operator<= (const QSharedPointer< T > &other) const
 
bool operator<= (const T *ptr) const
 
bool operator<= (std::nullptr_t) const
 
QSharedPointer & operator= (const QSharedPointer< T > &other) = default
 
template<typename U >
QSharedPointer & operator= (const QSharedPointer< U > &p) noexcept
 
template<typename U >
QSharedPointer & operator= (const QWeakPointer< U > &p)
 
QSharedPointer & operator= (QSharedPointer< T > &&other) = default
 
template<typename U >
QSharedPointer & operator= (QSharedPointer< U > &&p) noexcept
 
bool operator== (const QSharedPointer< T > &other) const
 
bool operator== (const T *ptr) const
 
bool operator== (std::nullptr_t) const
 
bool operator> (const QSharedPointer< T > &other) const
 
bool operator> (const T *ptr) const
 
bool operator> (std::nullptr_t) const
 
bool operator>= (const QSharedPointer< T > &other) const
 
bool operator>= (const T *ptr) const
 
bool operator>= (std::nullptr_t) const
 
void reset ()
 
void reset (U *value)
 
void reset (U *value, Deleter d)
 
void reset (U *value, Deleter d, Alloc a)
 
template<typename U >
QSharedPointer< U > staticCast () const
 
void swap (QSharedPointer &other)
 
QWeakPointer< T > toWeakRef () const
 
long use_count () const noexcept
 

Related Functions

These are not member functions

 cs_add_missing_extent_t
 
QSharedArrayPointer< T > QMakeShared (std::size_t size)
 

Detailed Description

template<typename T>
class QSharedArrayPointer< T >

The QSharedArrayPointer class stores a shared pointer to a dynamically allocated array of objects. The array will be deleted when the last QSharedArrayPointer pointing to the array is destroyed or reset.

Additional Documentation

Refer to the QSharedPointer documentation for inherited methods like reset() and toWeakRef().

Example

void someFunction()
{
data[2] = 42;
return;
}

Member Typedef Documentation

template<typename T >
QSharedArrayPointer< T >::element_type

Typedef for std::shared_ptr< cs_add_missing_extent_t<T> >::element_type.

template<typename T >
QSharedArrayPointer< T >::ElementType

Typedef for element_type.

template<typename T >
QSharedArrayPointer< T >::pointer

Typedef for std::shared_ptr< cs_add_missing_extent_t<T> >::pointer.

template<typename T >
QSharedArrayPointer< T >::Pointer

Typedef for pointer.

template<typename T >
QSharedArrayPointer< T >::weak_type
template<typename T >
QSharedArrayPointer< T >::WeakType

Typedef for weak_type.

Constructor & Destructor Documentation

template<typename T >
QSharedArrayPointer< T >::QSharedArrayPointer ( const QSharedArrayPointer< element_type > &  other)

Copy constructs a new QSharedArrayPointer from other and returns a reference to this object.

template<typename T >
QSharedArrayPointer< T >::QSharedArrayPointer ( const QSharedArrayPointer< element_type[]> &  other)

Copy constructs a new QSharedArrayPointer from other and returns a reference to this object.

template<typename T >
QSharedArrayPointer< T >::~QSharedArrayPointer ( )

Destroys this QSharedArrayPointer.

If the current QSharedArrayPointer is not a nullptr, then the internal reference count is decremented. If the reference count is zero then the object it is pointing to will be destroyed.

template<typename T >
QSharedArrayPointer< T >::QSharedArrayPointer ( QSharedArrayPointer< element_type > &&  other)

Move constructs a new QSharedArrayPointer from other and returns a reference to this object.

template<typename T >
QSharedArrayPointer< T >::QSharedArrayPointer ( QSharedArrayPointer< element_type[]> &&  other)

Move constructs a new QSharedArrayPointer from other and returns a reference to this object.

Method Documentation

template<typename T >
bool QSharedArrayPointer< T >::isNull ( ) const

Returns true if the current QSharedArrayPointer contains a nullptr.

template<typename T >
element_type & QSharedArrayPointer< T >::operator* ( ) const
noexcept

Returns a reference to the first element in the array.

template<typename T >
QSharedArrayPointer & QSharedArrayPointer< T >::operator= ( const QSharedArrayPointer< element_type > &  other)

Copy assigns from other and returns a reference to this object.

template<typename T >
QSharedArrayPointer & QSharedArrayPointer< T >::operator= ( const QSharedArrayPointer< element_type[]> &  other)

Copy assigns from other and returns a reference to this object.

template<typename T >
QSharedArrayPointer & QSharedArrayPointer< T >::operator= ( QSharedArrayPointer< element_type > &&  other)

Move assigns from other and returns a reference to this object.

template<typename T >
QSharedArrayPointer & QSharedArrayPointer< T >::operator= ( QSharedArrayPointer< element_type[]> &&  other)

Move assigns from other and returns a reference to this object.

template<typename T >
element_type & QSharedArrayPointer< T >::operator[] ( std::size_t  index) const
noexcept

Returns a reference to the element with the given index.

template<typename T >
void QSharedArrayPointer< T >::swap ( QSharedArrayPointer< T > &  other)

Swaps the current pointer with other.

Friends And Related Function Documentation

cs_add_missing_extent_t ( )
related

Adds array brackets to T if it does not contain them. Implemented as a templated type trait.

QSharedArrayPointer< T > QMakeShared ( std::size_t  size)
related

Constructs a new array containing elements of type T. The number of elements in the array will be equal to the value for size. Each element will be value initialized.

Refer to default constructed elements for additional information.