3111: Fix from_to dispatch.

* mln/convert/from_to.hh: dispatch functions where not called at all. * mln/convert/from_to.hxx: Add more forward declarations. --- milena/ChangeLog | 8 ++++++ milena/mln/convert/from_to.hh | 48 ++++++++++++++++++++++++++++++++------- milena/mln/convert/from_to.hxx | 25 ++++++++++++++++++++ 3 files changed, 72 insertions(+), 9 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index e218828..6e38723 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,11 @@ +2008-12-30 Guillaume Lazzara <z@lrde.epita.fr> + + Fix from_to dispatch. + + * mln/convert/from_to.hh: dispatch functions where not called at all. + + * mln/convert/from_to.hxx: Add more forward declarations. + 2008-12-30 Roland Levillain <roland@lrde.epita.fr> Start to factor code among tests on complex-based images. diff --git a/milena/mln/convert/from_to.hh b/milena/mln/convert/from_to.hh index 149b115..8e3510a 100644 --- a/milena/mln/convert/from_to.hh +++ b/milena/mln/convert/from_to.hh @@ -68,17 +68,23 @@ namespace mln { - // F -> T - // if F convertible to T. + // Default dispatch if the two arguments are objects. + + // Object -> Object template <typename F, typename T> inline void - from_to_dispatch(const metal::true_&, const Object<F>& from, Object<T>& to) + from_to_dispatch(const Object<F>& from, Object<T>& to) { - exact(to) = exact(from); + typedef mlc_converts_to(F, T) F_converts_to_T; + internal::from_to_dispatch(F_converts_to_T(), + exact(from), exact(to)); } + + // Dispatch to specific implementation. + // Image -> Site_Set. template <typename I, typename S> inline @@ -102,6 +108,20 @@ namespace mln } + + // Dispatch related to convertible objects. + + // F -> T + // if F convertible to T. + template <typename F, typename T> + inline + void + from_to_dispatch(const metal::true_&, const Object<F>& from, Object<T>& to) + { + exact(to) = exact(from); + } + + // F is NOT convertible to T. template <typename F, typename T> inline @@ -112,6 +132,10 @@ namespace mln } + + // Dispatch entry points. + // Check whether arguments are an object or not. + // Builtin -> Builtin template <typename F, typename T> inline @@ -119,7 +143,7 @@ namespace mln from_to_dispatch(metal::false_, const F& from, metal::false_, T& to) { - over_load::from_to_(from, exact(to)); + over_load::from_to_(from, to); } @@ -151,9 +175,7 @@ namespace mln from_to_dispatch(metal::true_, const F& from, metal::true_, T& to) { - typedef mlc_converts_to(F, T) F_converts_to_T; - internal::from_to_dispatch(F_converts_to_T(), - exact(from), exact(to)); + internal::from_to_dispatch(exact(from), exact(to)); } @@ -182,11 +204,19 @@ namespace mln template <typename T> inline void - from_to_(const T& from, T& to) + from_to_(const Object<T>& from, Object<T>& to) { exact(to) = exact(from); } + template <typename T> + inline + void + from_to_(const T& from, T& to) + { + to = from; + } + } // end of namespace mln::convert::over_load diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx index b534234..793da8b 100644 --- a/milena/mln/convert/from_to.hxx +++ b/milena/mln/convert/from_to.hxx @@ -106,6 +106,13 @@ namespace mln namespace convert { + // Facade + + template <typename F, typename T> + void + from_to(const F& from, T& to); + + namespace over_load { @@ -115,6 +122,16 @@ namespace mln from_to_(const Object<F>&, Object<T>&); // end of Guard. + // Object -> Object + template <typename T> + void + from_to_(const Object<T>& from, Object<T>& to); + + // Object -> Object + template <typename T> + void + from_to_(const T& from, T& to); + // algebra::vec -> Gpoint. template <unsigned n, typename T, typename P> @@ -182,6 +199,14 @@ namespace mln void from_to_(const float& from, Value<V>& to); + // float -> unsigned + void + from_to_(const float& from, unsigned& to); + + // float -> int + void + from_to_(const float& from, int& to); + // int -> Value template <typename T> void -- 1.5.6.5
participants (1)
-
Guillaume Lazzara