1 #ifndef MF_NDARRAY_FRAME_FORMAT_H_
2 #define MF_NDARRAY_FRAME_FORMAT_H_
4 #include "../../common.h"
5 #include "../../utility/misc.h"
16 std::type_index elem_type_ = std::type_index(
typeid(
void));
17 std::size_t elem_size_ = 0;
18 std::size_t elem_alignment_ = 0;
23 std::size_t stride_ = 0;
33 template<
typename Elem>
35 static_assert(
sizeof(Elem) >=
alignof(Elem),
"sizeof always larger or equal to alignof");
38 format.elem_type_ = std::type_index(
typeid(Elem));
39 format.elem_size_ =
sizeof(Elem);
40 format.elem_alignment_ =
alignof(Elem);
45 template<
typename Elem>
47 std::type_index query_type(
typeid(Elem));
48 return (elem_type_ == query_type);
52 std::size_t
elem_size() const noexcept {
return elem_size_; }
54 std::size_t
stride() const noexcept {
return stride_; }
55 std::size_t
padding() const noexcept {
return (stride_ - elem_size_); }
#define MF_EXPECTS(condition)
Definition: common.h:27
bool is_nonzero_multiple_of(T x, T base)
Check if x is a non-zero multiple of base.
Definition: misc.h:43