Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

n_index_t

Variadic template class n_index_t describes a position inside of the N-dimensional container. Specifically, the number of dimensions and the of index value of each.

Syntax

template<typename... TypeListT> class n_index_t

Description

n_index_t represents a position inside an n-dimensional space as a sequence of index value for each dimension. The index of each dimension can be represented by different types. This flexibility allows the same interface to be used to declare n_index_t with indices that are fully known at compile time with fixed<int NumberT>, or to be only known at runtime with int, or only known at runtime but with a guarantee will be a multiple of an alignment with aligned<int Alignment>. For more details, see the Number representation section.

Objects of this class may be used to identify a cell in a container, describe the inclusive lower bounds for n_bounds(), n-dimensional position for accessor's translated_to().

The following table provides information about the template arguments for n_index_t.

Template Argument

Description

typename... TypeListT

Comma separated list of types, where the number of types provided controls how many dimensions there are. Each type in the list identifies how the index of the corresponding dimension is to be represented. The order of the dimensions is the same order as C++ subscripts declaring a multi-dimensional array, from leftmost to rightmost.

Requirements: Type must be int, or fixed<NumberT>, or aligned<AlignmentT>.

The following table provides information about the members of n_index_t

Member

Description

static constexpr int rank;

Number of dimensions.

static constexpr int row_dimension = rank-1;
Index of last dimension, row.
n_index_t()

Default constructor. Uses default values for extent types.

Requirements: Every type in TypeListT is default constructible.

Effects: Construct n_index_t, uses default values of each type in TypeListT for the dimesnion sizes. In general only correctly initialized when every type is a fixed<NumberT>.

n_index_t(const n_extent_t &a_other)

Copy constructor.

Effects: Construct n_index_t, copying index value of each dimension from a_other.

explicit n_index_t(const TypeListT & … a_values)

Returns: The last extent in its native type

Effects: Construct n_index_t, initializing each dimension with the corresponding value from the list of a_values passed as an argument. In use, a_values is a comma separate list of values whose length and types are defined by TypeListT.

The following table provides information about the friend functions of n_index_t

Friend Function Description
std::ostream& operator << (std::ostream& output_stream, const n_index_t & a_indices)

Effects: Append string representation of a_indices' values to a_output_stream.

Returns: Reference to a_output_stream for chained calls.