Exemplo n.º 1
0
 PredType data_type_file ( V const & ) { return h5_type_from_C(typename remove_complex<V>::type());}
Exemplo n.º 2
0
namespace triqs::h5 {

  template <typename... T> struct hdf5_scheme_impl<std::variant<T...>> { static std::string invoke() = delete; };

  /**
   */
  template <typename... T> void h5_write(h5::group gr, std::string const &name, std::variant<T...> const &v) {
    visit([&](auto const &x) { h5_write(gr, name, x); }, v);
  }

  template <typename T> bool h5_is(datatype dt) {
    if constexpr (std::is_same<T, std::string>::value) {
      return H5Tget_class(dt) == H5T_STRING;
    } // H5T_INTEGER, H5T_FLOAT
    else
      return H5Tequal(dt, h5_type_from_C(T{}));
  }

  template <typename VT, typename U, typename... T> void h5_read_variant_helper(VT &v, datatype dt, h5::group gr, std::string const &name) {
    if (h5_is<U>(dt)) {
      v = VT{triqs::h5::h5_read<U>(gr, name)};
      return;
    }
    if constexpr (sizeof...(T) > 0)
      h5_read_variant_helper<VT, T...>(v, dt, gr, name);
    else
      TRIQS_RUNTIME_ERROR << " Error in h5_read: std::variant<...> not compatible with TRIQS_HDF5_data_scheme \n";
  }

  /**
   * Read vairant from the h5
Exemplo n.º 3
0
 // the type of data to put in the file_or_group
 template <typename V> H5::PredType data_type_file () { return h5_type_from_C(typename remove_complex<V>::type());}