multi_array_refmulti_array_ref is a multi-dimensional container
adaptor. It provides the MultiArray interface over any contiguous
block of elements. multi_array_ref exports the
same interface as multi_array, with the exception
of the constructors.
Model Of.multi_array_ref models
MultiArray,
CopyConstructible.
and depending on the element type, it may also model
EqualityComparable and LessThanComparable.
Detailed descriptions are provided here only for operations that are
not described in the multi_array reference.
Synopsis
>
class multi_array_ref {
public:
// types:
typedef ValueType element;
typedef *implementation-defined* value_type;
typedef *implementation-defined* reference;
typedef *implementation-defined* const_reference;
typedef *implementation-defined* difference_type;
typedef *implementation-defined* iterator;
typedef *implementation-defined* const_iterator;
typedef *implementation-defined* reverse_iterator;
typedef *implementation-defined* const_reverse_iterator;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
// template typedefs
template struct subarray;
template struct const_subarray;
template struct array_view;
template struct const_array_view;
// structors
template
explicit multi_array_ref(element* data, const ExtentList& sizes,
const storage_order& store = c_storage_order());
explicit multi_array_ref(element* data, const extents_tuple& ranges,
const storage_order& store = c_storage_order());
multi_array_ref(const multi_array_ref& x);
~multi_array_ref();
// modifiers
multi_array_ref& operator=(const multi_array_ref& x);
template multi_array_ref& operator=(const Array& x);
// iterators:
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
reverse_iterator rbegin();
reverse_iterator rend();
const_reverse_iterator rbegin() const;
const_reverse_iterator rend() const;
// capacity:
size_type size() const;
size_type num_elements() const;
size_type num_dimensions() const;
// element access:
template
element& operator()(const IndexList& indices);
template
const element& operator()(const IndexList& indices) const;
reference operator[](index i);
const_reference operator[](index i) const;
array_view::type operator[](const indices_tuple& r);
const_array_view::type operator[](const indices_tuple& r) const;
// queries
element* data();
const element* data() const;
element* origin();
const element* origin() const;
const size_type* shape() const;
const index* strides() const;
const index* index_bases() const;
// comparators
bool operator==(const multi_array_ref& rhs);
bool operator!=(const multi_array_ref& rhs);
bool operator<(const multi_array_ref& rhs);
bool operator>(const multi_array_ref& rhs);
bool operator>=(const multi_array_ref& rhs);
bool operator<=(const multi_array_ref& rhs);
// modifiers:
template
void assign(InputIterator begin, InputIterator end);
template
void reshape(const SizeList& sizes)
template void reindex(const BaseList& values);
void reindex(index value);
};
]]>
Constructorstemplate <typename ExtentList>
explicit multi_array_ref(element* data,
const ExtentList& sizes,
const storage_order& store = c_storage_order(),
const Allocator& alloc = Allocator());
This constructs a multi_array_ref using the specified
parameters. sizes specifies the shape of the
constructed multi_array_ref. store
specifies the storage order or layout in memory of the array
dimensions. alloc is used to
allocate the contained elements.
ExtentList RequirementsExtentList must model Collection.
Preconditionssizes.size() == NumDims;::type ranges,
const storage_order& store = c_storage_order());]]>
This constructs a multi_array_ref using the specified
parameters. ranges specifies the shape and
index bases of the constructed multi_array_ref. It is the result of
NumDims chained calls to
extent_gen::operator[]. store
specifies the storage order or layout in memory of the array
dimensions.
This constructs a shallow copy of x.
Complexity Constant time (for contrast, compare this to
the multi_array class copy constructor.
Modifiers
multi_array_ref& operator=(const Array& x);]]>
This performs an element-wise copy of x
into the current multi_array_ref.Array RequirementsArray must model MultiArray.
Preconditionsstd::equal(this->shape(),this->shape()+this->num_dimensions(),
x.shape());Postconditions(*.this) == x;ComplexityThe assignment operators perform
O(x.num_elements()) calls to element's
copy constructor.