* mln/pw/cst.hh: add the proper traits.
* tests/pw/value.cc: add one more test.
---
milena/ChangeLog | 8 ++++++++
milena/mln/pw/cst.hh | 34 ++++++++++++++++++++++++++++++++++
milena/tests/pw/value.cc | 11 ++++++-----
3 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f672bbb..e9ca068 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2009-01-20 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Make the use of pw::cst() optional in predicates.
+
+ * mln/pw/cst.hh: add the proper traits.
+
+ * tests/pw/value.cc: add one more test.
+
+2009-01-20 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix a double free in fibonacci heap and add support for priority.
* mln/util/fibonacci_heap.hh: Fix the destructor and add an attribute
diff --git a/milena/mln/pw/cst.hh b/milena/mln/pw/cst.hh
index bc344ad..91034cd 100644
--- a/milena/mln/pw/cst.hh
+++ b/milena/mln/pw/cst.hh
@@ -39,6 +39,40 @@
namespace mln
{
+ // Forward declaration
+ namespace pw
+ {
+
+ template <typename T>
+ struct cst_;
+
+ template <typename T>
+ cst_<T> cst(const T& t);
+
+ } // end of namespace mln::pw
+
+
+ namespace trait
+ {
+
+ template <typename F, typename S>
+ struct set_binary_< op::eq, mln::Function_v2v, F, mln::value::Scalar, S >
+ {
+ typedef mln_trait_op_eq(F, pw::cst_<mln_value_equiv(S)>) ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ template <typename F, typename S>
+ mln_trait_op_eq(F,S)
+ operator == (const Function_v2v<F>& fun, const value::Scalar<S>&
s)
+ {
+ return exact(fun) == pw::cst( value::equiv(s) );
+ }
+
+
+
namespace pw
{
diff --git a/milena/tests/pw/value.cc b/milena/tests/pw/value.cc
index 268ebde..19938db 100644
--- a/milena/tests/pw/value.cc
+++ b/milena/tests/pw/value.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/pw/value.cc
- *
- * \brief Test on mln::pw::value_.
- */
+/// \file tests/pw/value.cc
+///
+/// Test on mln::pw::value_.
#include <mln/core/image/image2d.hh>
#include <mln/data/fill.hh>
@@ -45,6 +45,7 @@ int main()
point2d p(1, 1);
ima(p) = 51;
mln_assertion( (pw::value(ima) == pw::cst(51))(p) == true );
+ mln_assertion( (pw::value(ima) == 51)(p) == true );
// {
// image2d<float> imaf(3,3);
--
1.5.6.5
Show replies by date