Std::vector read/write


Hi I was wondering if it is possible to read/write std::vector to hdf5. Especially if the size of the array is not known at runtime.

Best regards,


Take a look at H5CPP. For example



Yes Paul, it is possible to do that. How do I know? I did exactly that something 2011-ish, 7 years later added template metaprogramming based pythonic syntax, this year feature detection idiom based generalized container support, generative programming technique based heuristics to choose between layout types.
If your goal is to write a library with similar features – great! But before you do that, you might want to do a research and understand what the landscape looks like, and most importantly why it is hard to develop libraries for the HDF5 system.

IF you really want to make your extendable dataset fast, you could write your own data pipeline based on direct chunks and BLAS level 3 blocking algorithms. Not easy to do, but has been done, on a dark night – out of necessity.

You could do all these, of course; or just use what is already been done.

Here is the documentation on h5::write, it takes an std::vector where T can be arbitrary POD_T including fundamental types. h5::append is based on direct chunk write, and is as fast as the underlying file system, even for tiny event such as High Frequency Trading bids – as it was designed for it.

best wishes: steven


Hi Paul,

You can also look at another project:

which was designed to map c++ types to hdf5 types

Best regards,