Closed 1uc closed 4 months ago
we're seeing an error now like RuntimeError: Not possible to serialize a T*
I'm guessing because of this...
testing locally without this commit to be sure
edit: no error confirmed after popping current top two commits (including this one)
Thanks for letting us know. I've checked the PR again, and nothing sticks out as wrong. Do you know what T
is and if T*
is inside some other container, the type of that container?
T is a double
in this context, but we do some pointer casting to force a 1d vector data pointer into a 2 or 3d dataset
which is feasibly not how it should be done, but it's what has worked until now
template<std::size_t dim, typename Data>
NO_DISCARD auto pointer_dim_caster(Data* data)
{
if constexpr (dim == 1)
return data;
if constexpr (dim == 2)
return reinterpret_cast<Data const** const>(data);
if constexpr (dim == 3)
return reinterpret_cast<Data const*** const>(data);
}
Yes! That was an interesting surprise. We still have a test for a variation using write_raw
here:
https://github.com/BlueBrain/HighFive/blob/070badf6935e17bb74c5a9d0e08969f640b4a87b/tests/unit/test_legacy.cpp#L27-L29
I see three options:
write_raw
without (or with) the magic in pointer_dim_caster
.reshapeMemSpace
, see #991. Comments are welcome. mdspan
which should be one of the next things I'd like to implement.what we're doing is essentially the same as the legacy test, which I'm surprised if it's passing
I can test write_raw
without the reinterpret_cast, as the shape given is the correct dimension
we have no plans for C++23 right now
without the reinterpret_cast I get
oh I wasn't using write_raw
, testing...
The write_raw
doesn't care about dimensions and such, it's just a very shallow wrapper:
https://github.com/BlueBrain/HighFive/blob/070badf6935e17bb74c5a9d0e08969f640b4a87b/include/highfive/bits/H5Slice_traits_misc.hpp#L268-L279
The type of the pointer doesn't matter, they're all converted to void *
and sent to HDF5.
it seems ok with write_raw
and no reintrepret_cast :+1:
Glad to hear that!
This change will be documented in the Migration Guide via https://github.com/BlueBrain/HighFive/pull/996.
Migration Guide: https://bluebrain.github.io/HighFive/md__2home_2runner_2work_2_high_five_2_high_five_2doc_2migration__guide.html
We need this because
std::span
is consideredstd::is_trivially_copyable
.