* mln/core/concept/image.hh: Add an invalid operator= in order to
avoid wrong assignment. See sandbox/bug/concept_and_assignment.cc.
---
milena/ChangeLog | 7 +++++++
milena/mln/core/concept/image.hh | 19 ++++++++++++++++++-
2 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 3ece40a..8753025 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2009-03-30 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Avoid invalid assigments with image concept.
+
+ * mln/core/concept/image.hh: Add an invalid operator= in order to
+ avoid wrong assignment. See sandbox/bug/concept_and_assignment.cc.
+
+2009-03-30 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add math::sin and math::pi.
* mln/math/all.hh: add new includes.
diff --git a/milena/mln/core/concept/image.hh b/milena/mln/core/concept/image.hh
index e2bc4f8..6b23192 100644
--- a/milena/mln/core/concept/image.hh
+++ b/milena/mln/core/concept/image.hh
@@ -43,6 +43,7 @@
# include <mln/trait/concrete.hh> // FIXME: Should be in all.hh!
# include <mln/trait/images.hh>
+# include <mln/metal/abort.hh>
# include <mln/metal/is_a.hh>
# include <mln/metal/equal.hh>
@@ -73,6 +74,9 @@ namespace mln
{
typedef Image<void> category;
+ template <typename J>
+ Image<E>& operator=(const J& rhs);
+
/*
// provided by internal::image_base:
@@ -110,7 +114,6 @@ namespace mln
};
-
namespace convert
{
@@ -176,6 +179,20 @@ namespace mln
} // end of namespace mln::internal
+ template <typename E>
+ template <typename J>
+ inline
+ Image<E>&
+ Image<E>::operator=(const J&)
+ {
+ /// You are assigning an image of a concrete type to
+ /// an image with a concept type. It does NOT work.
+ ///
+ /// You forgot a call to exact() on the left operand!
+ mlc_abort(E)::check();
+ return *this;
+ }
+
template <typename E>
inline
--
1.5.6.5
Show replies by date