boost::multi::unique_array

A D‐dimensional array that is move only (cannot be copied into another unique_array)

Synopsis

Declared in <boost/multi/array.hpp>

template<
    typename T,
    boost::multi::dimensionality_type D,
    class Alloc>
class unique_array
    : public dynamic_array<T, D, Alloc>

Base Classes

Name

Description

dynamic_array<T, D, Alloc>

A multidimensional array (fix to a managed memory buffer)

Type Aliases

Name

Description

allocator_type

Allocator type (returned by get_allocator())

const_cursor

Indexable const‐cursor, pointer‐like objects that multidimensionally indexable (type usually returned by .home() const)

const_iterator

Random‐access iterator in the leading dimension, in general they dereference to an immutable subarrays of lower dimension (multi::const_subarray<...>) or, for D == 1, to an element immutable reference (T const&)

const_pointer

For D == 1 it is the pointer type to the elements (as immutables), otherwise it is void

const_reference

Subarray immutable reference after binding first index, multi::const_subarray<T, D ‐ 1, P> or, for D == 1, std::pointer_traits<const_pointer>::reference (usually T const&)

cursor

Indexable cursor, pointer‐like objects that multidimensionally indexable (type usually returned by .home())

decay_type

Associalted array value type (generally itself, multi::array<element, dimensionality, allocator_type>)

dimensionality_type

Integer type to store dimensionality information (e.g. 1D, 2D, 3D)

element

Element type (T)

element_const_ptr

The pointer type to a constant element (std::allocator_traits<allocator_type>::const_pointer, usually T const*)

element_cref

const‐qualified reference type to an element (usually T const&)

element_move_ptr

Pointer‐like type that produces an moved element (r‐value)

element_ptr

Pointer to element type (usually T*)

element_ref

Reference type to an element (usually T&)

element_type [deprecated]

(deprecated, use element)

extension_type [deprecated]

(deprecated) use extent_type

extent_type

A type to store the extent of an array (the range of valid indices in the leading dimension), returned from .extent().

extents_type

A type that stores the extents of the array or subarray (returned from .extents() and used for array constructors)

index

Type to store an index in the leading dimension

index_range

Type that represents a range of indices

indices_type

A tuple type that allows storing D indices to locate an element in the array

iterator

Random‐access iterator in the leading dimension, in general they dereference to a subarray of lower dimension (multi::subarray<...>) or, for D == 1 to an element reference (T&)

layout_type

Layout type (generally a strided layout multi::layout_t<D>)

move_iterator

Iterator in the leading dimension that mark elements as movable

pointer

For D == 1 it is the pointer type to the elements, otherwise it is void

reference

Subarray reference after binding first index, multi::subarray<T, D ‐ 1, P> or, for D == 1, std::pointer_traits<pointer>::reference (usually T&)

size_type

A type to hold the size of an array or subarray (size in the leading dimension) (usually signed)

value_type

The value type associated after binding the first index (generally multi::array<element, D ‐ 1>)

Member Functions

Name

Description

unique_array [constructor]

Constructors

~unique_array [destructor]

Destructor

operator=

Assignment operators

apply

