diff --git a/c++/h5/complex.hpp b/c++/h5/complex.hpp index 76820e0..c183b2e 100644 --- a/c++/h5/complex.hpp +++ b/c++/h5/complex.hpp @@ -43,13 +43,17 @@ namespace h5 { double i; }; - // Type trait to check if a type is std::complex. - template - struct _is_complex : std::false_type {}; + namespace detail { - // Specialization of h5::_is_complex for std::complex. - template - struct _is_complex> : std::true_type {}; + // Type trait to check if a type is std::complex. + template + struct _is_complex : std::false_type {}; + + // Specialization of h5::_is_complex for std::complex. + template + struct _is_complex> : std::true_type {}; + + } // namespace detail /** * @ingroup h5_types @@ -57,7 +61,7 @@ namespace h5 { * @tparam T Type to check. */ template - constexpr bool is_complex_v = _is_complex::value; + constexpr bool is_complex_v = detail::_is_complex::value; } // namespace h5 diff --git a/c++/h5/stl/variant.hpp b/c++/h5/stl/variant.hpp index 948ace6..3a883ac 100644 --- a/c++/h5/stl/variant.hpp +++ b/c++/h5/stl/variant.hpp @@ -59,19 +59,23 @@ namespace h5 { std::visit([&](auto const &x) { h5_write(g, name, x); }, v); } - // Helper function to read a std::variant from HDF5. - template - void h5_read_variant_helper(VT &v, datatype dt, group g, std::string const &name) { - // finds the correct h5_read recursively - if (hdf5_type_equal(hdf5_type(), dt)) { - v = VT{h5_read(g, name)}; - return; + namespace detail { + + // Helper function to read a std::variant from HDF5. + template + void h5_read_variant_helper(VT &v, datatype dt, group g, std::string const &name) { + // finds the correct h5_read recursively + if (hdf5_type_equal(hdf5_type(), dt)) { + v = VT{h5_read(g, name)}; + return; + } + if constexpr (sizeof...(Ts) > 0) + h5_read_variant_helper(v, dt, g, name); + else + throw std::runtime_error("Error in h5_read_variant_helper: Type stored in the variant has no corresponding HDF5 datatype"); } - if constexpr (sizeof...(Ts) > 0) - h5_read_variant_helper(v, dt, g, name); - else - throw std::runtime_error("Error in h5_read_variant_helper: Type stored in the variant has no corresponding HDF5 datatype"); - } + + } // namespace detail /** * @brief Read a std::variant from an HDF5 dataset. @@ -90,7 +94,7 @@ namespace h5 { // assume for the moment, name is a dataset. dataset ds = g.open_dataset(name); datatype dt = get_hdf5_type(ds); - h5_read_variant_helper, Ts...>(v, dt, g, name); + detail::h5_read_variant_helper, Ts...>(v, dt, g, name); } /** @} */