PVData C++  8.0.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Differences between std::vector and shared_vector

Differences in behavior

shared_vector models const-ness like shared_ptr. A equivalent of 'const std::vector<E>' is 'const shared_vector<const E>'. However, it is also possible to have 'const shared_vector<E>' analogous to 'E* const' and 'shared_vector<const E>' which is analogous to 'const E*'.

Copying a shared_vector, by construction or assignment, does not copy its contents. Modifications to one such "copy" effect all associated shared_vector instances.

std::vector::reserve(N) has no effect if N<=std::vector::capacity(). However, like resize(), shared_vector<E>::reserve() has the side effect of always calling make_unique().

Parts of std::vector interface not implemented

Mutating methods insert(), erase(), shrink_to_fit(), emplace(), and emplace_back() are not implemented.

shared_vector does not model an allocator which is bound to the object. Therefore the get_allocator() method and the allocator_type typedef are not provided.

The assign() method and the related constructor are not implemented at this time.

The comparison operators '>', '>=', '<=', and '<' are not implemented at this time.

Parts not found in std::vector

shared_vector has additional constructors from raw pointers and shared_ptr s.

Implicit casting is not allowed. Instead use const_shared_vector_cast()/freeze()/thaw() (Value const-ness and shared_vector) to casting between 'T' and 'const T'. Use static_shared_vector_cast() to cast between void and non-void (same const-ness).

To facilitate safe modification the methods unique() and make_unique() are provided.

The slice() method selects a sub-set of the shared_vector.

The low level accessors dataPtr(), dataOffset(), dataCount(), and dataTotal().