Template Struct Dimension¶
Defined in File dim.hpp
Struct Documentation¶
-
template<size_t
Value
>
structripple
::
Dimension
¶ Defines a class to represent a dimension, where the value is known at compile time, but can also be evaluated at runtime as a size type.
The class should be used through the aliases when a single dimension must be specified to make code more readible:
// Not clear, what is 0? do_something(container, 0); // More clear, intention of x dimension application is known at call site. do_something(container, dimx());
The other use case is when used with
unrolled_for
, where is can be used more generically in a constexpr context:unrolled_for<num_dimensions>([] (auto dim_value) { // Compile time dimension can be used here: do_something(container, Dimension<dim_value>{}); });
or explicitly made
constexpr
(this can improve access performance):unrolled_for<num_dimensions>([] (auto dim_value) { constexpr auto dim = dim_value; // Access the dim element of a container: auto v = container[dim]; // Use in a template type: auto block = block_with_cx_padding<dim>(...); });
- Template Parameters
Value
: The value of the dimension.
Public Functions
-
constexpr
operator size_t
() const¶ Overload of operator size_t to convert a dimension to a size_t.
- Return
The value of the dimension.