1014: Fix make doc, handle todos, and pass tests with g++-2.95.

https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Fix make doc, handle todos, and pass tests with g++-2.95. * tests/safe_image.cc, * mln/core/concept/genpoint.hh, * mln/core/window.hh, * mln/core/internal/image_adaptor.hh, * mln/core/internal/set_of.hh, * mln/level/fill.hh, * mln/level/compare.hh, * mln/level/paste.hh, * mln/make/window2d.hh: Fix. mln/core/concept/genpoint.hh | 3 --- mln/core/internal/image_adaptor.hh | 2 ++ mln/core/internal/set_of.hh | 9 ++++++--- mln/core/window.hh | 2 -- mln/level/compare.hh | 9 ++++++--- mln/level/fill.hh | 30 ++++++++++++------------------ mln/level/paste.hh | 13 ++++++------- mln/make/window2d.hh | 4 ++-- tests/safe_image.cc | 2 ++ 9 files changed, 36 insertions(+), 38 deletions(-) Index: tests/safe_image.cc --- tests/safe_image.cc (revision 1013) +++ tests/safe_image.cc (working copy) @@ -32,6 +32,7 @@ #include <mln/core/image2d_b.hh> #include <mln/core/safe_image.hh> +#include <mln/level/paste.hh> int main() @@ -44,4 +45,5 @@ point2d p = make::point2d(-5, -1); ima_(p) = 0; + level::paste(ima, ima_); } Index: mln/core/concept/genpoint.hh --- mln/core/concept/genpoint.hh (revision 1013) +++ mln/core/concept/genpoint.hh (working copy) @@ -185,9 +185,6 @@ * * \see mln::Dpoint * \relates mln::GenPoint - * - * \todo Introduce the notion of "generalized dpoint" and - * add the more general extra operator-(GenPoint, GenDpoint). */ template <typename P> mln_point(P) Index: mln/core/window.hh --- mln/core/window.hh (revision 1013) +++ mln/core/window.hh (working copy) @@ -94,8 +94,6 @@ bool is_centered() const; /*! \brief Test if the window is symmetric. - * - * \todo Implementation! */ bool is_symmetric() const; Index: mln/core/internal/image_adaptor.hh --- mln/core/internal/image_adaptor.hh (revision 1013) +++ mln/core/internal/image_adaptor.hh (working copy) @@ -103,6 +103,7 @@ template <typename I, typename E, typename S> bool image_adaptor_<I,E,S>::owns_(const psite& p) const { + mln_precondition(exact(this)->has_data()); return adaptee_.owns_(p); } @@ -110,6 +111,7 @@ const S& image_adaptor_<I,E,S>::domain() const { + mln_precondition(exact(this)->has_data()); return adaptee_.domain(); } Index: mln/core/internal/set_of.hh --- mln/core/internal/set_of.hh (revision 1013) +++ mln/core/internal/set_of.hh (working copy) @@ -37,6 +37,8 @@ # include <set> # include <iterator> +# include <mln/core/internal/force_exact.hh> + namespace mln { @@ -70,9 +72,9 @@ * * If \p elt is already in the set, this method is a no-op. * - * \todo Returns exact(*this). + * \return The set itself after insertion. */ - void insert(const E& elt); + set_of_<E>& insert(const E& elt); /*! \brief Return the i-th element of the set. @@ -189,12 +191,13 @@ } template <typename E> - void + set_of_<E>& set_of_<E>::insert(const E& elt) { s_.insert(elt); if (needs_update_ = false) needs_update_ = true; + return internal::force_exact< set_of_<E> >(*this); } template <typename E> Index: mln/level/fill.hh --- mln/level/fill.hh (revision 1013) +++ mln/level/fill.hh (working copy) @@ -50,8 +50,7 @@ * \pre \p ima has to be initialized. */ template <typename I> - void fill(Image<I>& ima, - const mln_value(I)& v); + void fill(Image<I>& ima, const mln_value(I)& v); /*! Fill the image \p ima by applying the function \p f. @@ -65,8 +64,7 @@ * \pre \p ima has to be initialized. */ template <typename I> - void fill(Image<I>& ima, - mln_value(I) (*f)(const mln_point(I)& p)); + void fill(Image<I>& ima, mln_value(I) (*f)(const mln_point(I)& p)); /*! Fill the image \p ima with the values given by the array \p arr. @@ -78,12 +76,10 @@ * of image points, otherwise the program crashes. * * \pre \p ima has to be initialized. - * - * \todo Add as parameter the array size, then add a test. + * \pre N = \p ima.npoints */ - template <typename I> - void fill(Image<I>& ima, - const mln_value(I) arr[]); + template <typename I, unsigned N> + void fill(Image<I>& ima, mln_value(I) (&arr)[N]); /*! Fill the image \p ima with the values of the image \p data. @@ -94,13 +90,10 @@ * \warning The definition domain of \p ima has to be included in * the one of \p data. * - * \pre \p ima has to be initialized. - * - * \todo Test domain inclusion. + * \pre \p ima.domain <= \p data.domain. */ template <typename I, typename J> - void fill(Image<I>& ima, - const Image<J>& data); + void fill(Image<I>& ima, const Image<J>& data); @@ -128,16 +121,17 @@ ima(p) = f(p); } - template <typename I> + template <typename I, unsigned N> void fill(Image<I>& ima_, - const mln_value(I) array[]) + mln_value(I) (&arr)[N]) { I& ima = exact(ima_); mln_precondition(ima.has_data()); + mln_precondition(N = ima.npoints()); mln_piter(I) p(ima.domain()); unsigned i = 0; for_all(p) - ima(p) = array[i++]; + ima(p) = arr[i++]; } template <typename I, typename J> @@ -146,7 +140,7 @@ { I& ima = exact(ima_); const J& data = exact(data_); - mln_precondition(ima.has_data() && data.has_data()); + mln_precondition(ima.domain() <= data.domain()); mln_piter(I) p(ima.domain()); for_all(p) Index: mln/level/compare.hh --- mln/level/compare.hh (revision 1013) +++ mln/level/compare.hh (working copy) @@ -45,7 +45,7 @@ * \param[in] lhs A first image. * \param[in] rhs A second image. * - * \todo Test domain equality. + * \pre lhs.domain = rhs.domain */ template <typename L, typename R> bool operator = (const Image<L>& lhs, const Image<R>& rhs); @@ -57,7 +57,7 @@ * \param[in] lhs A first image. * \param[in] rhs A second image. * - * \todo Test domain equality. + * \pre lhs.domain = rhs.domain */ template <typename L, typename R> bool operator < (const Image<L>& lhs, const Image<R>& rhs); @@ -69,7 +69,7 @@ * \param[in] lhs A first image. * \param[in] rhs A second image. * - * \todo Test domain equality. + * \pre lhs.domain = rhs.domain */ template <typename L, typename R> // required! bool operator <= (const Image<L>& lhs, const Image<R>& rhs); @@ -83,6 +83,7 @@ { const L& lhs = exact(lhs_); const R& rhs = exact(rhs_); + mln_precondition(lhs.domain() = rhs.domain()); mln_piter(L) p(lhs.domain()); for_all(p) if (! (lhs(p) = rhs(p))) @@ -95,6 +96,7 @@ { const L& lhs = exact(lhs_); const R& rhs = exact(rhs_); + mln_precondition(lhs.domain() = rhs.domain()); mln_piter(L) p(lhs.domain()); for_all(p) if (! (lhs(p) < rhs(p))) @@ -107,6 +109,7 @@ { const L& lhs = exact(lhs_); const R& rhs = exact(rhs_); + mln_precondition(lhs.domain() = rhs.domain()); mln_piter(L) p(lhs.domain()); for_all(p) if (! (lhs(p) <= rhs(p))) Index: mln/level/paste.hh --- mln/level/paste.hh (revision 1013) +++ mln/level/paste.hh (working copy) @@ -52,12 +52,11 @@ * This routine runs: \n * for all p of \p data, \p destination(p) = \p data(p). * - * \warning The definition domain of \p data has to be included - * in the one of \p destination. + * \warning The definition domain of \p data has to be included in + * the one of \p destination; so using mln::safe_image does not + * make pasting outside the destination domain work. * - * \pre Both images have to be initialized. - * - * \todo Test domain inclusion. + * \pre \p data.domain <= \p destination.domain */ template <typename I, typename J> void paste(const Image<I>& data, Image<J>& destination); @@ -69,8 +68,8 @@ void paste(const Image<I>& data_, Image<J>& destination_) { const I& data = exact(data_); - I& destination = exact(destination_); - assert(ima.has_data() && destination.has_data()); + J& destination = exact(destination_); + mln_precondition(data.domain() <= destination.domain()); mln_piter(I) p(data.domain()); for_all(p) Index: mln/make/window2d.hh --- mln/make/window2d.hh (revision 1013) +++ mln/make/window2d.hh (working copy) @@ -53,13 +53,13 @@ * \return A 2D window. */ template <unsigned M> - mln::window2d window2d(const bool (&values)[M]); + mln::window2d window2d(bool (&values)[M]); # ifndef MLN_INCLUDE_ONLY template <unsigned M> - mln::window2d window2d(const bool (&values)[M]) + mln::window2d window2d(bool (&values)[M]) { int h = unsigned(std::sqrt(float(M))) / 2; assert((2 * h + 1) * (2 * h + 1) = M);
participants (1)
-
Thierry Geraud