The solution lay in changing the write function to accept file and memory data types:
bool write(const my_container<unsigned int>& p, const H5::DataType& file_datatype, const H5::DataType& mem_datatype, const std::string& datapath) const {
try {
const hsize_t h5size[1] = { p.size() };
const H5::DataSpace h5space(1, h5size);
const H5::DataSet h5set = fileptr_->createDataSet(datapath, file_datatype, h5space);
const void* data = &(*p.begin());
h5set.write(data, mem_datatype);
}
catch( H5::Exception& ) {
// Handle exception
return false;
}
return true;
}
Then the rest worked as expected - read function is essentially unchanged; was able to do the same even for containers of pairs of unsigned ints and so on. HTH.