8000 support `std::variant` for read function · Issue #901 · BlueBrain/HighFive · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.
This repository was archived by the owner on Feb 26, 2025. It is now read-only.
support std::variant for read function #901
Open
@nitrogar

Description

@nitrogar

I am writing a generic H5 viewer, therefore I need to fetch data from dataset and casting the result at the end.

I tried std::vector<std::vector<std::variant<int,float,double,std::string>>> but it gives me this compilation error.

my code:

std::vector<std::vector<std::variant<int,float,double,std::string>>> data;
dataset.select({0, 0}, {10, 10}).read(data);

error:

/home/username/githubs/HighFive/include/highfive/bits/../bits/H5DataType_misc.hpp: In instantiation of ‘HighFive::AtomicType<T>::AtomicType() [with T = std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >]’:
/home/username/githubs/HighFive/include/highfive/bits/../bits/H5DataType_misc.hpp:499:12:   required from ‘HighFive::DataType HighFive::create_datatype() [with T = std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >]’
/home/username/githubs/HighFive/include/highfive/bits/H5ReadWrite_misc.hpp:141:84:   required from ‘HighFive::details::BufferInfo<T>::BufferInfo(const HighFive::DataType&, F, Operation) [with F = HighFive::SliceTraits<HighFive::Selection>::read<std::vector<std::vector<std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >(std::vector<std::vector<std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&, const HighFive::DataTransferProps&) const::<lambda()>; T = std::vector<std::vector<std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >]’
/home/username/githubs/HighFive/include/highfive/bits/H5Slice_traits_misc.hpp:175:34:   required from ‘void HighFive::SliceTraits<Derivate>::read(T&, const HighFive::DataTransferProps&) const [with T = std::vector<std::vector<std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >; Derivate = HighFive::Selection; HighFive::DataTransferProps = HighFive::PropertyList<HighFive::PropertyType::DATASET_XFER>]’
/home/archiver/projects/omar_challeng/include/H5.hpp:45:81:   required from here
/home/username/githubs/HighFive/include/highfive/bits/../bits/H5DataType_misc.hpp:257:57: error: static assertion failed: Type not supported
  257 |     static_assert(details::inspector<T>::recursive_ndim > 0, "Type not supported");
      |                                          ~~~~~~~~~~~~~~~^~~
/home/username/githubs/HighFive/include/highfive/bits/../bits/H5DataType_misc.hpp:257:57: note: the comparison reduces to ‘(0 > 0)’
In file included from /home/username/githubs/HighFive/include/highfive/bits/H5Converter_misc.hpp:13:
/home/username/githubs/HighFive/include/highfive/bits/H5Inspector_misc.hpp: In instantiation of ‘static void HighFive::details::type_helper<T>::unserialize(const hdf5_type*, const std::vector<long unsigned int>&, type&) [with T = std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >; hdf5_type = std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >; type = std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >]’:
/home/username/githubs/HighFive/include/highfive/bits/H5Inspector_misc.hpp:425:47:   recursively required from ‘static void HighFive::details::inspector<std::vector<Size> >::unserialize(const It&, const std::vector<long unsigned int>&, type&) [with It = const std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*; T = std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >; type = std::vector<std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >]’
/home/username/githubs/HighFive/include/highfive/bits/H5Inspector_misc.hpp:425:47:   required from ‘static void HighFive::details::inspector<std::vector<Size> >::unserialize(const It&, const std::vector<long unsigned int>&, type&) [with It = const std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*; T = std::vector<std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >; type = std::vector<std::vector<std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >]’
/home/username/githubs/HighFive/include/highfive/bits/H5Converter_misc.hpp:92:37:   required from ‘void HighFive::details::DeepCopyBuffer<T>::unserialize(T&) const [with T = std::vector<std::vector<std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >]’
/home/username/githubs/HighFive/include/highfive/bits/H5Slice_traits_misc.hpp:199:18:   required from ‘void HighFive::SliceTraits<Derivate>::read(T&, const HighFive::DataTransferProps&) const [with T = std::vector<std::vector<std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >; Derivate = HighFive::Selection; HighFive::DataTransferProps = HighFive::PropertyList<HighFive::PropertyType::DATASET_XFER>]’
/home/archiver/projects/omar_challeng/include/H5.hpp:45:81:   required from here
/home/username/githubs/HighFive/include/highfive/bits/H5Inspector_misc.hpp:217:23: error: static assertion failed: The type is not trivially copyable
  217 |         static_assert(is_trivially_copyable, "The type is not trivially copyable");
      |                       ^~~~~~~~~~~~~~~~~~~~~
/home/username/githubs/HighFive/include/highfive/bits/H5Inspector_misc.hpp:217:23: note: ‘HighFive::details::type_helper<std::variant<int, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::is_trivially_copyable’ evaluates to false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0