diff --git a/include/highfive/bits/H5Inspector_misc.hpp b/include/highfive/bits/H5Inspector_misc.hpp index 3f69276c4..b69888043 100644 --- a/include/highfive/bits/H5Inspector_misc.hpp +++ b/include/highfive/bits/H5Inspector_misc.hpp @@ -132,6 +132,10 @@ inspector { // If this value is false: serialize, unserialize are mandatory static constexpr bool is_trivially_copyable + // Is this type trivially nestable, i.e. is type[n] a contiguous + // array of `base_type[N]`? + static constexpr bool is_trivially_nestable + // Reading: // Allocate the value following dims (should be recursive) static void prepare(type& val, const std::vector dims) @@ -162,6 +166,7 @@ struct type_helper { static constexpr size_t ndim = 0; static constexpr size_t recursive_ndim = ndim; static constexpr bool is_trivially_copyable = std::is_trivially_copyable::value; + static constexpr bool is_trivially_nestable = is_trivially_copyable; static std::vector getDimensions(const type& /* val */) { return {}; @@ -206,6 +211,7 @@ struct inspector: type_helper { using hdf5_type = int8_t; static constexpr bool is_trivially_copyable = false; + static constexpr bool is_trivially_nestable = false; static hdf5_type* data(type& /* val */) { throw DataSpaceException("A boolean cannot be read directly."); @@ -255,6 +261,7 @@ struct inspector: type_helper { using hdf5_type = hobj_ref_t; static constexpr bool is_trivially_copyable = false; + static constexpr bool is_trivially_nestable = false; static hdf5_type* data(type& /* val */) { throw DataSpaceException("A Reference cannot be read directly."); @@ -287,7 +294,8 @@ struct inspector> { static constexpr size_t ndim = 1; static constexpr size_t recursive_ndim = ndim + inspector::recursive_ndim; static constexpr bool is_trivially_copyable = std::is_trivially_copyable::value && - inspector::is_trivially_copyable; + inspector::is_trivially_nestable; + static constexpr bool is_trivially_nestable = false; static std::vector getDimensions(const type& val) { std::vector sizes(recursive_ndim, 1ul); @@ -350,6 +358,7 @@ struct inspector> { static constexpr size_t ndim = 1; static constexpr size_t recursive_ndim = ndim; static constexpr bool is_trivially_copyable = false; + static constexpr bool is_trivially_nestable = false; static std::vector getDimensions(const type& val) { std::vector sizes{val.size()}; @@ -396,8 +405,9 @@ struct inspector> { static constexpr size_t ndim = 1; static constexpr size_t recursive_ndim = ndim + inspector::recursive_ndim; static constexpr bool is_trivially_copyable = std::is_trivially_copyable::value && - sizeof(type) == N * sizeof(T) && - inspector::is_trivially_copyable; + inspector::is_trivially_nestable; + static constexpr bool is_trivially_nestable = (sizeof(type) == N * sizeof(T)) && + is_trivially_copyable; static std::vector getDimensions(const type& val) { std::vector sizes{N}; @@ -466,7 +476,8 @@ struct inspector { static constexpr size_t ndim = 1; static constexpr size_t recursive_ndim = ndim + inspector::recursive_ndim; static constexpr bool is_trivially_copyable = std::is_trivially_copyable::value && - inspector::is_trivially_copyable; + inspector::is_trivially_nestable; + static constexpr bool is_trivially_nestable = false; static std::vector getDimensions(const type& /* val */) { throw DataSpaceException("Not possible to have size of a T*"); @@ -496,7 +507,8 @@ struct inspector { static constexpr size_t ndim = 1; static constexpr size_t recursive_ndim = ndim + inspector::recursive_ndim; static constexpr bool is_trivially_copyable = std::is_trivially_copyable::value && - inspector::is_trivially_copyable; + inspector::is_trivially_nestable; + static constexpr bool is_trivially_nestable = is_trivially_copyable; static void prepare(type& val, const std::vector& dims) { if (dims.size() < 1) { diff --git a/include/highfive/boost.hpp b/include/highfive/boost.hpp index fb8a709c5..795a4021d 100644 --- a/include/highfive/boost.hpp +++ b/include/highfive/boost.hpp @@ -19,7 +19,9 @@ struct inspector> { static constexpr size_t ndim = Dims; static constexpr size_t recursive_ndim = ndim + inspector::recursive_ndim; static constexpr bool is_trivially_copyable = std::is_trivially_copyable::value && - inspector::is_trivially_copyable; + inspector::is_trivially_nestable; + static constexpr bool is_trivially_nestable = false; + static std::vector getDimensions(const type& val) { std::vector sizes; @@ -92,6 +94,7 @@ struct inspector> { static constexpr size_t recursive_ndim = ndim + inspector::recursive_ndim; static constexpr bool is_trivially_copyable = std::is_trivially_copyable::value && inspector::is_trivially_copyable; + static constexpr bool is_trivially_nestable = false; static std::vector getDimensions(const type& val) { std::vector sizes{val.size1(), val.size2()}; diff --git a/include/highfive/eigen.hpp b/include/highfive/eigen.hpp index aaad280ef..4a0b293fd 100644 --- a/include/highfive/eigen.hpp +++ b/include/highfive/eigen.hpp @@ -30,7 +30,8 @@ struct eigen_inspector { static constexpr size_t recursive_ndim = ndim + inspector::recursive_ndim; static constexpr bool is_trivially_copyable = is_row_major() && std::is_trivially_copyable::value && - inspector::is_trivially_copyable; + inspector::is_trivially_nestable; + static constexpr bool is_trivially_nestable = false; static std::vector getDimensions(const type& val) { std::vector sizes{static_cast(val.rows()), static_cast(val.cols())};