https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix the last couple of warnings with g++-3.3.
* mln/core/routine/ops.hh (todo): New.
(operator/=): Add commentary.
* mln/util/adjacency_matrix.hh: Fix u/s warning.
* tests/value/int_u8.cc: De-activate warning-prone line.
* tests/util/adjacency_matrix.cc: Update style.
mln/core/routine/ops.hh | 22 ++++++++++++++++------
mln/util/adjacency_matrix.hh | 13 +++++++------
tests/util/adjacency_matrix.cc | 3 ++-
tests/value/int_u8.cc | 4 +++-
4 files changed, 28 insertions(+), 14 deletions(-)
Index: mln/core/routine/ops.hh
--- mln/core/routine/ops.hh (revision 4042)
+++ mln/core/routine/ops.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Milena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -86,12 +87,15 @@
* can become:
* static O zero =...
* return zero - exact(rhs);
+ *
+ * \todo Address the remark in op/=.
*/
# include <mln/trait/op/all.hh>
# include <mln/core/concept/object.hh>
# include <mln/metal/converts_to.hh>
+
namespace mln
{
@@ -384,6 +388,7 @@
operator%=(Object<L>& lhs, const Object<R>& rhs);
+
# ifndef MLN_INCLUDE_ONLY
// Plus equal.
@@ -395,7 +400,7 @@
{
typedef mln_trait_op_plus(L, R) P;
mlc_converts_to(P, L)::check();
- return exact(lhs) = exact(lhs) + exact(rhs);
+ return exact(lhs) = static_cast<L>(exact(lhs) + exact(rhs));
}
// Minus equal.
@@ -407,7 +412,7 @@
{
typedef mln_trait_op_minus(L, R) M;
mlc_converts_to(M, L)::check();
- return exact(lhs) = exact(lhs) - exact(rhs);
+ return exact(lhs) = static_cast<L>(exact(lhs) - exact(rhs));
}
// Times equal.
@@ -419,7 +424,7 @@
{
typedef mln_trait_op_times(L, R) T;
mlc_converts_to(T, L)::check();
- return exact(lhs) = exact(lhs) * exact(rhs);
+ return exact(lhs) = static_cast<L>(exact(lhs) * exact(rhs));
}
// Div equal.
@@ -431,7 +436,12 @@
{
typedef mln_trait_op_div(L, R) D;
mlc_converts_to(D, L)::check();
- return exact(lhs) = exact(lhs) / exact(rhs);
+ // Remark:
+ // The code below gives a warning with g++-3.3 with the test file
+ // tests/value/int_u8.cc. It is normal since writing "i /= f"
+ // means casting eventually float to int. Yet what do we want in
+ // that case? A quiet compilation or a warning?
+ return exact(lhs) = static_cast<L>(exact(lhs) / exact(rhs));
}
// Mod equal.
@@ -443,7 +453,7 @@
{
typedef mln_trait_op_mod(L, R) M;
mlc_converts_to(M, L)::check();
- return exact(lhs) = exact(lhs) % exact(rhs);
+ return exact(lhs) = static_cast<L>(exact(lhs) % exact(rhs));
}
// Unary plus.
Index: mln/util/adjacency_matrix.hh
--- mln/util/adjacency_matrix.hh (revision 4042)
+++ mln/util/adjacency_matrix.hh (working copy)
@@ -45,6 +45,7 @@
# include <mln/metal/converts_to.hh>
# include <mln/debug/println.hh>
+
namespace mln
{
@@ -262,8 +263,8 @@
adjacency_matrix_impl_selector<V, metal::bool_<false> >
::add(const V& e1, const V& e2)
{
- mln_precondition(e1 < int(nelements_));
- mln_precondition(e2 < int(nelements_));
+ mln_precondition(int(e1) < int(nelements_));
+ mln_precondition(int(e2) < int(nelements_));
adj_.insert(make::ord_pair(e1, e2));
}
@@ -272,8 +273,8 @@
adjacency_matrix_impl_selector<V, metal::bool_<false> >
::remove(const V& e1, const V& e2)
{
- mln_precondition(e1 < int(nelements_));
- mln_precondition(e2 < int(nelements_));
+ mln_precondition(int(e1) < int(nelements_));
+ mln_precondition(int(e2) < int(nelements_));
mln_precondition(adj_.has(make::ord_pair(e1, e2)));
adj_.remove(make::ord_pair(e1, e2));
}
@@ -290,8 +291,8 @@
adjacency_matrix_impl_selector<V, metal::bool_<false> >
::are_adjacent(const V& e1, const V& e2) const
{
- mln_precondition(e1 < int(nelements_));
- mln_precondition(e2 < int(nelements_));
+ mln_precondition(int(e1) < int(nelements_));
+ mln_precondition(int(e2) < int(nelements_));
return adj_.has(make::ord_pair(e1, e2));
}
Index: tests/value/int_u8.cc
--- tests/value/int_u8.cc (revision 4042)
+++ tests/value/int_u8.cc (working copy)
@@ -187,7 +187,9 @@
sym_compare_assert(c, ==, 50.f);
// FIXME: Triggers a warning about signed vs unsigned comparison.
- d /= 2.4f;
+ // Read the todo and the remark in mln/core/routine/ops.hh.
+ //
+ // d /= 2.4f;
}
Index: tests/util/adjacency_matrix.cc
--- tests/util/adjacency_matrix.cc (revision 4042)
+++ tests/util/adjacency_matrix.cc (working copy)
@@ -27,12 +27,13 @@
/// \file tests/util/adjacency_matrix.cc
///
-/// test of mln::util::adjacency_matrix
+/// \brief Test of mln::util::adjacency_matrix.
#include <mln/util/adjacency_matrix.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/int_u16.hh>
+
int main()
{
using namespace mln;