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

ID 767253
Date 9/08/2022
Public

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

Document Table of Contents

n_extent_generator

To facilitate simpler and clearer creation of n_extent_t objects.

Syntax
template<typename... TypeListT>
class n_extent_generator;

namespace { 
    // Instance of generator object
    n_extent_generator<> n_extent; 
}
Description

The generator object provides recursively constructing operators [] for fixed<>, aligned<>, and integer values allowing building of an n_extent_t <…> instance, one dimension at a time. The main purpose is to allow a usage syntax that is similar to C multi-dimensional array definition:

Compare the following examples, instantiating three n_extent_t instances. and using the generator object to instantiate equivalent instances.

n_extent_t<int, int> ext1(height, width);
n_extent_t<int, aligned<128>> ext2(height, width);
n_extent_t<fixed<1080>, fixed<1920>> ext3(1080_fixed, 1920_fixed);

auto ext1 = n_extent[height][width];
auto ext2 = n_extent[height][aligned<128>(width)];
auto ext3 = n_extent[1080_fixed][1920_fixed];

Class Hierarchy

It is expected that n_extent_generator < … > not be directly used as a data member or parameter, instead only n_extent_t <...> from which it is derived. The generator object n_extent can be automatically downcast any place expecting an n_extent_t<…> .

The following table provides the template arguments for n_extent_generator

Template Argument Description
typename... TypeListT
Comma separated list of types, where the number of types provided controls how many dimensions the generator currently represent. Each type in the list identifies how the size 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 is int, fixed<NumberT>, or aligned<AlignmentT>.

The following table provides information on the types defined as members of n_extent_generator in addition to those inherited from n_extent_t.

Member Type Description
typedef n_extent_t<TypeListT...> value_type
Type value that the any chained [] operator calls have produced.

The following table provides information on the members of n_extent_generator in addition to those inherited from n_extent_t

Member Description
n_extent_generator ()

Requirements: TypeListT is empty

Effects: Construct generator with no extents specified

n_extent_generator (const n_extent_generator &a_other)

Effects: Construct generator copying any extent values from a_other

n_extent_generator<TypeListT..., int> operator [] (int a_size) const

Requirements: a_size >= 0

Returns: n_extent_generator<…> with additional rightmost integer based extent.

n_extent_generator<TypeListT...,
          fixed<NumberT>> operator [] (fixed<NumberT> a_size) const

Requirements: a_size >= 0

Returns: n_extent_generator<…> with additional rightmost fixed<NumberT> extent.

n_extent_generator<TypeListT...,
          aligned<AlignmentT>> operator [] (aligned<AlignmentT> a_size)

Requirements: a_size >= 0

Returns: n_extent_generator<…> with additional rightmost aligned<AlignmentT> based extent.

value_type value() const 

Returns: n_extent_t<…> with the correct types and values of the multi-dimensional extents aggregated by the generator.