|
H5CPP
v1.14.0
Modern C++ templates for HDF5 serial and parallel I/O
|
|
Every h5cpp resource handle follows the RAII idiom: the HDF5 object is opened (or created) on construction and closed automatically on destruction. The handle owns one reference to the underlying hid_t; copy-construction and copy-assignment increment HDF5's refcount so the object survives until the last copy goes out of scope, and move-construction / move-assignment transfer the reference (the source is invalidated to H5I_UNINIT).
The contract:
hid_t (and calls H5Iinc_ref so h5cpp's reference is independent of any pre-existing C-side owner) or accepts a brace initializer {handle} (which takes ownership without incrementing — used when h5cpp itself produced the handle).H5Fclose for h5::fd_t, H5Dclose for h5::ds_t, etc.) but only after H5Iis_valid(handle) returns true, so destroying a moved-from or default-constructed handle is a no-op.H5Iinc_ref. Both copies refer to the same HDF5 object and each independently decrements the refcount on destruction.Implementation lives in h5cpp/H5Iall.hpp template h5::impl::detail::hid_t<T, capi_close, from_capi, to_capi, hdf5_class>. The full catalog of public handle aliases — file, dataset, group, attribute, object, dataspace, datatype, property lists, and the async variants — is in Handles, Descriptors & Property Lists.
See also: Handles, Descriptors & Property Lists, Conversion Policy