Fixed order shape with mixed size capability. More...
#include <kwk/utility/container/shape.hpp>
Fixed order shape with mixed size capability.
Required header:
kwk::shape defines and optimally stores a set of integral values representing the size of a container along a fixed number of dimensions (or Order). Those sizes can be either specified at runtime or at compile-time. kwk::shape then provides an interface to query informations about those dimensions, sizes and compare shapes.
kwk::shape can be defined in two ways:
using the kwk::of_size function. This is the main process of building a size to pass to the constructor of containers as it leverages all the minutiae of defining the kwk::shape type in itself.
defining the layout of the kwk::shape using Extent and manually initializing it.
| D | List of Extent types |
Public Member Functions | |
| constexpr | shape () noexcept=default |
| Constructs a default kwk::shape equals to [0 0 ... 0]. | |
| constexpr | shape (shape const &d) noexcept |
| Copy constructor. | |
| template<concepts::extent... T> requires ( std::is_constructible_v<parent, int,T...> ) | |
| constexpr | shape (T... d) noexcept |
| Construct from a subset of Extent. | |
| template<std::integral... Coords> requires (static_order == sizeof...(Coords)) | |
| constexpr bool | contains (Coords... p) const noexcept |
| Check if a position fits into current shape volume. | |
| template<auto... D2> requires ( constraint_t::is_contructible_from<parent{},typename shape<D2...>::parent{}>() ) | |
| explicit (static_order !=sizeof...(D2)) const expr shape(shape< D2... > const &other) noexcept | |
| Construct shape from another shape type. | |
| template<auto... D2> | |
| constexpr bool | fit_constraints (shape< D2... > const &ref) const noexcept |
| Check if a shape fit current's shape constraints on size and dimension. | |
| constexpr std::int32_t | nbdims () const noexcept |
| Number of non-trivial dimensions. | |
| constexpr std::int32_t | numel () const noexcept |
| Number of elements. | |
| template<typename... Slicers> requires ( sizeof...(Slicers) <= static_order ) | |
| constexpr auto | operator() (Slicers const &... s) const noexcept |
| Shape slicing interface. | |
| constexpr shape & | operator= (shape const &other) &noexcept |
| Assignment operator. | |
Static Public Member Functions | |
| static constexpr auto | order () noexcept |
| Number of dimensions. | |
Static Public Attributes | |
| static constexpr bool | is_dynamic = parent::is_dynamic |
| Indicates that the shape has at least one dimension specified at runtime. | |
| static constexpr bool | is_fully_dynamic = parent::is_fully_dynamic |
| Indicates that the shape's dimensions are all specified at runtime. | |
| static constexpr bool | is_fully_static = parent::is_fully_static |
| Indicates that the shape's dimensions are all specified compile-time. | |
| static constexpr std::int32_t | static_order = parent::static_size |
| Compile-time value for Order. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, shape const &s) |
| Stream insertion operator. | |
| template<auto... D2> | |
| constexpr bool | operator== (shape const &a, shape< D2... > const &b) noexcept |
| Equality comparison operator. | |