Closed jlperla closed 9 years ago
The extent function should always be constexpr
. If a view
is constructed with constant expression dimensions then the result of the extent function should be observable as constexpr
. This is what helps force optimization. Added note to extent function about return value for implicit dimensions of default constructed view and explicit dimensions queried with literal input value.
I think that a paragraph explaining why extents are tricky is useful. Maybe something like:
The complexity in implementing extents is that the type depends on whether the extent was given statically or dynamically. As discussed before, this is essential to ensure a zero-overhead penalty for the abstraction. For example, consider
view< int[ ][3][3] > array_1
vs.view< int[ ][ ][ ] > array_2
. Callingarray_1.extent(1)
returns aconstexpr const std::size_t
, whilearray_2.extent(1)
returns aconst std::size_
t. This static information is essential for the compiler to generate an efficientoperator()
or for interfacing libraries such as Eigen to query an underlying static extent to enable SIMD optimizations based on the known extent length, etc.