diff --git a/doc/arts/dev.xml.rst b/doc/arts/dev.xml.rst index e5ddce0d34..960927415b 100644 --- a/doc/arts/dev.xml.rst +++ b/doc/arts/dev.xml.rst @@ -39,8 +39,8 @@ There are two structs defined in ``xml_io_struct.h``: static void read(std::istream&, T&, bifstream* = nullptr) = delete; // Binary streaming IO (optional) - static void get(std::span, bofstream*) = delete; - static void put(std::span, bifstream*) = delete; + static void get(std::span, bifstream*) = delete; + static void put(std::span, bofstream*) = delete; // Text streaming (optional) static void parse(std::span, std::istream&) = delete; diff --git a/src/core/rtepack/rtepack_mueller_matrix.h b/src/core/rtepack/rtepack_mueller_matrix.h index 4b50689702..602b026ced 100644 --- a/src/core/rtepack/rtepack_mueller_matrix.h +++ b/src/core/rtepack/rtepack_mueller_matrix.h @@ -275,8 +275,8 @@ Array forward_cumulative_transmission( } // namespace rtepack template <> - struct std::formatter : std::formatter {}; template <> -struct xml_io_stream : xml_io_stream {}; +struct xml_io_stream + : xml_io_stream_inherit {}; diff --git a/src/core/rtepack/rtepack_propagation_matrix.h b/src/core/rtepack/rtepack_propagation_matrix.h index 40491da03c..67416e34ac 100644 --- a/src/core/rtepack/rtepack_propagation_matrix.h +++ b/src/core/rtepack/rtepack_propagation_matrix.h @@ -127,8 +127,8 @@ propmat_vector operator*(Numeric x, const propmat_vector_const_view &y); } // namespace rtepack template <> - struct std::formatter : std::formatter {}; template <> -struct xml_io_stream : xml_io_stream {}; +struct xml_io_stream + : xml_io_stream_inherit {}; diff --git a/src/core/rtepack/rtepack_spectral_matrix.h b/src/core/rtepack/rtepack_spectral_matrix.h index a08ed04841..aaf8b3cff3 100644 --- a/src/core/rtepack/rtepack_spectral_matrix.h +++ b/src/core/rtepack/rtepack_spectral_matrix.h @@ -271,8 +271,8 @@ using specmat_tensor3_const_view = matpack::view_t; } // namespace rtepack template <> - struct std::formatter : std::formatter {}; template <> -struct xml_io_stream : xml_io_stream {}; +struct xml_io_stream + : xml_io_stream_inherit {}; diff --git a/src/core/rtepack/rtepack_stokes_vector.h b/src/core/rtepack/rtepack_stokes_vector.h index 38a6cf04ac..682f23c05b 100644 --- a/src/core/rtepack/rtepack_stokes_vector.h +++ b/src/core/rtepack/rtepack_stokes_vector.h @@ -160,8 +160,8 @@ using stokvec_tensor6_const_view = matpack::view_t; } // namespace rtepack template <> - struct std::formatter : std::formatter {}; template <> -struct xml_io_stream : xml_io_stream {}; +struct xml_io_stream + : xml_io_stream_inherit {}; \ No newline at end of file diff --git a/src/core/xml/xml_io_stream.h b/src/core/xml/xml_io_stream.h index 7205173b49..52e172656a 100644 --- a/src/core/xml/xml_io_stream.h +++ b/src/core/xml/xml_io_stream.h @@ -39,8 +39,8 @@ struct xml_io_stream { static void read(std::istream&, T&, bifstream* = nullptr) = delete; // Binary streaming IO (optional) - static void get(std::span, bofstream*) = delete; - static void put(std::span, bifstream*) = delete; + static void get(std::span, bifstream*) = delete; + static void put(std::span, bofstream*) = delete; // Text streaming (optional) static void parse(std::span, std::istream&) = delete; @@ -103,3 +103,28 @@ template concept xml_io_parseable = requires(std::span b, std::istream& is) { xml_io_stream::parse(b, is); }; + +//! Explicitly inherit and cast between spans +template T> +struct xml_io_stream_inherit : xml_io_stream { + static void get(std::span b, bifstream* pbifs) + requires(xml_io_binary) + { + xml_io_stream::get(std::span{reinterpret_cast(b.data()), b.size()}, + pbifs); + } + + static void put(std::span b, bofstream* pbofs) + requires(xml_io_binary) + { + xml_io_stream::put( + std::span{reinterpret_cast(b.data()), b.size()}, pbofs); + } + + static void parse(std::span b, std::istream& is) + requires(xml_io_parseable) + { + xml_io_stream::parse(std::span{reinterpret_cast(b.data()), b.size()}, + is); + } +}; diff --git a/src/core/xml/xml_io_stream_array.h b/src/core/xml/xml_io_stream_array.h index 6c1df8c0c9..8acf68a51c 100644 --- a/src/core/xml/xml_io_stream_array.h +++ b/src/core/xml/xml_io_stream_array.h @@ -153,16 +153,16 @@ struct xml_io_stream> { } ARTS_METHOD_ERROR_CATCH - static void put(std::span> v, bifstream* pbifs) + static void put(std::span> v, bofstream* pbofs) requires(xml_io_binary) { - inner::put(std::span(reinterpret_cast(v.data()), N), pbifs); + inner::put(std::span(reinterpret_cast(v.data()), N), pbofs); } - static void get(std::span> v, bofstream* pbofs) + static void get(std::span> v, bifstream* pbifs) requires(xml_io_binary) { - inner::get(std::span(reinterpret_cast(v.data()), N), pbofs); + inner::get(std::span(reinterpret_cast(v.data()), N), pbifs); } static void parse(std::span> v, std::istream& is)