6 #ifndef ECHELON_SINK_ADAPTORS_HPP 7 #define ECHELON_SINK_ADAPTORS_HPP 9 #include <echelon/hdf5/container_adaption.hpp> 14 template <
typename ResizeableSink>
18 static_assert(hdf5::has_reshape_member<ResizeableSink>(),
19 "ResizeableSink does not fulfill the ResizeableSink requirements");
21 explicit auto_reshaper(ResizeableSink& underlying_sink_) : underlying_sink_{&underlying_sink_}
25 template <
typename Source>
26 friend void operator<<=(auto_reshaper<ResizeableSink> sink,
const Source& source)
28 auto shape = source.shape();
30 std::vector<std::size_t> shape_;
31 shape_.reserve(shape.size());
33 for(
auto value : shape)
35 shape_.push_back(value);
38 hdf5::reshape_adl(*sink.underlying_sink_, shape_);
40 *sink.underlying_sink_ <<= source;
44 ResizeableSink* underlying_sink_;
66 template <
typename ResizeableSink>
69 return auto_reshaper<ResizeableSink>(sink);
echelon's core namespace
Definition: attribute.cpp:10
auto_reshaper< ResizeableSink > auto_reshape(ResizeableSink &sink)
Add an adaptor to the sink which automatically reshapes the sink if needed.
Definition: sink_adaptors.hpp:67