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

ID 767253
Date 11/07/2023
Public

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

Document Table of Contents

make_ n_container template function

Factory function to construct an instance of a properly-typed n_container<…> based on n_extent_t passed to it.

Syntax

template<
    typename PrimitiveT,
    typename LayoutT,
    typename AllocatorT = allocator::default_alloc,
    typename ExtentsT
>
auto make_n_container(const ExtentsT &_extents)
->n_container<PrimitiveT, LayoutT, ExtentsT, AllocatorT>

Description

Use make_n_container to more easily create an n-dimensional container using template argument deduction, and avoid specifying the type of extents.

An example of the instantiation of a High Definition image object is below.

typedef n_container<RGBAs, layout::soa, 
                    n_extent_t<int, int>> HdImage;
HdImage image1(n_extent[1080][1920]);

Alternatively, it is possible to use factory function with the C++11 keyword auto, as shown below.

auto image1 = make_n_container<RGBAs, 
                          layout::soa>(n_extent[1080][1920]);