#include <h5cpp/all>
#include <array>
#include <deque>
#include <forward_list>
#include <iostream>
#include <list>
#include <vector>
int main() {
static_assert(h5::meta::storage_representation_v<std::vector<int>> ==
h5::meta::storage_representation_t::linear_value_dataset,
"vector<int> must be linear_value_dataset");
static_assert(h5::meta::storage_representation_v<std::array<double, 5>> ==
h5::meta::storage_representation_t::array_element,
"std::array<double, 5> must be array_element");
auto check = [](const char* label, bool ok) {
std::cout << (ok ?
"✔ ok " :
"✘ failed") <<
" " << label <<
"\n";
};
{
std::cout <<
" vector<int>(8) = " << back <<
"\n";
check("std::vector<int>(8) round-trip", back == v);
}
{
std::cout <<
" array<double,5> = " << back <<
"\n";
check("std::array<double, 5> round-trip", back == a);
}
{
std::cout <<
" list<int>(5) = " << back <<
"\n";
check("std::list<int>(5) round-trip", back == l);
}
{
std::cout <<
" deque<short>(7) = " << back <<
"\n";
check("std::deque<short>(7) round-trip", back == d);
}
{
h5::write(fd,
"/seq/forward_list_float", fl);
std::cout <<
" forward_list<float>(4) = " << back <<
"\n";
check("std::forward_list<float>(4) round-trip", back == fl);
}
{
std::cout <<
" int64_t[6] = " << back <<
"\n";
bool ok = true;
for (
std::size_t i = 0; ok && i < 6; ++i) ok = (back[i] == arr[i]);
check("int64_t[6] round-trip (read into array)", ok);
}
return 0;
}
h5::at_t create(const hid_t &parent, const std::string &path, args_t &&... args)
Create a new attribute of element type T on a parent HDF5 object.
Definition H5Acreate.hpp:100
T aread(const hid_t &ds, const std::string &name, const h5::acpl_t &acpl=h5::default_acpl)
Read an attribute by name and return its value as type T.
Definition H5Aread.hpp:76
h5::gr_t write(const LOC &parent, const std::string &path, const T &src)
Write a sparse matrix or vector as a CSC group.
Definition H5Dsparse.hpp:185