27 #ifndef MLN_DATA_CONVERT_HH
28 # define MLN_DATA_CONVERT_HH
36 # include <mln/core/routine/duplicate.hh>
37 # include <mln/fun/v2v/convert.hh>
38 # include <mln/data/transform.hh>
54 template <
typename V,
typename I>
56 convert(const V& v, const Image<I>& input);
60 # ifndef MLN_INCLUDE_ONLY
65 template <
typename V,
typename I>
68 convert_tests(
const V&,
const Image<I>& input)
70 mln_precondition(
exact(input).is_valid());
82 template <
typename V,
typename I>
85 convert(const V& v, const Image<I>& input)
87 mln_trace(
"data::impl::generic::convert");
88 internal::convert_tests(v, input);
90 fun::v2v::convert<V> f;
99 template <typename V, typename I>
102 convert_identity(const V& v, const Image<I>& input)
104 mln_trace(
"data::impl::convert_identity");
105 internal::convert_tests(v, input);
107 mln_concrete(I) output =
duplicate(input);
118 template <
typename V,
typename I>
121 convert_dispatch(metal::
bool_<true>,
122 const V& v, const Image<I>& input)
124 return impl::convert_identity(v, input);
127 template <
typename V,
typename I>
130 convert_dispatch(metal::
bool_<false>,
131 const V& v, const Image<I>& input)
136 template <
typename V,
typename I>
139 convert_dispatch(const V& v, const Image<I>& input)
144 return convert_dispatch(metal::bool_<test>(),
152 template <
typename V,
typename I>
155 convert(const V& v, const Image<I>& input)
157 mln_trace(
"data::convert");
159 internal::convert_tests(v, input);
161 mln_ch_value(I, V) output = internal::convert_dispatch(v, input);
167 # endif // ! MLN_INCLUDE_ONLY
174 #endif // ! MLN_DATA_CONVERT_HH