URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-21 Simon Nivault <simon.nivault(a)lrde.epita.fr>
A point can be considered as a metal::vec
* mln/core/point.hh: Update.
* tests/point2d.cc: (operator vec()).
---
mln/core/point.hh | 14 +++++++++++---
tests/point2d.cc | 3 +++
2 files changed, 14 insertions(+), 3 deletions(-)
Index: trunk/milena/tests/point2d.cc
===================================================================
--- trunk/milena/tests/point2d.cc (revision 1151)
+++ trunk/milena/tests/point2d.cc (revision 1152)
@@ -30,6 +30,7 @@
* \brief Tests on mln::point2d.
*/
+#include <iostream>
#include <mln/core/point2d.hh>
@@ -56,4 +57,6 @@
q.set_all(0);
for (unsigned i = 0; i < p.dim; ++i)
mln_assertion(q[i] == 0);
+
+ std::cout << 3.4 * metal::vec<2, int>(p) << std::endl;
}
Index: trunk/milena/mln/core/point.hh
===================================================================
--- trunk/milena/mln/core/point.hh (revision 1151)
+++ trunk/milena/mln/core/point.hh (revision 1152)
@@ -36,6 +36,7 @@
# include <mln/core/concept/point.hh>
# include <mln/core/internal/coord_impl.hh>
# include <mln/fun/i2v/all.hh>
+# include <mln/metal/vec.hh>
namespace mln
@@ -98,13 +99,13 @@
point_<M,C>& operator+=(const dpoint& dp);
/// Type of the array of coordinates.
- typedef const C (&vec_t)[dim];
+ typedef metal::vec<dim, C> vec_t;
/// Hook to coordinates.
- vec_t to_vec() const { return coord_; }
+ operator metal::vec<dim, C>() const;
protected:
- C coord_[dim];
+ metal::vec<dim, C> coord_;
};
@@ -157,6 +158,13 @@
return *this;
}
+ template <typename M, typename C>
+ point_<M,C>::operator metal::vec<dim, C>() const
+ {
+ return coord_;
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln