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_bounds_generator

Facilitates simple creation of n_bounds_t objects. #include <sdlt/n_bounds.h>

Syntax

template<typename... TypeListT>
class n_bounds_generator;

namespace { 
    // Instance of generator object
    n_bounds_generator<> n_bounds; 
}

Description

The generator object provides recursively constructing operators [] for bounds_t<LowerT, UpperT> values allowing building of a n_bounds_t<…> instance one dimension at a time. Its main purpose is to allow a usage syntax that is similar to C multi-dimensional array definition:

Compare creating two n_bounds_t instances:

n_bounds_t<bounds_t<fixed<540>, fixed<1080>>,
           bounds_t<fixed<960>, fixed<1920>>> bounds1(bounds_t<540_fixed,1080_fixed>(), 
        bounds_t<960_fixed, 1920_fixed>));

n_bounds_t<bounds_t<int, int>,
           bounds_t<int, int>> bounds2(bounds_t<int, int>(540,960), 
        bounds_t<int, int>(960, 1920));
and the equivalent instances using the generator objects and factory functions
auto bounds1 = n_bounds[bounds(540_fixed, 1080_fixed)]
                       [bounds(960_fixed, 1920_fixed)];
auto bounds2 = n_bounds[bounds(540, 1080)]
                       [bounds(960, 1920)];
or alternatively using the operator() with n_index_t and n_extent_t generator objects
auto bounds1 = n_bounds(n_index[540_fixed][960_fixed], 
                         n_extent[540_fixed][960_fixed]);

auto bounds2 = n_bounds(n_index[540][960], 
                        n_extent[540][960]);

Class Hierarchy

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

The following table provides information on the template arguments for n_bounds_generator

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 bounds 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: types in the list be bounds_t<LowerT, UpperT>

The following table provides information on the types defined as members of n_bounds_generator in addition to those inherited from n_bounds_t

Member Types

Description

typedef n_bounds_t<TypeListT...> value_type

Type value that the any chained [] operator calls have produced.

The following table provides information on the members of n_bounds_generator in addition to those inherited from n_bounds_t

Member

Description

n_bounds_generator()

Requirements: TypeListT is empty

Effects: Construct generator with no bounds specified

n_bounds_generator(const n_bounds_generator &a_other) 

Effects: Construct generator copying any bounds values from a_other

template<typename LowerT, typename UpperT>
auto
operator [] (const bounds_t<LowerT, UpperT> & a_bounds) const 

Effects: build a n_bounds_generator<…> with additional rightmost bounds_t<LowerT, UpperT> based dimension.

Returns: n_bounds_generator<TypeListT..., bounds_t< LowerT, UpperT >>

template<class... IndexTypeListT, class... ExtentTypeListT>
auto operator () ( 
 const n_index_t<IndexTypeListT...> & a_indices,
 const n_extent_t<ExtentTypeListT...> & a_extents)  const

Requirements: rank of a_indices is same as rank of a_extents and TypeListT be empty

Effects: build a n_bounds_generator<…> where n-lower bounds are specified by a_indices, and n-upper bounds are calculated by adding a_extents to a_indices

Returns: n_bounds[bounds(a_indices.get<0>(),

a_indices.get<0>() + a_extents.get<0>())]

[bounds(a_indices.get<1>(),

a_indices.get<1>() + a_extents.get<1>())]

[bounds(a_indices.get<…>(),

a_indices.get<…>() + a_extents.get<…>())]

[bounds( a_indices.get<row_dimension>(),

a_indices.get< row_dimension >() + a_extents.get< row_dimension >())]

value_type value() const

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