---
milena/ChangeLog | 5 ++
milena/mln/convert/impl/from_value_to_value.hh | 62 ++++++++++++++----------
2 files changed, 41 insertions(+), 26 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4b4c4a9..41ca209 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * mln/convert/impl/from_value_to_value.hh: Improve
+ from_value_to_value dispatch for types with identical equiv type.
+
2013-04-24 Guillaume Lazzara <z(a)lrde.epita.fr>
Handle 16 bits value types with io::magick.
diff --git a/milena/mln/convert/impl/from_value_to_value.hh
b/milena/mln/convert/impl/from_value_to_value.hh
index 9c93e5a..8d1afc9 100644
--- a/milena/mln/convert/impl/from_value_to_value.hh
+++ b/milena/mln/convert/impl/from_value_to_value.hh
@@ -65,38 +65,48 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- // We want to disable this code since it prevents types of
- // different quantification to rely on from_to_ overload and
- // handle specific conversions. (ex: rgb16 towards rgb8)
-
- // // Case 1:
-
- // template <typename V, typename W>
- // void
- // from_value_to_value_(const mln::value::Vectorial<V>& from,
- // mln::value::Vectorial<W>& to)
- // {
- // exact(to) = exact(from).to_equiv();
- // }
-
- // // Case 2:
-
- // template <typename V, typename W>
- // void
- // from_value_to_value_(const mln::value::Scalar<V>& from,
- // mln::value::Scalar<W>& to)
- // {
- // exact(to) = exact(from).to_equiv();
- // }
+ // Case 1: Same equiv type.
+
+ template <typename V, typename W, typename EV>
+ void
+ from_value_to_value_(const mln::value::Vectorial<V>& from,
+ mln::value::Vectorial<W>& to,
+ const EV&, const EV&)
+ {
+ exact(to) = exact(from).to_equiv();
+ }
+
+ template <typename V, typename W, typename EV>
+ void
+ from_value_to_value_(const mln::value::Scalar<V>& from,
+ mln::value::Scalar<W>& to,
+ const EV&, const EV&)
+ {
+ exact(to) = exact(from).to_equiv();
+ }
+
+ // Case 2: Different equiv type. No concept based
+ // conversions. Trying to find more specific conversions with
+ // other from_to_ overloads.
+ template <typename V, typename W, typename EV1, typename EV2>
+ inline
+ void
+ from_value_to_value_(const Value<V>& from, Value<W>& to,
+ const EV1&, const EV2&)
+ {
+ from_to_(exact(from), exact(to));
+ }
+
template <typename V, typename W>
inline
void
from_value_to_value_(const Value<V>& from, Value<W>& to)
{
- // No concept based conversion. Trying to find more specific
- // conversion with other from_to overloads.
- from_to_(exact(from), exact(to));
+ /// Checking if V and W have the same equivalent type.
+ typedef mln_equiv(V) V_equiv;
+ typedef mln_equiv(W) W_equiv;
+ from_value_to_value_(exact(from), exact(to), V_equiv(), W_equiv());
}
--
1.7.2.5
Show replies by date