6 #ifndef ECHELON_HDF5_CONTAINER_ADAPTION_HPP 7 #define ECHELON_HDF5_CONTAINER_ADAPTION_HPP 10 #include <type_traits> 25 inline auto data(C&& container) -> decltype(data(container, adl_enabler{}))
27 return data(container, adl_enabler{});
31 inline auto data(C&& container) -> decltype(container.data())
33 return container.data();
40 inline auto data_adl(C&& container) -> decltype(data(container))
42 return data(container);
46 inline auto shape(
const C& container) -> decltype(shape(container, adl_enabler{}))
48 return shape(container, adl_enabler{});
52 inline auto shape(
const C& container) -> decltype(container.shape())
54 return container.shape();
58 inline auto shape_adl(
const C& container) -> decltype(shape(container))
60 return shape(container);
64 inline auto reshape(C& container,
const std::vector<std::size_t>& new_shape)
65 -> decltype(
reshape(container, new_shape, adl_enabler{}))
67 return reshape(container, new_shape, adl_enabler{});
78 inline auto reshape(C& container,
const std::vector<std::size_t>& new_shape)
79 -> decltype(container.reshape(new_shape))
81 return container.reshape(new_shape);
85 inline auto reshape_adl(C& container,
const std::vector<std::size_t>& new_shape)
86 -> decltype(
reshape(container, new_shape))
88 return reshape(container, new_shape);
95 constexpr
auto has_data_accessor_impl(
int) -> decltype((data_adl(std::declval<T>()),
bool{}))
100 template <
typename T>
101 constexpr
bool has_data_accessor_impl(...)
106 template <
typename T>
107 constexpr
auto has_shape_property_impl(
int) -> decltype((shape(std::declval<T>()),
bool{}))
112 template <
typename T>
113 constexpr
bool has_shape_property_impl(...)
118 template <
typename T>
119 constexpr
auto has_reshape_member_impl(
int)
120 -> decltype((
reshape(std::declval<T&>(), std::vector<std::size_t>{}),
bool{}))
125 template <
typename T>
126 constexpr
bool has_reshape_member_impl(...)
132 template <
typename T>
133 constexpr
bool has_data_accessor()
135 return detail::has_data_accessor_impl<T>(0);
138 template <
typename T>
139 constexpr
bool has_shape_property()
141 return detail::has_shape_property_impl<T>(0);
144 template <
typename T>
145 constexpr
bool has_reshape_member()
147 return detail::has_reshape_member_impl<T>(0);
150 template <
typename T>
151 constexpr
bool is_readable_container()
153 return has_data_accessor<const T>() && has_shape_property<T>();
156 template <
typename T>
157 constexpr
bool is_container()
159 return has_data_accessor<T>() && has_shape_property<T>();
163 template <
typename C>
164 struct container_trait
166 static_assert(is_container<C>(),
"C does not fulfill the Container requirements.");
168 using value_type =
typename std::decay<decltype(*data_adl(std::declval<const C>()))>::
type;
echelon's core namespace
Definition: attribute.cpp:10
auto reshape(C &container, const std::vector< std::size_t > &new_shape) -> decltype(reshape(container, new_shape, adl_enabler
Reshapes the container.
Definition: container_adaption.hpp:64
A handle to an HDF5 type.
Definition: hdf5/type.hpp:23