Files
2025-10-25 03:02:53 +03:00

9.2 KiB
Raw Permalink Blame History

[mdspan.layout.reqmts]

23 Containers library [containers]

23.7 Views [views]

23.7.3 Multidimensional access [views.multidim]

23.7.3.4 Layout mapping [mdspan.layout]

23.7.3.4.2 Requirements [mdspan.layout.reqmts]

1

#

A type M meets the layout mapping requirements if

M models copyable and equality_comparable,

is_nothrow_move_constructible_v is true,

is_nothrow_move_assignable_v is true,

is_nothrow_swappable_v is true, and

the following types and expressions are well-formed and have the specified semantics.

🔗

typename M::extents_type

2

#

Result: A type that is a specialization of extents.

🔗

typename M::index_type

3

#

Result: typename M::extents_type::index_type.

🔗

typename M::rank_type

4

#

Result: typename M::extents_type::rank_type.

🔗

typename M::layout_type

5

#

Result: A type MP that meets the layout mapping policy requirements ([mdspan.layout.policy.reqmts]) and for which is-mapping-of<MP, M> is true.

🔗

m.extents()

6

#

Result: const typename M::extents_type&

🔗

m(i...)

7

#

Result: typename M::index_type

8

#

Returns: A nonnegative integer less than numeric_limits<typename M::index_type>::max() and less than or equal to numeric_limits<size_t>::max().

🔗

m(i...) == m(static_cast<typename M::index_type>(i)...)

9

#

Result: bool

10

#

Returns: true

🔗

m.required_span_size()

11

#

Result: typename M::index_type

12

#

Returns: If the size of the multidimensional index space m.extents() is 0, then 0, else 1 plus the maximum value of m(i...) for all i.

🔗

m.is_unique()

13

#

Result: bool

14

#

Returns: true only if for every i and j where (i != j || ...) is true,m(i...) != m(j...) is true.

[Note 1:

A mapping can return false even if the condition is met.

For certain layouts, it is possibly not feasible to determine efficiently whether the layout is unique.

— end note]

🔗

m.is_exhaustive()

15

#

Result: bool

16

#

Returns: true only if for all k in the range [0, m.required_span_size()) there exists an i such that m(i...) equals k.

[Note 2:

A mapping can return false even if the condition is met.

For certain layouts, it is possibly not feasible to determine efficiently whether the layout is exhaustive.

— end note]

🔗

m.is_strided()

17

#

Result: bool

18

#

Returns: true only if for every rank index r of m.extents() there exists an integer sr such that, for all i where (i+dr) is a multidimensional index in m.extents() ([mdspan.overview]),m((i + dr)...) - m(i...) equals sr.

[Note 3:

This implies that for a strided layoutm(i0,…,ik)=m(0,…,0)+i0×s0+⋯+ik×sk.

— end note]

[Note 4:

A mapping can return false even if the condition is met.

For certain layouts, it is possibly not feasible to determine efficiently whether the layout is strided.

— end note]

🔗

m.stride(r)

19

#

Preconditions: m.is_strided() is true.

20

#

Result: typename M::index_type

21

#

Returns: sr as defined in m.is_strided() above.

22

#

[Note 5:

It is not required for m.stride(r) to be well-formed if m.extents().rank() is zero, even if m.is_always_strided() is true.

— end note]

🔗

M::is_always_unique()

23

#

Result: A constant expression ([expr.const]) of type bool.

24

#

Returns: true only if m.is_unique() is true for all possible objects m of type M.

[Note 6:

A mapping can return false even if the above condition is met.

For certain layout mappings, it is possibly not feasible to determine whether every instance is unique.

— end note]

🔗

M::is_always_exhaustive()

25

#

Result: A constant expression ([expr.const]) of type bool.

26

#

Returns: true only if m.is_exhaustive() is true for all possible objects m of type M.

[Note 7:

A mapping can return false even if the above condition is met.

For certain layout mappings, it is possibly not feasible to determine whether every instance is exhaustive.

— end note]

🔗

M::is_always_strided()

27

#

Result: A constant expression ([expr.const]) of type bool.

28

#

Returns: true only if m.is_strided() is true for all possible objects m of type M.

[Note 8:

A mapping can return false even if the above condition is met.

For certain layout mappings, it is possibly not feasible to determine whether every instance is strided.

— end note]