(inherited) Acting on a tuple this is equivalent to .operator()(get<0>(tpl), get<1>(tpl), ...). (Typically, the argument type is of size D (tuple_size<Tuple>, returning an [const]element reference)

as_const

yields a const‐element view of the subarray, preventing modification of elements.

back

yields the back subarray of leading dimension (or element for D == 1) of a non‐empty array.

base

returns the base pointer of the array (arithmetic base of the layout, generally a pointer to the first element)

begin

returns an iterator to the beginning in the leading dimension

cbegin

returns an const‐iterator to the beginning

cend

returns an const‐iterator to the end

chunked

produces a subarray of higher dimension by chunking in the leading dimension (if count doesn't divide size, subelements and the end are left)

const_array_cast

creates a view of the array with element references with const‐removed

copy [deprecated]

materializes an independent, owning array copy of this view with the associated array‐value type (use unary prefix + as a shortcut)

data

for D == 1 only, gives a pointer to a memory range of .size(), for compatibility with std::vector and std::span.

data_elements

gets a pointer to a contigous range of size .num_elements() containing the data of the array

decay

materializes an independent, owning array copy of this view with the associated array‐value type (use unary prefix + as a shortcut)

diagonal

Subarray of lower dimension that represents the main diagonal of a square array

dropped

yields a subarray of the same dimensionally in which the first count elements are dropped.

element_moved

An array view in which element references are r‐values

element_transformed

a view with the elements transformed

elements

yields a random‐access range with all the elements of the array (no copies or allocations are made, O(1) operation)

end

returns an iterator to the end in the leading dimension

extensions [deprecated]

Deprecated, prefer extents().

extents

Returns the index extensions (structured cartesian product of half‐open ranges) for all dimensions as an extents_type (extents_t<D>), a tuple of D index_extension values each encoding [first, last)]. The result can be passed directly to array constructors or compared for equality of extents. Prefer this over the deprecated extensions().

flatted

yields a view of the array that is flattened in the first two leading dimensions

flattened

yields a view of the array that is flattened in the first two leading dimensions

front

yields the front subarray of leading dimension (or element for D == 1) of a non‐empty array.

get_allocator

returns the allocator that is used to acquire/release memory and to construct/destroy the elements in that memory

home

returns a cursor pointing to the top corner element of the array

is_compact [deprecated]

is_flattable [deprecated]

layout

returns the internal layout information of the array

max_size

returns the maximum number of elements that the vector can hold.

mbegin

returns an move‐iterator (moves on dereference) to the beginning in the leading dimension

member_cast

yields a view of the array containing a specific member of original element type

mend

returns an move‐iterator (moves on dereference) to the ending in the leading dimension

move

yields a subarray whose elements are marked for move

operator delete

Delete operator

operator new

New operators

operator&

Address‐of operators

operator()

Subarray returning operator (takes multiple parameters, the number of parameters is equal or lower than the number of dimensions, individual arguments can be single indices or ranges)

operator+

materializes an independent, owning array copy of this view with the associated array‐value type

operator[]

Subscript operators (takes multiple parameters, the number of parameters is equal or lower than the number of dimensions, individual arguments can be single indices or ranges)

operator~

yields a transpose view (same as .transposed())

origin [deprecated]

partitioned

yields a subarray of higher dimension by splitting the leading dimension into n equal‐sized partitions (n must divide size())

raw_array_cast

yields a view of the array where the underlying memory handle is a raw pointer (in general T*), useful for lambda kernels. Handler must be convertible with a pointer (e.g. through std::to_address).

reindexed

yields an equivalent subarray with a specific starting index

reinterpret_array_cast

yields a view of the subarray where elements are reinterpreted as a different type (elements must have compatible size)

reset

resets the array to a new size (or empty) and reclaims the memory.

reversed

yields a view of the array with the leading dimension in the reverse order (e.g. a.reversed()[i][j]== a[a.size() ‐ 1 ‐ i][j])

rotated

yields a view of the array where the indices are rotated (to the left) (e.g. a.rotated()[i][j][k]== a[j][k][i])

serialize

Serializes the array shape and elements into arxiv. On save: writes extensions then elements. On load: reads extensions and resizes the array if needed before loading elements. Compatible with Boost.Serialization and Cereal archives

size

returns the size of the array in the leading dimension

sliced

yields a subarray‐view from index first to index last (not inclusive) skipping step in the leading dimension

static_array_cast

yields a view of the array in which the internal representation is static_cast to another type (and/or pointer)

strided

yields a subarray‐view of the array with skipping step in the leading dimension

strides

returns the layout internal strides of an array as a tuple

swap

taked

yields an array‐view of the same dimensionality taking the first count subarrays in the leading dimension

transposed

yields a transpose view , that exchanges the first two indices

unordered

yields a view in which index access is unordered (an arbitrary transposition of indices generally to optimize access)

unrotated

yields a view of the array where the indices are unrotated (to the right, opposite to .rotated()) (e.g. a.unrotated()[i][j][k]== a[k][i][j], a.rotated().unrotated() is the same as a)

operator Range

Conversion to Range

operator To&

Conversion operators

operator To const&

Conversion to To

operator std::span<U>

Conversion to span

operator std::span<U const>

conversion to std::span (D == 1 only)

operator==

Equality operator

operator!=

Inequality operator

operator<

Less‐than operators (all ordering operations are lexicographical order, subarray by subarray, recursively)

operator<=

Less‐than‐or‐equal operator

operator>

Greater‐than operator

Using Declarations

Name

Description

Unnamed using

apply

Acting on a tuple this is equivalent to .operator()(get<0>(tpl), get<1>(tpl), ...). (Typically, the argument type is of size D (tuple_size<Tuple>, returning an [const]element reference)

decay

copies the array into a new independent array (allocates).

diagonal

yield a array reference of lower dimension with the diagonal elements

difference_type

Signed integer type to represent difference between indices (usually std::ptrdiff_t)

dimensionality

Dimensionality value of the array (generally D)

dropped

(inherited) yields an array of the same dimensionality with the first n dropped in the leading dimension.

element

Element type (generally T)

element_ptr

Element pointer type (generally T*)

empty

checks if the container has no elements.

extent

returns the extent of the array in the leading dimension

extents

returns the extents of the array (Cartesian product of valid indices)

flattened

(inherited) yields a view of the array that is flattened in the first two leading dimensions

home

(inherited) returns a cursor pointing to the top corner element of the array

index

Type to store an array index in the leading dimension

index_extension

Type that describes the extents in the leading dimension

indexes

D‐tuple type that stores the indices of an array

is_empty

checks if the container has no elements (same as empty()).

layout

returns the layout of the array.

nelems

returns the nelems layout (convex hull data size) of the array.

num_elements

returns the total number of elements.

operator()

Subscript operator (takes multiple parameters, the number of parameters is equal or lower than the number of dimensions, individual arguments can be single indices or ranges)

[boost/multi/dynamic_array-00/operator].adoc[operator[]]

Inherited indexed access

operator~

(inherited) yields a transpose view (same as .transposed())

partitioned

yields an array view of higher‐dimensionality by partitioning the array in the leading dimensions.

rank_v

Integer constant with the rank of the array

raw_array_cast

(inherited) yields a view of the array where the underlying memory handle is a raw pointer (in general T*), useful for lambda kernels. Handler must be convertible with a pointer (e.g. through std::to_address).

reinterpret_array_cast

(inherited) yields a view of the subarray where elements are reinterpreted as a different type (elements must have compatible size)

rotated

(inherited) yields a view of the array where the indices are rotated (to the left) (e.g. a.rotated()[i][j][k]== a[j][k][i])

size_type

Integer type to represent size in the leading dimension (usually std::ptrdiff_t)

sizes

returns a tuple decribing sizes across all the dimensions of the array.

sizes_type

D‐tuple type that stores the sizes of an array

sliced

(inherited) A subarray‐view from index first to index last (not inclusive) skipping step in the leading dimension

stride

returns the layout's stride (distance between elements in memory) in the leading dimension.

stride_type

Stride type (generally std::ptrdiff_t)

strided

yields an array view that skips step subarrays in the leading dimension

strides_type

Type that represents the layout strides (generally a D‐tuple)

taked

(inherited) yields an array‐view of the same dimensionality taking the first count subarrays in the leading dimension

transposed

(inherited) yields a transposed view, that exchanges the first two indices

unordered

(inherited) yields a view in which index access is unordered (an arbitrary transposition of indices generally to optimize access)

unrotated

(inherited) yields a view of the array where the indices are rotated (to the left) (e.g. a.unrotated()[i][j][k]== a[k][i][j])

Non-Member Functions

Name

Description

move

yields an array reference marked for move; for subarrays (including r‐value subarrays), its elements are marked as movable, for array values this has the same effect as std::move.

move

yields an array reference marked for move; for subarrays (including r‐value subarrays), its elements are marked as movable, for array values this has the same effect as std::move.

move

yields an array reference marked for move; for subarrays (including r‐value subarrays), its elements are marked as movable, for array values this has the same effect as std::move.

operator!=

Inequality operator

operator!=

Inequality operator

operator==

Equality operator

operator==

Equality operator

swap

swaps the contents of subarrays with other (extents must match, doesn't allocate, O(N) operations)

swap

swaps the contents of subarrays with other (extents must match, doesn't allocate, O(N) operations)

swap

swaps the contents of two dynamic arrays (extents must match, doesn't allocate, O(N) operations)

swap

swaps the contents of subarrays with other (extents must match, doesn't allocate, O(N) operations)

swap

swaps the contents of subarrays with other (extents must match, doesn't allocate, O(N) operations)

Derived Classes

Name

Description

array

A multidimensional array value

Created with MrDocs