Olena-patches
  Threads by month 
                
            - ----- 2025 -----
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2024 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2023 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2022 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2021 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2020 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2019 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2018 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2017 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2016 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2015 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2014 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2013 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2012 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2011 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2010 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2009 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2008 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2007 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2006 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2005 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2004 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 
- 9625 discussions
 
                    
                        
https://svn.lrde.epita.fr/svn/oln/trunk/extended
Index: ChangeLog
from  Thierry Geraud  <theo(a)lrde.epita.fr>
	Fix some icpc remarks and update operator traits.
	* xtd/res.hh (macros): Add spaces to fix pb with icpc preproc.
	* xtd/args.hh (xtd_nargs): Likewise.
	* xtd/math/abs.hh (internal::int_): Handwrite code.
	* xtd/math/pow.hh: Cosmetics.
	* xtd/math/arith.hh: Add comments.
	* xtd/literal.hh (argument): Remove reference so that temporaries
	are copied.
	* xtd/abstract/fun_nary_expr.hh: Likewise.
	* xtd/bind.hh: Likewise.
	* xtd/abstract/any.hh: Remove cause obsolete.
	* xtd/abstract/fun.hh: Add doc.
	(abstract::fun_): Disable imperative operators.
	* xtd/abstract/plain_fun.hh: Add doc.
	* xtd/optraits.hh: Rewrite.
	* xtd/traits.hh: New.
	* xtd/builtin/traits.hh: Replace dummy code by effective one.
	* xtd/internal/opmacros.hh: Rewrite.
	* xtd/internal/mlc.hh: Add include.
	* tests: Add ignore rule for '.deps'.
	* tests/cfun.cc: Fix icpc remark.
	* tests/abs.cc: New.
	* tests/optraits.cc: New.
	* tests/Makefile.am: Update.
	* tests/bi_traits: New directory to test builtin op traits.
	* tests/bi_traits/bool.cc: New.
	* tests/bi_traits/char.cc: New.
	* tests/bi_traits/sint.cc: New.
	* tests/bi_traits/uint.cc: New.
	* tests/bi_traits/schar.cc: New.
	* tests/bi_traits/slong.cc: New.
	* tests/bi_traits/uchar.cc: New.
	* tests/bi_traits/sshort.cc: New.
	* tests/bi_traits/ulong.cc: New.
	* tests/bi_traits/ushort.cc: New.
	* tests/bi_traits/float.cc: New.
	* tests/bi_traits/ldouble.cc: New.
	* tests/bi_traits/double.cc: New.
 tests/Makefile.am             |   10 +
 tests/abs.cc                  |   13 ++
 tests/bi_traits/bool.cc       |   48 ++++++++
 tests/bi_traits/char.cc       |   48 ++++++++
 tests/bi_traits/double.cc     |   48 ++++++++
 tests/bi_traits/float.cc      |   48 ++++++++
 tests/bi_traits/ldouble.cc    |   48 ++++++++
 tests/bi_traits/schar.cc      |   48 ++++++++
 tests/bi_traits/sint.cc       |   48 ++++++++
 tests/bi_traits/slong.cc      |   48 ++++++++
 tests/bi_traits/sshort.cc     |   48 ++++++++
 tests/bi_traits/uchar.cc      |   48 ++++++++
 tests/bi_traits/uint.cc       |   48 ++++++++
 tests/bi_traits/ulong.cc      |   48 ++++++++
 tests/bi_traits/ushort.cc     |   48 ++++++++
 tests/cfun.cc                 |    4 
 tests/optraits.cc             |   33 ++++++
 xtd/abstract/fun.hh           |   42 +++++++
 xtd/abstract/fun_nary_expr.hh |   10 -
 xtd/abstract/plain_fun.hh     |   32 +++++
 xtd/bind.hh                   |   10 -
 xtd/builtin/traits.hh         |  194 ++++++++++++++++++++++-------------
 xtd/internal/mlc.hh           |    1 
 xtd/internal/opmacros.hh      |   87 ++++++++++++---
 xtd/literal.hh                |    8 -
 xtd/math/abs.hh               |   10 -
 xtd/math/arith.hh             |    1 
 xtd/math/pow.hh               |    1 
 xtd/optraits.hh               |  229 +++++++++++++++++++++++++++---------------
 xtd/traits.hh                 |   74 +++++++++++++
 30 files changed, 1186 insertions(+), 197 deletions(-)
Index: xtd/res.hh
Index: xtd/math/abs.hh
--- xtd/math/abs.hh	(revision 456)
+++ xtd/math/abs.hh	(working copy)
@@ -56,12 +56,12 @@
 
   namespace internal {
 
-    int           abs_(int i)           { return std::abs(i); }
-    long int      abs_(long int i)      { return std::abs(i); }
+    int           abs_(int x)           { return x < 0 ? -x : x; }
+    long int      abs_(long int x)      { return x < 0 ? -x : x; }
 
-    float         abs_(float i)         { return std::fabs(i); }
-    double        abs_(double i)        { return std::fabs(i); }
-    long double   abs_(long double i)   { return std::fabs(i); }
+    float         abs_(float x)         { return std::abs(x); }
+    double        abs_(double x)        { return std::abs(x); }
+    long double   abs_(long double x)   { return std::abs(x); }
 
   } // end of namespace xtd::internal
 
Index: xtd/math/pow.hh
--- xtd/math/pow.hh	(revision 456)
+++ xtd/math/pow.hh	(working copy)
@@ -102,6 +102,7 @@
   const pow_type                       pow;
 
 
+
 } // end of namespace xtd
 
 
Index: xtd/math/arith.hh
--- xtd/math/arith.hh	(revision 456)
+++ xtd/math/arith.hh	(working copy)
@@ -39,6 +39,7 @@
   xtd_internal_decl_binary_operator( mult,  * );
   xtd_internal_decl_binary_operator( div,   / );
   xtd_internal_decl_binary_operator( mod,   % );
+//   xtd_internal_decl_binary_operator( pow,   ^ );  // Cf. xtd/math/pow.hh
 
   xtd_internal_decl_unary_operator( uminus, - );
 
Index: xtd/args.hh
Index: xtd/literal.hh
--- xtd/literal.hh	(revision 456)
+++ xtd/literal.hh	(working copy)
@@ -68,7 +68,7 @@
   {
     const T value;
 
-    plain_literal_(const T& value)
+    plain_literal_(T value)
       : value(value)
     {} 
 
@@ -106,7 +106,7 @@
   {
     const T value;
 
-    meta_literal_(const T& value)
+    meta_literal_(T value)
       : value(value)
     {} 
 
@@ -150,7 +150,7 @@
   {
     const T value;
 
-    literal_expr_(const T& value) :
+    literal_expr_(T value) :
       value(value)
     {}
 
@@ -165,7 +165,7 @@
   // FIXME: doc
 
   template <typename T>
-  literal_expr_<T> lit(const T& value)
+  literal_expr_<T> lit(T value)
   {
     literal_expr_<T> tmp(value);
     return tmp;
Index: xtd/optraits.hh
--- xtd/optraits.hh	(revision 456)
+++ xtd/optraits.hh	(working copy)
@@ -28,141 +28,210 @@
 #ifndef EXTENDED_OPTRAITS_HH
 # define EXTENDED_OPTRAITS_HH
 
-# include <mlc/flags.hh>
+# include <xtd/traits.hh>
+# include <xtd/builtin/traits.hh>
 
 
 
-// logic
+namespace xtd
+{
 
-# define xtd_land(L, R)  typename xtd::land_trait_<L, R>::ret 
-# define xtd_lor(L, R)   typename xtd::lor_trait_<L, R>::ret 
-# define xtd_lxor(L, R)  typename xtd::lxor_trait_<L, R>::ret 
 
-# define xtd_lnot(T)     typename xtd::lnot_trait_<T>::ret 
+  /// \{
+  /// Tags to designate operators.
 
+  namespace abstract
+  {
+    struct oper
+    {};
 
-// cmp
+    struct op_tag
+    {};
 
-# define xtd_eq(L, R)      typename xtd::eq_trait_<L, R>::ret 
-# define xtd_neq(L, R)     typename xtd::neq_trait_<L, R>::ret 
-# define xtd_less(L, R)    typename xtd::less_trait_<L, R>::ret 
-# define xtd_leq(L, R)     typename xtd::leq_trait_<L, R>::ret 
-# define xtd_greater(L, R) typename xtd::greater_trait_<L, R>::ret 
-# define xtd_geq(L, R)     typename xtd::geq_trait_<L, R>::ret 
+  } // end of namespace xtd::abstract
 
 
-// arith
 
-# define xtd_plus(L, R)  typename xtd::plus_trait_<L, R>::ret 
-# define xtd_minus(L, R) typename xtd::minus_trait_<L, R>::ret 
-# define xtd_mult(L, R)  typename xtd::mult_trait_<L, R>::ret 
-# define xtd_div(L, R)   typename xtd::div_trait_<L, R>::ret 
-# define xtd_mod(L, R)   typename xtd::mod_trait_<L, R>::ret 
+  template <typename opname>
+  struct op_
 
-# define xtd_uminus(T)   typename xtd::uminus_trait_<T>::ret 
+    : public abstract::oper,
 
+      private mlc::assert_< mlc_is_a(opname, abstract::op_tag),
+			    xtd::ERROR::FIXME >
+  {
+  };
 
 
-// FIXME: xtd_plus(L, R) should be xtd::INTERNAL::plus_trait_< L, R >::ret
-// FIXME: which checks that the trait *is* defined
 
+  // logic
 
+  struct land    : public abstract::op_tag {};
+  struct lor     : public abstract::op_tag {};
+  struct lxor    : public abstract::op_tag {};
+  struct lnot    : public abstract::op_tag {};
+
+  typedef op_<land> op_land;
+  typedef op_<lor > op_lor;
+  typedef op_<lxor> op_lxor;
+  typedef op_<lnot> op_lnot;
 
-namespace xtd
-{
+  // cmp
 
-  // logic
+  struct eq      : public abstract::op_tag {};
+  struct neq     : public abstract::op_tag {};
+  struct less    : public abstract::op_tag {};
+  struct leq     : public abstract::op_tag {};
+  struct greater : public abstract::op_tag {};
+  struct geq     : public abstract::op_tag {};
+
+  typedef op_<eq     > op_eq;
+  typedef op_<neq    > op_neq;
+  typedef op_<less   > op_less;
+  typedef op_<leq    > op_leq;
+  typedef op_<greater> op_greater;
+  typedef op_<geq    > op_geq;
 
-  template <typename L, typename R>
-  struct land_trait_ : public mlc::undefined
-  {
-  };
+  // arith
 
-  template <typename L, typename R>
-  struct lor_trait_ : public mlc::undefined
-  {
-  };
+  struct plus   : public abstract::op_tag {};
+  struct minus  : public abstract::op_tag {};
+  struct mult   : public abstract::op_tag {};
+  struct div    : public abstract::op_tag {};
+  struct mod    : public abstract::op_tag {};
+  struct uminus : public abstract::op_tag {};
 
-  template <typename L, typename R>
-  struct lxor_trait_ : public mlc::undefined
-  {
-  };
+  typedef op_<plus  > op_plus;
+  typedef op_<minus > op_minus;
+  typedef op_<mult  > op_mult;
+  typedef op_<div   > op_div;
+  typedef op_<mod   > op_mod;
+  typedef op_<uminus> op_uminus;
 
-  template <typename T>
-  struct lnot_trait_ : public mlc::undefined
-  {
-  };
+  /// \}
 
 
-  // cmp
 
-  template <typename L, typename R>
-  struct eq_trait_ : public mlc::undefined
-  {
-  };
 
-  template <typename L, typename R>
-  struct neq_trait_ : public mlc::undefined
-  {
-  };
 
-  template <typename L, typename R>
-  struct less_trait_ : public mlc::undefined
+  template < typename name,
+	     typename data >
+  struct default_case_ < op_<name>, data >
   {
+    typedef mlc::undefined ret;
   };
 
-  template <typename L, typename R>
-  struct leq_trait_ : public mlc::undefined
-  {
-  };
 
-  template <typename L, typename R>
-  struct greater_trait_ : public mlc::undefined
+  template <typename name,
+	    typename T>
+  struct case_ < op_<name>, T,
+		 1 > : public mlc::where_< mlc_is_builtin(T) >,
+
+		       private mlc::assert_< mlc_is_not_a(T, mlc::pair_),
+					     xtd::ERROR::FIXME >
   {
+    typedef T ret; // FIXME: fake!!!
   };
 
-  template <typename L, typename R>
-  struct geq_trait_ : public mlc::undefined
+
+  template <typename name,
+	    typename L, typename R>
+  struct case_ < op_<name>, mlc::pair_<L, R>,
+		 1 > : public mlc::where_< mlc::and_<mlc_is_builtin(L), mlc_is_builtin(R)> >
   {
+    struct protected_ {
+      typedef typename xtd::switch_< internal::UAC, mlc::pair_<L, R> >::ret ret;
+    };
   };
 
 
-  // arith
 
-  template <typename L, typename R>
-  struct plus_trait_ : public mlc::undefined
+  namespace internal
   {
-  };
 
-  template <typename L, typename R>
-  struct minus_trait_ : public mlc::undefined
-  {
-  };
 
-  template <typename L, typename R>
-  struct mult_trait_ : public mlc::undefined // FIXME: or "times"?
-  {
-  };
+    template < typename name,
+	       typename L, typename R >
+    struct get_trait_ < op_<name>, L, R >
 
-  template <typename L, typename R>
-  struct div_trait_ : public mlc::undefined
-  {
-  };
+      : private mlc::assert_< mlc::implies_< mlc::is_defined_<   xtd::set_trait_<op_<name>, L, R> >,
+					     mlc::ret_found_in_< xtd::set_trait_<op_<name>, L, R> > >,
+			      xtd::ERROR::FIXME >,
 
-  template <typename L, typename R>
-  struct mod_trait_ : public mlc::undefined
+	private mlc::assert_< mlc::implies_< mlc::is_undefined_< xtd::set_trait_<op_<name>, L, R> >,
+					     mlc::neq_< typename get_case_< op_<name>, mlc::pair_<L, R> >::ret,
+							mlc::none > >,
+			      xtd::ERROR::FIXME >
   {
+      typedef xtd::set_trait_< op_<name>, L, R > user_trait;
+      typedef mlc_ret(user_trait) user_ret;
+
+      typedef typename get_case_< op_<name>, mlc::pair_<L, R> >::ret case_t;
+      typedef mlc_ret(case_t) case_ret;
+
+      typedef typename mlc::if_< mlc_is_found(user_ret), user_ret, case_ret >::ret ret;
   };
 
-  template <typename T>
-  struct uminus_trait_ : public mlc::undefined
+
+    template < typename name,
+	       typename T >
+    struct get_trait_ < op_<name>, T >
+
+      : private mlc::assert_< mlc::implies_< mlc::is_defined_<   xtd::set_trait_<op_<name>, T> >,
+					     mlc::ret_found_in_< xtd::set_trait_<op_<name>, T> > >,
+			      xtd::ERROR::FIXME >
   {
+      typedef xtd::set_trait_< op_<name>, T > user_trait;
+      typedef mlc_ret(user_trait) user_ret;
+
+      typedef typename get_case_< op_<name>, T >::ret case_t;
+      typedef mlc_ret(case_t) case_ret;
+
+      typedef typename mlc::if_< mlc_is_found(user_ret), user_ret, case_ret >::ret ret;
   };
 
+  } // end of namespace xtd::internal
+
 
 
 } // end of namespace xtd
 
 
 
+// logic
+
+# define xtd_op_land_trait(L, R)  typename xtd::internal::get_trait_<xtd::op_land, L, R>::ret 
+# define xtd_op_lor_trait(L, R)   typename xtd::internal::get_trait_<xtd::op_lor, L, R>::ret 
+# define xtd_op_lxor_trait(L, R)  typename xtd::internal::get_trait_<xtd::op_lxor, L, R>::ret 
+
+# define xtd_op_lnot_trait(T)     typename xtd::internal::get_trait_<xtd::op_lnot, T>::ret 
+
+
+// cmp
+
+# define xtd_op_eq_trait(L, R)      typename xtd::internal::get_trait_<xtd::op_eq, L, R>::ret 
+# define xtd_op_neq_trait(L, R)     typename xtd::internal::get_trait_<xtd::op_neq, L, R>::ret 
+# define xtd_op_less_trait(L, R)    typename xtd::internal::get_trait_<xtd::op_less, L, R>::ret 
+# define xtd_op_leq_trait(L, R)     typename xtd::internal::get_trait_<xtd::op_leq, L, R>::ret 
+# define xtd_op_greater_trait(L, R) typename xtd::internal::get_trait_<xtd::op_greater, L, R>::ret 
+# define xtd_op_geq_trait(L, R)     typename xtd::internal::get_trait_<xtd::op_geq, L, R>::ret 
+
+
+// arith
+
+# define xtd_op_plus_trait(L, R)  typename xtd::internal::get_trait_<xtd::op_plus, L, R>::ret 
+# define xtd_op_plus_trait_(L, R)          xtd::internal::get_trait_<xtd::op_plus, L, R>::ret 
+# define xtd_op_minus_trait(L, R) typename xtd::internal::get_trait_<xtd::op_minus, L, R>::ret 
+# define xtd_op_minus_trait_(L, R)         xtd::internal::get_trait_<xtd::op_minus, L, R>::ret 
+# define xtd_op_mult_trait(L, R)  typename xtd::internal::get_trait_<xtd::op_mult, L, R>::ret 
+# define xtd_op_mult_trait_(L, R)          xtd::internal::get_trait_<xtd::op_mult, L, R>::ret 
+# define xtd_op_div_trait(L, R)   typename xtd::internal::get_trait_<xtd::op_div, L, R>::ret 
+# define xtd_op_div_trait_(L, R)           xtd::internal::get_trait_<xtd::op_div, L, R>::ret 
+# define xtd_op_mod_trait(L, R)   typename xtd::internal::get_trait_<xtd::op_mod, L, R>::ret 
+# define xtd_op_mod_trait_(L, R)           xtd::internal::get_trait_<xtd::op_mod, L, R>::ret 
+
+# define xtd_op_uminus_trait(T)   typename xtd::internal::get_trait_<xtd::op_uminus, T>::ret 
+
+
+
 #endif // ! EXTENDED_OPTRAITS_HH
Index: xtd/abstract/fun.hh
--- xtd/abstract/fun.hh	(revision 456)
+++ xtd/abstract/fun.hh	(working copy)
@@ -37,10 +37,18 @@
   namespace abstract
   {
 
-    /*! \class xtd::abstract::fun_
+    /*! \class xtd::abstract::fun_<E>
     **
-    ** Abstract base class for xtd functions.  Parameter E is the
-    ** exact type of the function.
+    ** Abstract base class for xtd functions.  These functions are
+    ** pure (non imperative); they can be plain, meta, or expr.
+    ** Parameter E is the exact type of the function.
+    ** 
+    ** \note 1) This base class is useful to check if a type is the
+    ** one of an xtd function.  2) As an xtd function is pure, all
+    ** imperative operators are disabled.
+    **
+    ** \see xtd::abstract::plain_fun_<E>, xtd::abstract::meta_fun_<E>,
+    ** xtd::abstract::fun_expr_<E>
     */
 
     template <typename E>
@@ -48,12 +56,40 @@
     {
     public:
 
+      /// Static dispatch of this towards its exact type.
       const E& exact() const
       {
 	return *(const E*)(const void*)(this);
       }
       
+      /// \{
+      /// Imperative operators are disabled.
+      template <typename T> void operator %= (const T&) const;
+      template <typename T> void operator &= (const T&) const;
+      template <typename T> void operator *= (const T&) const;
+      template <typename T> void operator += (const T&) const;
+      template <typename T> void operator -= (const T&) const;
+      template <typename T> void operator /= (const T&) const;
+      template <typename T> void operator ^= (const T&) const;
+      template <typename T> void operator |= (const T&) const;
+      template <typename T> void operator = (const T&);
+      void operator ++ () const;
+      void operator -- () const;
+      void operator ++ (int) const;
+      void operator -- (int) const;
+      /// \}
+
+      /// \{
+      /// Operators "*(x)" and "(x)->" are disabled.
+      void operator *  () const;
+      void operator -> () const;
+      /// \}
+
+      /// Conversion operator is disabled.
+      template <typename T> operator T () const;
+      
     protected:
+      /// Ctor is protected so that this class seems abstract.
       fun_() {}
     };
 
Index: xtd/abstract/plain_fun.hh
--- xtd/abstract/plain_fun.hh	(revision 456)
+++ xtd/abstract/plain_fun.hh	(working copy)
@@ -31,8 +31,9 @@
 # include <xtd/abstract/fun.hh>
 
 
-// macro
-
+/** \def xtd_res(F)
+ ** \brief Macro to get the result type of a plain function of type F.
+ */
 # define xtd_res(F)  typename xtd::typedef_::res_type::from_<xtd::fun_traits_<F> >::ret
 
 
@@ -50,6 +51,12 @@
   } // end of namespace xtd::ERROR
 
 
+  /*! \class xtd::fun_traits_<F>
+  **
+  ** Traits class for a plain function of type F.  This class should
+  ** be specialized to provide (thru typedefs) the result type and
+  ** the argument types.
+  */
 
   template <typename F>
   struct fun_traits_ : public mlc::undefined
@@ -63,10 +70,27 @@
   namespace abstract
   {
 
-    /*! \class xtd::abstract::plain_fun_
+    /*! \class xtd::abstract::plain_fun_<E>
     **
     ** Abstract base class for plain functions.  Parameter E is the
     ** exact type of the function.
+    **
+    ** A plain function is a function object knowing the types of its
+    ** input (and consequently of its output).  For instance,
+    ** xtd::cos_f is an instance of xtd::cos_<float>.  This function
+    ** explicitly takes a float (and thus returns a float); so it is a
+    ** plain function.
+    **
+    ** A plain function of type F should define the type of its
+    ** result.  For that the traits class associated with this
+    ** function type, fun_traits_<F>, should be specialized and
+    ** contain a typedef res_type.  The result type is then accessible
+    ** thru the macro xtd_res(F) where F is the type of the plain
+    ** function.
+    **
+    ** An xtd plain function is an xtd function.
+    **
+    ** \see xtd::fun_traits_<F>, xtd_res(F)
     */
 
     template <typename E>
@@ -80,6 +104,8 @@
 
 	public fun_<E>
     {
+    public:
+
     protected:
       plain_fun_(){
 	// FIXME: unsigned is parameter so mlc_is_a does not work
Index: xtd/abstract/fun_nary_expr.hh
--- xtd/abstract/fun_nary_expr.hh	(revision 456)
+++ xtd/abstract/fun_nary_expr.hh	(working copy)
@@ -170,11 +170,11 @@
 
       template <typename T>
       m2expr_< E, literal_expr_<T>, arg_<2> >
-      bind_1(const T& value) const;
+      bind_1(T value) const;
 
       template <typename T>
       m2expr_< E, arg_<1>, literal_expr_<T> >
-      bind_2(const T& value) const;
+      bind_2(T value) const;
 
     protected:
       fun_nary_expr_() {}
@@ -207,15 +207,15 @@
 
       template <typename T>
       m3expr_< E, literal_expr_<T>, arg_<2>, arg_<3> >
-      bind_1(const T& value) const;
+      bind_1(T value) const;
 
       template <typename T>
       m3expr_< E, arg_<1>, literal_expr_<T>, arg_<3> >
-      bind_2(const T& value) const;
+      bind_2(T value) const;
 
       template <typename T>
       m3expr_< E, arg_<1>, arg_<2>, literal_expr_<T> >
-      bind_3(const T& value) const;
+      bind_3(T value) const;
 
     protected:
       fun_nary_expr_() {}
Index: xtd/traits.hh
--- xtd/traits.hh	(revision 0)
+++ xtd/traits.hh	(revision 0)
@@ -0,0 +1,74 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_TRAITS_HH
+# define EXTENDED_TRAITS_HH
+
+# include <xtd/internal/mlc.hh>
+
+
+namespace xtd
+{
+
+  namespace ERROR
+  {
+    struct FIXME;
+
+  } // end of namespace xtd::ERROR
+
+
+
+  template < typename subject,
+	     typename T1,
+	     typename T2 = mlc::none >
+  struct set_trait_ : public mlc::undefined
+  {
+  };
+
+
+
+  namespace internal
+  {
+
+    template < typename subject,
+	       typename T1,
+	       typename T2 = mlc::none >
+    struct get_trait_
+
+      : private mlc::assert_< mlc::is_defined_< xtd::set_trait_<subject, T1, T2> >,
+			      xtd::ERROR::FIXME >
+    {
+    };
+
+  } // end of namespace xtd::internal
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_TRAITS_HH
Index: xtd/builtin/traits.hh
--- xtd/builtin/traits.hh	(revision 456)
+++ xtd/builtin/traits.hh	(working copy)
@@ -28,95 +28,149 @@
 #ifndef EXTENDED_BUILTIN_TRAITS_HH
 # define EXTENDED_BUILTIN_TRAITS_HH
 
-# include <xtd/optraits.hh>
+# include <xtd/traits.hh>
 
 
 
-// FIXME: this is dummy and incomplete code!
+# define xtd_intprom(Type) typename xtd::internal::intprom_<Type>::ret
 
 
-# define xtd_internal_DUMMY_builtin_arith_traits(OperatorName)						\
-													\
-  template <typename T>											\
-  struct OperatorName##_trait_ < T, T >									\
-  {													\
-    typedef T ret;											\
-  };													\
-													\
-  template <> struct OperatorName##_trait_ < float, int > { typedef float ret; };			\
-  template <> struct OperatorName##_trait_ < int, float > { typedef float ret; };			\
-  template <> struct OperatorName##_trait_ < double, int > { typedef double ret; };			\
-  template <> struct OperatorName##_trait_ < int, double > { typedef double ret; };			\
-  template <> struct OperatorName##_trait_ < double, float > { typedef double ret; };			\
-  template <> struct OperatorName##_trait_ < float, double > { typedef double ret; };			\
-													\
-  template <> struct OperatorName##_trait_ < long double, int > { typedef long double ret; };		\
-  template <> struct OperatorName##_trait_ < int, long double > { typedef long double ret; };		\
-  template <> struct OperatorName##_trait_ < long double, float > { typedef long double ret; };		\
-  template <> struct OperatorName##_trait_ < float, long double > { typedef long double ret; };		\
-  template <> struct OperatorName##_trait_ < long double, double > { typedef long double ret; };	\
-  template <> struct OperatorName##_trait_ < double, long double > { typedef long double ret; };	\
-													\
-  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
-
-
-# define xtd_internal_DUMMY_builtin_logic_traits(OperatorName)	\
-								\
-  template <>							\
-  struct OperatorName##_trait_ < bool, bool >			\
-  {								\
-    typedef bool ret;						\
-  };								\
-								\
-  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
-
-
-# define xtd_internal_DUMMY_builtin_cmp_traits(OperatorName)	\
-								\
-  template <typename T>						\
-  struct OperatorName##_trait_ < T, T >				\
-  {								\
-    typedef bool ret;						\
-  };								\
-								\
-  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
 
+namespace xtd
+{
+
+  // built-in traits and usual arithmetic conversions
 
+  namespace internal
+  {
   
+    // see page 90 of ISO-IEC_14882.2003.pdf
 
-namespace xtd
+
+    struct UAC; // for "usual arithmetic conversions"
+
+    // Integral promotion such as defined in FIXME: std.
+
+    template <class T>
+    struct intprom_
 {
+      typedef T ret;
+    };
 
-  // logic
+    // FIXME: approx?
 
-  xtd_internal_DUMMY_builtin_logic_traits( land );
-  xtd_internal_DUMMY_builtin_logic_traits( lor );
-  xtd_internal_DUMMY_builtin_logic_traits( lxor );
+    template <> struct intprom_ <char> { typedef int ret; };
+    template <> struct intprom_ <signed char> { typedef int ret; };
+    template <> struct intprom_ <unsigned char> { typedef int ret; };
+    template <> struct intprom_ <unsigned short int> { typedef int ret; };
 
-  template <> struct lnot_trait_< bool > { typedef bool ret; };
+    template <> struct intprom_ <bool> { typedef int ret; }; // FIXME: right?
 
-  // cmp
+  } // end of namespace mlc::internal
 
-  xtd_internal_DUMMY_builtin_cmp_traits( eq );
-  xtd_internal_DUMMY_builtin_cmp_traits( neq );
-  xtd_internal_DUMMY_builtin_cmp_traits( less );
-  xtd_internal_DUMMY_builtin_cmp_traits( leq );
-  xtd_internal_DUMMY_builtin_cmp_traits( greater );
-  xtd_internal_DUMMY_builtin_cmp_traits( geq );
 
+  // 1) Prevent bool to be involved in arithmetics.
+  template <typename L, typename R>
+  struct case_ < internal::UAC, mlc::pair_<L, R>,
+		 1 >
+    : public mlc::where_< mlc::or_< mlc::eq_<L, bool>,
+				    mlc::eq_<R, bool> > >
+  {
+    typedef mlc::undefined ret;
+  };
 
-  // arith
+  // 2) If either operand is of type long double, the other shall be
+  // 2) converted to long double.
+  template <typename L, typename R>
+  struct case_ < internal::UAC, mlc::pair_<L, R>,
+		 2 >
+    : public mlc::where_< mlc::or_< mlc::eq_<L, long double>,
+				    mlc::eq_<R, long double> > >
+  {
+    typedef long double ret;
+  };
 
-  xtd_internal_DUMMY_builtin_arith_traits( plus );
-  xtd_internal_DUMMY_builtin_arith_traits( minus );
-  xtd_internal_DUMMY_builtin_arith_traits( mult );
-  xtd_internal_DUMMY_builtin_arith_traits( div );
-  xtd_internal_DUMMY_builtin_arith_traits( mod );
+  // 3) Otherwise, if either operand is double, the other shall be
+  // 3) converted to double.
+  template <typename L, typename R>
+  struct case_ < internal::UAC, mlc::pair_<L, R>,
+		 3 >
+    : public mlc::where_< mlc::or_< mlc::eq_<L, double>,
+				    mlc::eq_<R, double> > >
+  {
+    typedef double ret;
+  };
 
-  template <> struct uminus_trait_< int > { typedef int ret; };
-  template <> struct uminus_trait_< float > { typedef float ret; };
-  template <> struct uminus_trait_< double > { typedef double ret; };
-  template <> struct uminus_trait_< long double > { typedef long double ret; };
+  // 4) Otherwise, if either operand is float, the other shall be
+  // 4) converted to float.
+  template <typename L, typename R>
+  struct case_ < internal::UAC, mlc::pair_<L, R>,
+		 4 >
+    : public mlc::where_< mlc::or_< mlc::eq_<L, float>,
+				    mlc::eq_<R, float> > >
+  {
+    typedef float ret;
+  };
+  
+  // 5) If either operand is unsigned long the other shall be
+  // 5) converted to unsigned long.
+  template <typename L, typename R>
+  struct case_ < internal::UAC, mlc::pair_<L, R>,
+		 5 >
+    : public mlc::where_< mlc::or_< mlc::eq_<L, unsigned long>,
+				    mlc::eq_<R, unsigned long> > >
+  {
+    typedef unsigned long ret;
+  };
+  
+  // 6) Otherwise, if one operand is a long int and the other unsigned
+  // 6) int, then if a long int can represent all the values of an
+  // 6) unsigned int, the unsigned int shall be converted to a long
+  // 6) int; otherwise both operands shall be converted to unsigned
+  // 6) long int.
+  template <typename L, typename R>
+  struct case_ < internal::UAC, mlc::pair_<L, R>,
+		 6 >
+    : public mlc::where_< mlc::or_< mlc::and_< mlc::eq_<xtd_intprom(L), long int>,
+					       mlc::eq_<xtd_intprom(R), unsigned int> >,
+				    mlc::and_< mlc::eq_<xtd_intprom(R), long int>,
+					       mlc::eq_<xtd_intprom(L), unsigned int> > > >
+  {
+    typedef long int ret; // FIXME: approx...
+  };
+
+  // 7) Otherwise, if either operand is long, the other shall be
+  // 7) converted to long.
+  template <typename L, typename R>
+  struct case_ < internal::UAC, mlc::pair_<L, R>,
+		 7 >
+    : public mlc::where_< mlc::or_< mlc::eq_<xtd_intprom(L), long>,
+				    mlc::eq_<xtd_intprom(R), long> > >
+  {
+    typedef long ret;
+  };
+
+  // 8) Otherwise, if either operand is unsigned, the other shall be
+  // 8) converted to unsigned.
+  template <typename L, typename R>
+  struct case_ < internal::UAC, mlc::pair_<L, R>,
+		 8 >
+    : public mlc::where_< mlc::or_< mlc::eq_<xtd_intprom(L), unsigned>,
+				    mlc::eq_<xtd_intprom(R), unsigned> > >
+  {
+    typedef unsigned ret;
+  };
+
+
+  // 0) Note: otherwise, the only remaining case is that both operands
+  // 0) are int.
+  template <typename L, typename R>
+  struct default_case_ < internal::UAC, mlc::pair_<L, R> >
+  {
+    // FIXME: test that:
+    // mlc::or_<mlc::eq_<xtd_intprom(L), int>, mlc::eq_<xtd_intprom(R), int> >
+    typedef int ret;
+  };
 
 
 } // end of namespace xtd
Index: xtd/bind.hh
--- xtd/bind.hh	(revision 456)
+++ xtd/bind.hh	(working copy)
@@ -46,7 +46,7 @@
     template <typename E>
     template <typename T>
     m2expr_< E, literal_expr_<T>, arg_<2> >
-    fun_nary_expr_< 2, E >::bind_1(const T& value) const
+    fun_nary_expr_< 2, E >::bind_1(T value) const
     {
       typedef m2expr_< E, literal_expr_<T>, arg_<2> > ret;
       ret tmp(this->exact(), lit(value), arg_<2>());
@@ -56,7 +56,7 @@
     template <typename E>
     template <typename T>
     m2expr_< E, arg_<1>, literal_expr_<T> >
-    fun_nary_expr_< 2, E >::bind_2(const T& value) const
+    fun_nary_expr_< 2, E >::bind_2(T value) const
     {
       typedef m2expr_< E, arg_<1>, literal_expr_<T> > ret;
       ret tmp(this->exact(), arg_<1>(), lit(value));
@@ -69,7 +69,7 @@
     template <typename E>
     template <typename T>
     m3expr_< E, literal_expr_<T>, arg_<2>, arg_<3> >
-    fun_nary_expr_< 3, E >::bind_1(const T& value) const
+    fun_nary_expr_< 3, E >::bind_1(T value) const
     {
       typedef m3expr_< E, literal_expr_<T>, arg_<2>, arg_<3> > ret;
       ret tmp(this->exact(), lit(value), arg_<2>(), arg_<3>());
@@ -79,7 +79,7 @@
     template <typename E>
     template <typename T>
     m3expr_< E, arg_<1>, literal_expr_<T>, arg_<3> >
-    fun_nary_expr_< 3, E >::bind_2(const T& value) const
+    fun_nary_expr_< 3, E >::bind_2(T value) const
     {
       typedef m3expr_< E, arg_<1>, literal_expr_<T>, arg_<3> > ret;
       ret tmp(this->exact(), arg_<1>(), lit(value), arg_<3>());
@@ -89,7 +89,7 @@
     template <typename E>
     template <typename T>
     m3expr_< E, arg_<1>, arg_<2>, literal_expr_<T> >
-    fun_nary_expr_< 3, E >::bind_3(const T& value) const
+    fun_nary_expr_< 3, E >::bind_3(T value) const
     {
       typedef m3expr_< E, arg_<1>, arg_<2>, literal_expr_<T> > ret;
       ret tmp(this->exact(), arg_<1>(), arg_<2>(), lit(value));
Index: xtd/internal/opmacros.hh
--- xtd/internal/opmacros.hh	(revision 456)
+++ xtd/internal/opmacros.hh	(working copy)
@@ -28,6 +28,7 @@
 #ifndef EXTENDED_INTERNAL_OPMACROS_HH
 # define EXTENDED_INTERNAL_OPMACROS_HH
 
+# include <mlc/if.hh>
 # include <xtd/math/includes.hh>
 
 # include <xtd/abstract/fun_expr.hh>
@@ -49,7 +50,7 @@
   struct fun_traits_< plain_##OperatorName##_<T> >			\
   {									\
     typedef T arg_type;							\
-    typedef xtd_##OperatorName(T) res_type;				\
+    typedef xtd_op_##OperatorName##_trait(T) res_type;					\
   };									\
 									\
 									\
@@ -71,6 +72,16 @@
 									\
 									\
   template <typename Expr>						\
+  struct case_ < op_##OperatorName, Expr,						\
+		 2 > : public mlc::where_< mlc_is_a(Expr, xtd::abstract::fun_expr_) >	\
+  {											\
+    struct protected_ {									\
+      typedef xtd::m1expr_<xtd::OperatorName##_type, Expr> ret;				\
+    };											\
+  };											\
+											\
+											\
+  template <typename Expr>								\
   xtd::m1expr_<xtd::OperatorName##_type, Expr>				\
   operator OperatorSymbol (const xtd::abstract::fun_expr_<Expr>& expr)	\
   {									\
@@ -79,16 +90,41 @@
   }									\
 									\
 									\
-  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n				\
+  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
 
 
-//   FIXME: does not specialize any template arguments
 
-//   template <typename Expr>
-//   struct OperatorName##_trait_ < Expr >
-//   {
-//     typedef xtd::m1expr_<xtd::OperatorName##_type, Expr> ret;
-//   };
+
+
+# define xtd_internal_decl_binop_w_lit(OperatorName, OperatorSymbol, Builtin)	\
+										\
+										\
+  template <typename Rexpr>							\
+  xtd::m2expr_<xtd::OperatorName##_type, xtd::literal_expr_<Builtin>, Rexpr>	\
+  operator OperatorSymbol (Builtin value,					\
+			   const xtd::abstract::fun_expr_<Rexpr>& rexpr)	\
+  {										\
+    typedef xtd::literal_expr_<Builtin> Lexpr;					\
+    Lexpr lexpr(value);								\
+    xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> tmp(lexpr, rexpr);	\
+    return tmp;									\
+  }										\
+										\
+										\
+  template <typename Lexpr>							\
+  xtd::m2expr_<xtd::OperatorName##_type, Lexpr, xtd::literal_expr_<Builtin> >	\
+  operator OperatorSymbol (const xtd::abstract::fun_expr_<Lexpr>& lexpr,	\
+			   Builtin value)					\
+  {										\
+    typedef xtd::literal_expr_<Builtin> Rexpr;					\
+    Rexpr rexpr(value);								\
+    xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> tmp(lexpr, rexpr);	\
+    return tmp;									\
+  }										\
+										\
+										\
+  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+
 
 
 
@@ -103,7 +139,7 @@
   {										\
     typedef T1 arg1_type;							\
     typedef T2 arg2_type;							\
-    typedef xtd_##OperatorName(T1, T2) res_type;				\
+    typedef xtd_op_##OperatorName##_trait(T1, T2) res_type;					\
   };										\
 										\
 										\
@@ -124,6 +160,25 @@
   const OperatorName##_type OperatorName;					\
 										\
 										\
+  template <typename L, typename R>								\
+  struct case_ < op_##OperatorName, mlc::pair_<L, R>,						\
+		 2 > : public mlc::where_< mlc::or_< mlc_is_a(L, xtd::abstract::fun_expr_),	\
+						     mlc_is_a(R, xtd::abstract::fun_expr_) > >	\
+  {												\
+    struct protected_ {										\
+      typedef typename mlc::if_< mlc_is_a(L, xtd::abstract::fun_expr_),				\
+				 L,								\
+				 xtd::literal_expr_<L> >::ret Lexpr;				\
+												\
+      typedef typename mlc::if_< mlc_is_a(R, xtd::abstract::fun_expr_),				\
+				 R,								\
+				 xtd::literal_expr_<R> >::ret Rexpr;				\
+												\
+      typedef xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> ret;				\
+    };												\
+  };												\
+												\
+												\
   template <typename Lexpr, typename Rexpr>					\
   xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr>				\
   operator OperatorSymbol (const xtd::abstract::fun_expr_<Lexpr>& lexpr,	\
@@ -134,16 +189,14 @@
   }										\
 										\
 										\
-  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n					\
-
+  xtd_internal_decl_binop_w_lit(OperatorName, OperatorSymbol, int);				\
+  xtd_internal_decl_binop_w_lit(OperatorName, OperatorSymbol, float);				\
+  xtd_internal_decl_binop_w_lit(OperatorName, OperatorSymbol, double);				\
+												\
+												\
+  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
 
-//   FIXME: does not specialize any template arguments
 
-//   template <typename Lexpr, typename Rexpr>
-//   struct OperatorName##_trait_ < Lexpr, Rexpr >
-//   {
-//     typedef xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> ret;
-//   };
 
 
 #endif // ! EXTENDED_INTERNAL_OPMACROS_HH
Index: xtd/internal/mlc.hh
--- xtd/internal/mlc.hh	(revision 456)
+++ xtd/internal/mlc.hh	(working copy)
@@ -37,6 +37,7 @@
 # include <mlc/assert.hh>
 # include <mlc/is_a.hh>
 # include <mlc/logic.hh>
+# include <mlc/implies.hh>
 # include <mlc/cmp.hh>
 # include <mlc/if.hh>
 
Index: tests/cfun.cc
--- tests/cfun.cc	(revision 456)
+++ tests/cfun.cc	(working copy)
@@ -7,12 +7,12 @@
 namespace my
 {
 
-  float foo()
+  static float foo()
   {
     return 5.1f;
   }
 
-  float bar(int i)
+  static float bar(int i)
   {
     return float(i) * 3.f;
   }
Index: tests/bi_traits/bool.cc
--- tests/bi_traits/bool.cc	(revision 0)
+++ tests/bi_traits/bool.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+//   check_trait(bool, bool);
+//   check_trait(bool, char);
+//   check_trait(bool, float);
+//   check_trait(bool, double);
+//   check_trait(bool, ldouble);
+  check_trait(bool, uchar);
+  check_trait(bool, schar);
+  check_trait(bool, ushort);
+  check_trait(bool, sshort);
+//   check_trait(bool, uint);
+  check_trait(bool, sint);
+//   check_trait(bool, ulong);
+//   check_trait(bool, slong);
+
+}
Index: tests/bi_traits/char.cc
--- tests/bi_traits/char.cc	(revision 0)
+++ tests/bi_traits/char.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+  check_trait(char, bool);
+  check_trait(char, char);
+  check_trait(char, float);
+  check_trait(char, double);
+  check_trait(char, ldouble);
+  check_trait(char, uchar);
+  check_trait(char, schar);
+  check_trait(char, ushort);
+  check_trait(char, sshort);
+  check_trait(char, uint);
+  check_trait(char, sint);
+  check_trait(char, ulong);
+  check_trait(char, slong);
+
+}
Index: tests/bi_traits/sint.cc
--- tests/bi_traits/sint.cc	(revision 0)
+++ tests/bi_traits/sint.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+  check_trait(sint, bool);
+  check_trait(sint, char);
+  check_trait(sint, float);
+  check_trait(sint, double);
+  check_trait(sint, ldouble);
+  check_trait(sint, uchar);
+  check_trait(sint, schar);
+  check_trait(sint, ushort);
+  check_trait(sint, sshort);
+  check_trait(sint, uint);
+  check_trait(sint, sint);
+  check_trait(sint, ulong);
+  check_trait(sint, slong);
+
+}
Index: tests/bi_traits/uint.cc
--- tests/bi_traits/uint.cc	(revision 0)
+++ tests/bi_traits/uint.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+  check_trait(uint, bool);
+  check_trait(uint, char);
+  check_trait(uint, float);
+  check_trait(uint, double);
+  check_trait(uint, ldouble);
+  check_trait(uint, uchar);
+  check_trait(uint, schar);
+  check_trait(uint, ushort);
+  check_trait(uint, sshort);
+  check_trait(uint, uint);
+  check_trait(uint, sint);
+  check_trait(uint, ulong);
+  check_trait(uint, slong);
+
+}
Index: tests/bi_traits/schar.cc
--- tests/bi_traits/schar.cc	(revision 0)
+++ tests/bi_traits/schar.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+  check_trait(schar, bool);
+  check_trait(schar, char);
+  check_trait(schar, float);
+  check_trait(schar, double);
+  check_trait(schar, ldouble);
+  check_trait(schar, uchar);
+  check_trait(schar, schar);
+  check_trait(schar, ushort);
+  check_trait(schar, sshort);
+  check_trait(schar, uint);
+  check_trait(schar, sint);
+  check_trait(schar, ulong);
+  check_trait(schar, slong);
+
+}
Index: tests/bi_traits/slong.cc
--- tests/bi_traits/slong.cc	(revision 0)
+++ tests/bi_traits/slong.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+  check_trait(slong, bool);
+  check_trait(slong, char);
+  check_trait(slong, float);
+  check_trait(slong, double);
+  check_trait(slong, ldouble);
+  check_trait(slong, uchar);
+  check_trait(slong, schar);
+  check_trait(slong, ushort);
+  check_trait(slong, sshort);
+  check_trait(slong, uint);
+  check_trait(slong, sint);
+  check_trait(slong, ulong);
+  check_trait(slong, slong);
+
+}
Index: tests/bi_traits/uchar.cc
--- tests/bi_traits/uchar.cc	(revision 0)
+++ tests/bi_traits/uchar.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+  check_trait(uchar, bool);
+  check_trait(uchar, char);
+  check_trait(uchar, float);
+  check_trait(uchar, double);
+  check_trait(uchar, ldouble);
+  check_trait(uchar, uchar);
+  check_trait(uchar, schar);
+  check_trait(uchar, ushort);
+  check_trait(uchar, sshort);
+  check_trait(uchar, uint);
+  check_trait(uchar, sint);
+  check_trait(uchar, ulong);
+  check_trait(uchar, slong);
+
+}
Index: tests/bi_traits/sshort.cc
--- tests/bi_traits/sshort.cc	(revision 0)
+++ tests/bi_traits/sshort.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+  check_trait(sshort, bool);
+  check_trait(sshort, char);
+  check_trait(sshort, float);
+  check_trait(sshort, double);
+  check_trait(sshort, ldouble);
+  check_trait(sshort, uchar);
+  check_trait(sshort, schar);
+  check_trait(sshort, ushort);
+  check_trait(sshort, sshort);
+  check_trait(sshort, uint);
+  check_trait(sshort, sint);
+  check_trait(sshort, ulong);
+  check_trait(sshort, slong);
+
+}
Index: tests/bi_traits/ulong.cc
--- tests/bi_traits/ulong.cc	(revision 0)
+++ tests/bi_traits/ulong.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+  check_trait(ulong, bool);
+  check_trait(ulong, char);
+  check_trait(ulong, float);
+  check_trait(ulong, double);
+  check_trait(ulong, ldouble);
+  check_trait(ulong, uchar);
+  check_trait(ulong, schar);
+  check_trait(ulong, ushort);
+  check_trait(ulong, sshort);
+  check_trait(ulong, uint);
+  check_trait(ulong, sint);
+  check_trait(ulong, ulong);
+  check_trait(ulong, slong);
+
+}
Index: tests/bi_traits/ushort.cc
--- tests/bi_traits/ushort.cc	(revision 0)
+++ tests/bi_traits/ushort.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+  check_trait(ushort, bool);
+  check_trait(ushort, char);
+  check_trait(ushort, float);
+  check_trait(ushort, double);
+  check_trait(ushort, ldouble);
+  check_trait(ushort, uchar);
+  check_trait(ushort, schar);
+  check_trait(ushort, ushort);
+  check_trait(ushort, sshort);
+  check_trait(ushort, uint);
+  check_trait(ushort, sint);
+  check_trait(ushort, ulong);
+  check_trait(ushort, slong);
+
+}
Index: tests/bi_traits/float.cc
--- tests/bi_traits/float.cc	(revision 0)
+++ tests/bi_traits/float.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+//   check_trait(float, bool);
+  check_trait(float, char);
+  check_trait(float, float);
+  check_trait(float, double);
+  check_trait(float, ldouble);
+  check_trait(float, uchar);
+  check_trait(float, schar);
+  check_trait(float, ushort);
+  check_trait(float, sshort);
+  check_trait(float, uint);
+  check_trait(float, sint);
+  check_trait(float, ulong);
+  check_trait(float, slong);
+
+}
Index: tests/bi_traits/ldouble.cc
--- tests/bi_traits/ldouble.cc	(revision 0)
+++ tests/bi_traits/ldouble.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+//   check_trait(ldouble, bool);
+  check_trait(ldouble, char);
+  check_trait(ldouble, float);
+  check_trait(ldouble, double);
+  check_trait(ldouble, ldouble);
+  check_trait(ldouble, uchar);
+  check_trait(ldouble, schar);
+  check_trait(ldouble, ushort);
+  check_trait(ldouble, sshort);
+  check_trait(ldouble, uint);
+  check_trait(ldouble, sint);
+  check_trait(ldouble, ulong);
+  check_trait(ldouble, slong);
+
+}
Index: tests/bi_traits/double.cc
--- tests/bi_traits/double.cc	(revision 0)
+++ tests/bi_traits/double.cc	(revision 0)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <typeinfo>
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+
+#include <xtd/optraits.hh>
+
+
+# define check_op_trait(OpName, OpSymb, T1, T2) \
+mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check()
+
+# define check_trait(T1, T2)			\
+check_op_trait(plus, +, T1, T2);		\
+check_op_trait(minus, -, T1, T2);		\
+check_op_trait(mult, *, T1, T2)
+
+// check_op_trait(mod, %, T1, T2);
+
+
+
+int main()
+{
+  typedef long double ldouble;
+  typedef unsigned char uchar;
+  typedef signed char schar;
+  typedef unsigned short ushort;
+  typedef signed short sshort;
+  typedef unsigned int uint;
+  typedef signed int sint;
+  typedef unsigned long ulong;
+  typedef signed long slong;
+
+//   check_trait(double, bool);
+  check_trait(double, char);
+  check_trait(double, float);
+  check_trait(double, double);
+  check_trait(double, ldouble);
+  check_trait(double, uchar);
+  check_trait(double, schar);
+  check_trait(double, ushort);
+  check_trait(double, sshort);
+  check_trait(double, uint);
+  check_trait(double, sint);
+  check_trait(double, ulong);
+  check_trait(double, slong);
+
+}
Index: tests/Makefile.am
--- tests/Makefile.am	(revision 456)
+++ tests/Makefile.am	(working copy)
@@ -8,20 +8,24 @@
 # when oln.m4 is available in the distribution.
 
 check_PROGRAMS =				\
-  id						\
+  abs						\
   bind						\
   cast						\
   cfun						\
   cos						\
+  id						\
   lit						\
-  math
+  math						\
+  optraits
 
-id_SOURCES = id.cc
+abs_SOURCES = abs.cc
 bind_SOURCES = bind.cc
 cast_SOURCES = cast.cc
 cfun_SOURCES = cfun.cc
 cos_SOURCES = cos.cc
+id_SOURCES = id.cc
 lit_SOURCES = lit.cc
 math_SOURCES = math.cc
+optraits_SOURCES = optraits.cc
 
 TESTS = $(check_PROGRAMS)
Index: tests/abs.cc
--- tests/abs.cc	(revision 0)
+++ tests/abs.cc	(revision 0)
@@ -0,0 +1,13 @@
+#include <iostream>
+#include <xtd/math/abs.hh>
+
+int main()
+{
+  long l = -3;
+  long ll = xtd::abs(l);
+  std::cout << ll << std::endl;
+
+  long i = -3;
+  long ii = xtd::abs(i);
+  std::cout << ii << std::endl;
+}
Index: tests/optraits.cc
--- tests/optraits.cc	(revision 0)
+++ tests/optraits.cc	(revision 0)
@@ -0,0 +1,33 @@
+#include <iostream>
+#include <xtd/optraits.hh>
+#include <xtd/math.hh>
+
+
+template <typename T>
+static void foo()
+{
+  xtd_op_plus_trait(int, char) tmp;
+}
+
+
+template <typename E1, typename E2>
+static
+void test_plus(const xtd::abstract::fun_expr_<E1>& expr1,
+	       const xtd::abstract::fun_expr_<E2>& expr2)
+{
+  const xtd_op_plus_trait(E1, E2)& tmp = expr1 + expr2;
+  std::cout << tmp(1.) << std::endl;
+}
+
+
+int main()
+{
+  using xtd::cos;
+  using xtd::sin;
+  using xtd::_1;
+
+  typeof(1+2u) tmp;
+//   2 * cos(_1);
+
+  test_plus(2 * cos(_1), sin(_1));
+}
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog
from  Nicolas Widynski  <nicolas.widynski(a)lrde.epita.fr>
	Add sample for real time segmentation.
	* oln/appli/snakes/snakes.cc: New. Real time segmentation using snakes
	                              and watersnakes.
 snakes.cc |  227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 227 insertions(+)
Index: oln/appli/snakes/snakes.cc
--- oln/appli/snakes/snakes.cc	(revision 0)
+++ oln/appli/snakes/snakes.cc	(revision 0)
@@ -0,0 +1,227 @@
+#include <oln/basics2d.hh>
+#include <ntg/all.hh>
+#include <oln/morpho/watersnakes.hh>
+#include <oln/level/fill.hh>
+#include <oln/appli/snakes/snakes.hh>
+
+#define my_abs(u) ((u) > 0 ? (u) : (-(u)))
+
+using ntg::int_u8;
+
+template <typename T>
+void aff_points(const oln::image2d<T>& input,
+		const std::vector<oln::point2d>& v,
+		oln::image2d<T>& out)
+{
+  oln_iter_type(oln::image2d<T>) p(input);
+  oln::image2d<bool> mask(input.size());
+
+  for_all(p)
+    mask[p] = false;
+
+  std::vector<oln::point2d>::const_iterator it = v.begin();
+  for (; it != v.end(); it++)
+    mask[*it] = true;
+
+  for_all(p)
+    {
+      if (mask[p] == true)
+	out[p] = 255;
+      else
+	out[p] = input[p];
+    }
+}
+
+template <typename T>
+void aff_droites(const oln::image2d<T>& input,
+		 const std::vector<oln::point2d>& v,
+		 oln::image2d<T>& out)
+{
+  oln_iter_type(oln::image2d<T>) p(input);
+  oln::image2d<bool> mask(input.size());
+
+  for_all(p)
+    mask[p] = false;
+
+  std::vector<oln::point2d>::const_iterator it = v.begin();
+  for (; it + 1!= v.end(); it++)
+    {
+      std::vector<oln::point2d> vec = oln::snakes::impl::draw_line_(*it, *(it+1));
+      std::vector<oln::point2d>::const_iterator it2 = vec.begin();
+
+      for (; it2 != vec.end(); it2++)
+	mask[*it2] = true;
+    }
+
+  for_all(p)
+    {
+      if (mask[p] == true)
+	out[p] = 255;
+      else
+	out[p] = input[p];
+    }
+}
+
+
+
+bool nearly_equal(int x1, int x2, int y1, int y2)
+{
+  return (my_abs(x1 - x2) < 5 and my_abs(y1 - y2) < 5);
+}
+
+template <typename T>
+std::vector<oln::point2d> tri_vec(const oln::image2d<T>& ima,
+				  const std::vector<oln::point2d>& v)
+{
+  std::vector<oln::point2d> res;
+  std::vector<oln::point2d>::const_iterator it;
+  std::vector<oln::point2d>::iterator it2;
+
+  int ex_1_x = -100;
+  int ex_1_y = -100;
+  int ex_2_x = 0;
+  int ex_2_y = 0;
+  int save_x = -1;
+  int save_y = -1;
+
+
+  for (int i = 0; i < 2; i++)
+    {
+      double min = 100000000;
+
+      for (it = v.begin(); it != v.end(); it++)
+	{
+	  if (i and nearly_equal((*it).row(), ex_1_x, (*it).col(), ex_1_y))
+	    continue;
+
+	  double tmp1 = oln::snakes::impl::euclidian_distance((*it).row(), 0, 0, 0);
+	  double tmp2 = oln::snakes::impl::euclidian_distance((*it).row(), ima.nrows(), 0, 0);
+	  double tmp3 = oln::snakes::impl::euclidian_distance(0, 0, (*it).col(), 0);
+	  double tmp4 = oln::snakes::impl::euclidian_distance(0, 0, (*it).col(), ima.ncols());
+
+	  double tmp_min;
+
+	  if (tmp1 <= tmp2 and tmp1 <= tmp3 and tmp1 <= tmp4)
+	    tmp_min = tmp1;
+	  if (tmp2 <= tmp1 and tmp2 <= tmp3 and tmp2 <= tmp4)
+	    tmp_min = tmp2;
+	  if (tmp3 <= tmp1 and tmp3 <= tmp2 and tmp3 <= tmp4)
+	    tmp_min = tmp3;
+	  if (tmp4 <= tmp1 and tmp4 <= tmp2 and tmp4 <= tmp3)
+	    tmp_min = tmp4;
+
+	  if (tmp_min < min)
+	    {
+	      min = tmp_min;
+	      save_x = (*it).row();
+	      save_y = (*it).col();
+	    }
+	}
+      if (not i)
+	{
+	  ex_1_x = save_x;
+	  ex_1_y = save_y;
+	}
+      else
+	{
+	  ex_2_x = save_x;
+	  ex_2_y = save_y;
+	}
+    }
+
+  res.push_back(oln::point2d(ex_1_x, ex_1_y));
+
+  std::vector<oln::point2d> tmp;
+  for (it = v.begin(); it != v.end(); it++)
+    if (((*it).row() != ex_1_x or (*it).col() != ex_1_y) and
+	((*it).row() != ex_2_x or (*it).col() != ex_2_y))
+      tmp.push_back(*it);
+
+
+  bool stop = false;
+
+  int tmp_x = ex_1_x;
+  int tmp_y = ex_1_y;
+
+  while (stop == false)
+    {
+      if (tmp.size() > 1)
+	{
+	  double min = 10000000;
+	  oln::point2d p;
+	  std::vector<oln::point2d>::iterator p_ref;
+	  for (it2 = tmp.begin(); it2 != tmp.end(); it2++)
+	    {
+ 	      double tmp_d = oln::snakes::impl::euclidian_distance((*it2).row(), tmp_x, (*it2).col(), tmp_y);
+	      if (tmp_d < min)
+		{
+		  min = tmp_d;
+		  p = *it2;
+		  p_ref = it2;
+		}
+	    }
+	  res.push_back(p);
+	  tmp.erase(p_ref);
+	  tmp_x = p.row();
+	  tmp_y = p.col();
+	}
+      else
+	{
+	  res.push_back(oln::point2d(tmp.front().row(), tmp.front().col()));
+	  stop = true;
+	}
+    }
+
+  res.push_back(oln::point2d(ex_2_x, ex_2_y));
+  return res;
+}
+
+
+int main(int argc, char **argv)
+{
+  using namespace oln;
+
+  if (argc < 10)
+    {
+      std::cout << "Usage : ./cmd force_type(0: grad, 1: variance) fen nb_gen lamda dmax snake_type(0:ferme, 1:ouvert) max_pts image_bool images(1+) " << std::endl;
+      exit(1);
+    }
+
+  std::vector<oln::point2d> v;
+  unsigned max_pts = (unsigned)atoi(argv[7]);
+
+  oln::image2d<ntg::bin> mask = load(argv[8]);
+  oln::image2d<int_u8> input1 = load(argv[9]);
+
+  v = morpho::watersnakes(input1, mask, win_c8p(), 5);
+
+  v = tri_vec(input1, v);
+
+  if (max_pts)
+    v = oln::snakes::impl::redispatch(v, max_pts);
+
+  for (int i = 9; i < argc; i++)
+    {
+      std::cout << i - 8 << " / " << argc - 9 << std::endl;
+
+      oln::image2d<int_u8> input;
+      input = load(argv[i]);
+      oln::image2d<int_u8> out(input.size());
+      unsigned nb_gen = 0;
+
+      if (i == 9)
+	nb_gen = (unsigned)atoi(argv[3]);
+      else
+	nb_gen = 1;
+
+      v = oln::snakes::snakes(input, v, (force_type)(atoi(argv[1])), (unsigned)atoi(argv[2]), nb_gen, max_pts, atof(argv[4]), (unsigned)atoi(argv[5]), (snake_type)atoi(argv[6]));
+
+      aff_droites(input, v, out);
+      //      aff_points(input, v, out);
+
+      char t[30];
+      sprintf(t, "snakes_%d.pgm", i - 8);
+
+      save(out, t);
+    }
+}
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog
from  Nicolas Widynski  <nicolas.widynski(a)lrde.epita.fr>
	Update snake force.
	* oln/appli/snakes/snakes.hh: 2 external forces to be chosen : gradient
	                              and variance. Energy of non agglutination.
 snakes.hh |  247 ++++++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 155 insertions(+), 92 deletions(-)
Index: oln/appli/snakes/snakes.hh
--- oln/appli/snakes/snakes.hh	(revision 454)
+++ oln/appli/snakes/snakes.hh	(working copy)
@@ -36,6 +36,8 @@
 # include <vector>
 
 #define sqr(u) ((u)*(u))
+typedef enum SNAKE_TYPE { FERME = 0, OUVERT = 1 } snake_type;
+typedef enum FORCE_TYPE { GRADIENT = 0, VARIANCE = 1 } force_type;
 const float PI = 3.14159265;
 
 
@@ -48,12 +50,12 @@
       inline
       float euclidian_distance(int x1, int x2, int y1, int y2) // sqr
       {
-	return sqr(x1 - x2) + sqr(y1 - y2);
+	return (sqr(x1 - x2) + sqr(y1 - y2));
       }
 
 
       template <typename T>
-      void verify_integrity_(const image2d<T>& grad,
+      void verify_integrity_(const image2d<T>& force,
 			     int &x1,
 			     int &x2,
 			     int &y1,
@@ -63,19 +65,19 @@
 	  x1 = 0;
 	if (x2 < 0)
 	  x2 = 0;
-	if (x1 > grad.nrows())
-	  x1 = grad.nrows() - 1;
-	if (x2 > grad.nrows())
-	  x2 = grad.nrows() - 1;
+	if (x1 > force.nrows())
+	  x1 = force.nrows() - 1;
+	if (x2 > force.nrows())
+	  x2 = force.nrows() - 1;
 
 	if (y1 < 0)
 	  y1 = 0;
 	if (y2 < 0)
 	  y2 = 0;
-	if (y1 > grad.ncols())
-	  y1 = grad.ncols() - 1;
-	if (y2 > grad.ncols())
-	  y2 = grad.ncols() - 1;
+	if (y1 > force.ncols())
+	  y1 = force.ncols() - 1;
+	if (y2 > force.ncols())
+	  y2 = force.ncols() - 1;
       }
 
 
@@ -154,9 +156,8 @@
 
 
 
-
       template <typename T>
-      std::vector<point2d> compute_normal_points_(const image2d<T>& grad,
+      std::vector<point2d> compute_normal_points_(const image2d<T>& force,
 						  const point2d& p1,
 						  const point2d& p2,
 						  const point2d& p3,
@@ -208,12 +209,13 @@
 	    y2 = p2.col();
 	  }
 
-	verify_integrity_(grad, x1, x2, y1, y2);
+	verify_integrity_(force, x1, x2, y1, y2);
 
 	return draw_line_(point2d(x1, y1), point2d(x2, y2));
       }
 
 
+      // we can compute the second derivative.
       float angle_force(const point2d& p1, const point2d& p2, const point2d& p3)
       { // al kashi
 	float b = euclidian_distance(p1.row(), p2.row(), p1.col(), p2.col());
@@ -221,49 +223,99 @@
 	float a = euclidian_distance(p1.row(), p3.row(), p1.col(), p3.col());
 	float angle =  acos((b + c - a) / (2 * sqrt(b) * sqrt(c))); // rad
 	angle = (angle * 180) / PI; //deg
-	return angle;
+	return sqr(180 - angle) / sqr(180);
+      }
+
+      template <typename T>
+      double variance(const image2d<T>& input,
+		      const point2d& p,
+		      unsigned int fen)
+      {
+	double moy = 0;
+	double res = 0;
+
+	for (int i = p.row() - fen / 2; i < p.row() + fen / 2; i++)
+	  for (int j = p.col() - fen / 2; j < p.col() + fen / 2; j++)
+	    {
+	      point2d p(i, j);
+	      if (input.hold(p))
+		moy += input[p];
       }
 
+	moy /= sqr(fen);
 
+	for (int i = p.row() - fen / 2; i < p.row() + fen / 2; i++)
+	  for (int j = p.col() - fen / 2; j < p.col() + fen / 2; j++)
+	    {
+	      point2d p(i, j);
+	      if (input.hold(p))
+		res += sqr(input[p] - moy);
+	    }
+
+	return res / sqr(fen);
+      }
 
       template <typename T>
-      std::vector<point2d> gen_snakes_(const image2d<T>& grad,
+      std::vector<point2d> gen_snakes_(const image2d<T>& force,
 				       const std::vector<point2d>& v,
+				       force_type f,
 				       unsigned int fen,
 				       float lambda,
 				       unsigned int dmax,
-				       unsigned int type)
+				       snake_type type)
       {
 	std::vector<point2d>::const_iterator it = v.begin();
 	std::vector<point2d> res;
 
-	if (type)
-	  res.push_back(v[0]);
-
-	for (; (it + 2) != v.end(); it++)
+	for (; it != v.end(); it++)
 	  {
 	    point2d p1 = *it;
-	    point2d p2 = *(it + 1);
-	    point2d p3 = *(it + 2);
-	    std::vector<point2d> v_normal = compute_normal_points_(grad, p1, p2, p3, dmax);
+	    point2d p2 = *it;
+	    point2d p3 = *it;
+
+	    if (type)
+	      {
+		if (it != v.begin())
+		  p1 = *(it - 1);
+		if (it + 1 != v.end())
+		  p3 = *(it + 1);
+	      }
+	    else
+	      {
+		if (it == v.begin())
+		  continue;
+		if (it + 1 == v.end())
+		  continue;
+		p1 = *(it - 1);
+		p3 = *(it + 1);
+	      }
+
+	    std::vector<point2d> v_normal = compute_normal_points_(force, p1, p2, p3, dmax);
 	    std::vector<point2d>::const_iterator it2 = v_normal.begin();
 
-	    float max = -1;
-	    point2d n_pt(0,0);
+	    float max = -1000000000;
+	    point2d n_pt(-1,-1);
 
 	    for (; it2 != v_normal.end(); it2++)
 	      {
-		float force = grad[*it2];
-		if (max < force)
+		float v_force = 0;
+
+		if (f == GRADIENT)
+		  v_force = (float)(force[*it2]) / 255 - angle_force(p1, *it2, p3) * lambda;
+		else
+		  v_force = variance(force, *it2, fen) / 128 - angle_force(p1, *it2, p3) * lambda;
+
+		if (max < v_force)
 		  {
-		    max = force;
+		    max = v_force;
 		    n_pt = *it2;
 		  }
 	      }
+	    if (n_pt.row() != -1)
 	    res.push_back(n_pt);
 	  }
 
-	if (type == 0)
+	if (type == FERME)
 	  {
 	    res.push_back(res[0]);
 	    res.push_back(res[1]);
@@ -271,78 +323,49 @@
 	else
 	  res.push_back(*(v.end() - 1));
 
-	if (lambda != 0)
-	  {
-	    bool conv = false;
+	return res;
+      }
 
-	    while (conv == false)
-	      {
-		conv = true;
-		float max = 0;
-		std::vector<point2d>::iterator it3 = res.begin();
-		std::vector<point2d>::iterator p_s;
-		point2d n_pt(0,0);
 
-		for (; (it3 + 2) != res.end(); it3++)
+      template <typename T>
+      void init_view(const image2d<T>& input,
+		     const std::vector<point2d>& v)
 		  {
-		    point2d p1 = *it3;
-		    point2d p2 = *(it3 + 1);
-		    point2d p3 = *(it3 + 2);
+	oln_iter_type(image2d<T>) p(input);
+	image2d<ntg::int_u8> out(input.size());
+	image2d<bool> mask(input.size());
 
-		    std::vector<point2d> v_normal = compute_normal_points_(grad, p1, p2, p3, dmax);
-		    std::vector<point2d>::const_iterator it2 = v_normal.begin();
-
-		    float angle_ref = angle_force(p1, p2, p3);
-		    float force_ref = grad[p2] - (180 - angle_ref) * lambda;
-
-		    for (; it2 != v_normal.end(); it2++)
-		      {
-			float angle = angle_force(p1, *it2, p3);
-			float force = grad[*it2] - (180 - angle) * lambda;
+	for_all(p)
+	  mask[p] = false;
 
-			if (p2.col() != (*it2).col() and p2.row() != (*it2).row() and force - force_ref > max)
-			  {
-			    max = force - force_ref;
-			    p_s = it3 + 1;
-			    n_pt = *it2;
-			  }
-		      }
-		  }
+	std::vector<point2d>::const_iterator it = v.begin();
+	for (; it != v.end(); it++)
+	  mask[*it] = true;
 
-		if (max > 0)
-		  {
-		    conv = false;
-		    if (type == 0)
+	for_all(p)
 		      {
-			if (p_s == (res.begin() + 1)) // 2nd
-			  {
-			    (*(res.end() - 1)).col() = n_pt.col();
-			    (*(res.end() - 1)).row() = n_pt.row();
-			  }
+	    if (mask[p] == true)
+	      out[p] = 255;
 			else
-			  if (p_s == (res.end() - 2)) // last
-			    {
-			      (*(res.begin())).col() = n_pt.col();
-			      (*(res.begin())).row() = n_pt.row();
-			    }
-		      }
-		    (*p_s).col() = n_pt.col();
-		    (*p_s).row() = n_pt.row();
-		  }
-	      }
+	      out[p] = input[p];
 	  }
 
-	return res;
+	save(out, "init.pgm");
       }
 
+
       std::vector<point2d> regen_snaxels(std::vector<point2d>& v,
-					 int type)
+					 snake_type type,
+					 unsigned max_pts)
       {
 	std::vector<point2d> res;
 	std::vector<point2d> tmp;
 	std::vector<point2d>::iterator it = v.begin();
 	std::vector<point2d>::iterator it2;
 
+	if (2 * v.size() > max_pts)
+	  return v;
+
 	for (it = v.begin(); (it + 1) != v.end(); it++)
 	  {
 	    std::vector<point2d> tmp2 = draw_line_(*it, *(it+1));
@@ -357,7 +380,7 @@
 	  if ((cpt % (tmp.size() / nb_pts)) == 0)
 	    res.push_back(*it2);
 
-	if (type == 0)
+	if (type == FERME)
 	  {
 	    res.push_back(res[0]);
 	    res.push_back(res[1]);
@@ -369,6 +392,32 @@
       }
 
 
+      std::vector<point2d> redispatch(const std::vector<point2d>& v,
+				      int nb_snaxels)
+      {
+	std::vector<point2d> res;
+	std::vector<point2d> tmp;
+	std::vector<point2d>::const_iterator it = v.begin();
+	int cpt = 0;
+
+	for (; it + 1 != v.end(); it++)
+	  {
+	    std::vector<point2d> vec = draw_line_(*it, *(it+1));
+	    std::vector<point2d>::const_iterator it2 = vec.begin();
+
+	    for (; it2 != vec.end(); it2++)
+	      tmp.push_back(*it2);
+	  }
+
+	for (it = tmp.begin(); it != tmp.end(); it++, cpt++)
+	  if ((cpt % (int)(roundf(((float)(tmp.size()) / nb_snaxels)))) == 0)
+	    res.push_back(*it);
+
+	res.push_back(*(v.end() - 1));
+	return res;
+      }
+
+
       template <typename T>
       void clean_ima(image2d<T>& ima)
       {
@@ -390,34 +439,46 @@
       std::vector<point2d>
       snakes_(const image2d<T>& input,
 	      const std::vector<point2d>& v_init,
+	      force_type f,
 	      unsigned int fen,
 	      unsigned int nb_gen,
+	      unsigned int max_pts,
 	      float lambda,
 	      unsigned int dmax,
-	      unsigned int type)
+	      snake_type type)
       {
-	image2d<T> grad = morpho::gradient_morpho(input, win_c4p());
-	clean_ima(grad);
+	image2d<T> force(input.size());
+
+	if (f == GRADIENT)
+	  force = morpho::gradient_morpho(input, win_c4p());
+	else
+	  {
+	    oln_iter_type(image2d<T>) p(input);
+	    for_all(p)
+	      force[p] = input[p];
+	  }
+
+	clean_ima(force);
 
 	std::vector<point2d> res;
 	std::vector<point2d>::const_iterator it = v_init.begin();
 	for (it = v_init.begin(); it != v_init.end(); it++)
 	  res.push_back(*it);
 
-	if (type == 0)
+	if (type == FERME)
 	  {
 	    res.push_back(res[0]);
 	    res.push_back(res[1]);
 	  }
 
 	int i = 0;
-
 	while (i < nb_gen)
 	  {
-	    res = gen_snakes_(grad, res, fen, lambda, dmax, type);
+	    res = gen_snakes_(force, res, f, fen, lambda, dmax, type);
+	    res = redispatch(res, max_pts);
 	    i++;
 	    if (i < nb_gen)
-	      res = regen_snaxels(res, type);
+	      res = regen_snaxels(res, type, max_pts);
 	  }
 
 	return res;
@@ -430,13 +491,15 @@
     std::vector<point2d>
     snakes(const image2d<T>& input,
 	   const std::vector<point2d>& v_init,
+	   force_type f,
 	   unsigned int fen,
 	   unsigned int nb_gen,
+	   unsigned int max_pts,
 	   float lambda,
 	   unsigned int dmax,
-	   unsigned int type) // 0 : ferme, 1 : ouvert
+	   snake_type type = OUVERT)
     {
-      return impl::snakes_(input, v_init, fen, nb_gen, lambda, dmax, type);
+      return impl::snakes_(input, v_init, f, fen, nb_gen, max_pts, lambda, dmax, type);
     }
 
   } // end of namespace oln::appli
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog
from  Nicolas Widynski  <nicolas.widynski(a)lrde.epita.fr>
	Update Watersnakes.
	* oln/morpho/watersnakes.hh: Little modifications.
 watersnakes.hh |   59 ++++++++++++++++++++++++++-------------------------------
 1 file changed, 27 insertions(+), 32 deletions(-)
Index: oln/morpho/watersnakes.hh
--- oln/morpho/watersnakes.hh	(revision 453)
+++ oln/morpho/watersnakes.hh	(working copy)
@@ -46,7 +46,7 @@
 
 
 const float INFTY = 1000000000000.f;
-# define WSHED 255
+# define WSHED -2
 # define MASK_VALUE -1
 typedef enum version_t { TARJAN = 0, NORMAL = 1 } version;
 
@@ -76,6 +76,7 @@
 		      LS[p] = LS[p] > (float)(input[p] - input[n]) ? LS[p] : (float)(input[p] - input[n]);
 	      }
 	  }
+
 	return LS;
       }
 
@@ -189,7 +190,6 @@
 
       template <typename T>
       bool is_a_boundary_point(const image2d<int>& label,
-			       const window2d& ng,
 			       const T& p,
 			       unsigned& label_b)
       {
@@ -207,20 +207,18 @@
       template <typename T>
       bool
       snake_iteration(image2d<T>& label,
-		      const window2d& ng,
 		      const image2d<float *>& dist,
-		      unsigned nb_compo,
 		      int b)
       {
 	float dist_min = INFTY;
 	point2d p_replace;
-	unsigned label_replace;
+	unsigned label_replace = 0;
 
 	oln_iter_type(image2d<T>) p(label);
 	for_all(p)
 	  {
 	    unsigned label_b;
-	    if (is_a_boundary_point(label, ng, p, label_b))
+	    if (is_a_boundary_point(label, p, label_b))
 	      {
 		float tmp = - dist[p][label[p] - 1] + compute_perimeter(label, p, label[p], b) +
 		  dist[p][label_b - 1] - compute_perimeter(label, p, label_b, b);
@@ -261,18 +259,15 @@
 	    if (marqueur[p] == false)
 	      {
 		dist[p][label[p] - 1] = input[p];
-		for (int i = 0; i < nb_compo; i++)
-		  if (i != label[p] - 1)
+		for (unsigned i = 0; i < nb_compo; i++)
+		  if ((int)i != label[p] - 1)
 		    dist[p][i] = INFTY;
 	      }
 	    else
-	      {
-		for (int i = 0; i < nb_compo; i++)
+	      for (unsigned i = 0; i < nb_compo; i++)
 		  dist[p][i] = INFTY;
 	      }
 
-	  }
-
 	int i = 0;
 
 	bool stop = false;
@@ -290,7 +285,7 @@
 			float grad = local_grad(input, LS, p, n);
 			float tmp = chamfer_distance(p, n) * grad;
 
-			for (int k = 0; k < nb_compo; k++)
+			for (unsigned k = 0; k < nb_compo; k++)
 			  if (dist[p][k] + tmp < dist[n][k])
 			    {
 			      dist[n][k] = dist[p][k] + tmp;
@@ -311,7 +306,7 @@
 			float grad = local_grad(input, LS, p2, n);
 			float tmp = chamfer_distance(p2, n) * grad;
 
-			for (int k = 0; k < nb_compo; k++)
+			for (unsigned k = 0; k < nb_compo; k++)
 			  if (dist[p2][k] + tmp < dist[n][k])
 			    {
 			      dist[n][k] = dist[p2][k] + tmp;
@@ -404,7 +399,6 @@
 	 image2d<int> output(input.size());
 
 	 level::fill(output, MASK_VALUE);
-	 unsigned tmp;
 
 	 oln_iter_type(image2d<T>) p(input);
 	 for_all (p)
@@ -415,7 +409,7 @@
        }
 
       template<typename T, typename T2>
-      image2d<T>
+      std::vector<point2d>
       watershed_line(const image2d<T>& input,
 		     const image2d<T>& orig,
 		     const image2d<T2>& marqueur,
@@ -423,17 +417,14 @@
 		     int b,
 		     version v)
       {
-	image2d<T> res(input.size());
+	image2d<int> final(input.size());
 	image2d<int> label;
 	image2d<T2> mark(input.size());
 	oln_iter_type(image2d<T>) p(input);
 	image2d<bool> is_wshed_line(input.size());
-	float dist;
-	float tmp;
+	std::vector<point2d> res;
 	unsigned nb_compo = 0;
 
-	int i = 0;
-
 	for_all(p)
 	  mark[p] = marqueur[p];
 
@@ -450,8 +441,8 @@
 	    op_type op(marqueur, input, ng);
 	    recon = op.output;
 	  }
-
 	image2d<float> LS = lower_slope(recon, ng);
+
 	label = init_watershed_(recon, mark, ng, nb_compo);
 
 	image2d<float*> topo = topographic_distance(recon, LS, mark, label, ng, nb_compo);
@@ -460,8 +451,7 @@
 	  {
 	    unsigned mini_label = 1;
 	    float mini_topo = topo[p][0];
-	    int h = 1;
-	    for (; h < nb_compo; h++)
+	    for (unsigned h = 1; h < nb_compo; h++)
 	      if (mini_topo > topo[p][h])
 		{
 		  mini_topo = topo[p][h];
@@ -469,28 +459,33 @@
 		}
 	    label[p] = mini_label;
 	  }
-	while (snake_iteration(label, ng, topo, nb_compo, b))
+
+	while (snake_iteration(label, topo, b))
 	  ;
 
-	level::fill(res, 0);
+	level::fill(final, 0);
 	for_all(p)
 	  {
 	    oln_neighb_type(window2d) q(win_c4p(), p);
 	    for_all (q)
 	      if (input.hold(q))
-		if (label[p] != label[q] and res[q] != WSHED)
-		  res[p] = WSHED;
-	    if (res[p] == 0)
-	      res[p] = orig[p];
+		if (label[p] != label[q] and final[q] != WSHED)
+		  final[p] = WSHED;
+	    if (final[p] == 0)
+	      final[p] = orig[p];
 	  }
 
+	for_all(p)
+	  if (final[p] == WSHED)
+	    res.push_back(p);
+
 	return res;
       }
 
 
 
       template<typename T, typename T2>
-      image2d<T>
+      std::vector<point2d>
       watersnakes_(const image2d<T>& input,
 		   const image2d<T2>& marqueur,
 		   const window2d& ng,
@@ -508,7 +503,7 @@
 
 
     template<typename T, typename T2>
-    image2d<T>
+    std::vector<point2d>
     watersnakes(const image2d<T>& input,
 		const image2d<T2>& marqueur,
 		const window2d& ng,
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        
https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog
from  Thierry Geraud  <theo(a)lrde.epita.fr>
	Fix some warnings with icpc; add is_built_in_.
	* tests (svn:ignore): Add '.deps'.
	* tests/case.cc: Fix warning with icpc.
	* tests/gcase.cc: New file.
	* mlc/abstract: New directory.
	* mlc/type.hh: Rename as...
	* mlc/abstract/type.hh: ...this.
	* mlc/bexpr.hh (abstract::bexpr): Move to...
	* mlc/abstract/bexpr.hh: ...this new file.
	* mlc/flags.hh: Update include.
	* mlc/value.hh: Update include.
	* mlc/ret.hh: Add separators in macros to fix error with icpc.
	* mlc/assert.hh: Add dtor to fix warning with icpc.
	* mlc/case.hh (internal::a_get_case): New flag.
	(get_case_): New class; it differs from case_ in remaining silent
	when no case matches.
	* mlc/cmp.hh (is_builtin_): New class with its specializations.
 mlc/abstract/bexpr.hh |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++
 mlc/abstract/type.hh  |   10 +++----
 mlc/assert.hh         |    1 
 mlc/bexpr.hh          |   32 ++++++------------------
 mlc/case.hh           |   27 ++++++++++++++++++++
 mlc/cmp.hh            |   44 +++++++++++++++++++++++++++++++++
 mlc/flags.hh          |    2 -
 mlc/value.hh          |    2 -
 tests/case.cc         |    4 +--
 tests/gcase.cc        |   38 +++++++++++++++++++++++++++++
 10 files changed, 192 insertions(+), 33 deletions(-)
Index: tests/case.cc
--- tests/case.cc	(revision 452)
+++ tests/case.cc	(working copy)
@@ -52,9 +52,9 @@
 
 
 template <class T>
-void print()
+static void print()
 {
-  int tmp;
+  T tmp;
 }
 
 
Index: tests/gcase.cc
--- tests/gcase.cc	(revision 0)
+++ tests/gcase.cc	(revision 0)
@@ -0,0 +1,38 @@
+#include <mlc/is_a.hh>
+#include <mlc/case.hh>
+
+
+struct test;
+
+
+mlc_case_equipment_for_namespace(client);
+
+
+namespace client
+{
+
+  template <class T>
+  struct case_ <test, T, 1> : public mlc::where_< mlc_is_a(T, short) >
+  {
+  };
+
+  template <class T>
+  struct case_ <test, T, 2> : public mlc::where_< mlc_is_a(T, int) >
+  {
+  };
+
+} // end of namespace client
+
+
+template <class T>
+void print()
+{
+  int tmp;
+}
+
+
+
+int main()
+{
+  print< client::get_case_<test, char>::ret >();
+}
Index: mlc/ret.hh
Index: mlc/flags.hh
--- mlc/flags.hh	(revision 452)
+++ mlc/flags.hh	(working copy)
@@ -28,7 +28,7 @@
 #ifndef METALIC_FLAGS_HH
 # define METALIC_FLAGS_HH
 
-# include <mlc/type.hh>
+# include <mlc/abstract/type.hh>
 
 
 namespace mlc {
Index: mlc/assert.hh
--- mlc/assert.hh	(revision 452)
+++ mlc/assert.hh	(working copy)
@@ -156,6 +156,7 @@
   {
   public:
     static void check() {} 
+    virtual ~assert_() {}
   protected:
     assert_() {}
   };
Index: mlc/case.hh
--- mlc/case.hh	(revision 452)
+++ mlc/case.hh	(working copy)
@@ -64,6 +64,7 @@
 
   namespace internal
   {
+    struct a_get_case;
     struct a_simple_case;
     struct a_switch_case;
 
@@ -203,6 +204,22 @@
     struct handle_default_case_;															\
 																			\
 																			\
+    template <typename context, typename data>														\
+    struct handle_default_case_ < mlc::internal::a_get_case, context, data >										\
+																			\
+      : private mlc::assert_< mlc::implies_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >,						\
+					     mlc_is_not_a(mlc_comma_1(NAMESPACE::default_case_<context, data>),						\
+							  mlc::where_) >,										\
+			      mlc::ERROR::A_default_case_STATEMENT_SHOULD_NOT_DERIVE_FROM_mlc_where_ >							\
+    {																			\
+      typedef NAMESPACE::default_case_<context, data> case_t;												\
+      typedef typename protected_in_<case_t>::the protected_case_t;											\
+																			\
+      typedef typename mlc::if_< mlc::is_found_<protected_case_t>,											\
+	                         protected_case_t,													\
+	                         case_t >::ret ret;													\
+    };																			\
+																			\
 																			\
     template <typename context, typename data>														\
     struct handle_default_case_ < mlc::internal::a_simple_case, context, data >										\
@@ -261,7 +278,8 @@
 						      mlc::where_) >,											\
 			      mlc::ERROR::A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_ >,								\
 																			\
-	private mlc::assert_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >,								\
+	private mlc::assert_< mlc::implies_< mlc::neq_< use, mlc::internal::a_get_case >,								\
+					     mlc::is_defined_< NAMESPACE::default_case_<context, data> > >,						\
 			      mlc::WARNING::NO_default_case_STATEMENT_HAS_BEEN_DEFINED >								\
 																			\
     {																			\
@@ -380,6 +398,13 @@
 																			\
 																			\
   template <typename context, typename data>														\
+  struct get_case_																	\
+  {																			\
+    typedef typename NAMESPACE::internal::select_case_<mlc::internal::a_get_case, context, data>::ret ret;						\
+  };																			\
+																			\
+																			\
+  template <typename context, typename data>														\
   struct case_ <context, data, mlc::internal::unknown_case_id>												\
 																			\
     : private mlc::assert_< mlc::neq_< mlc_comma_2(typename NAMESPACE::internal::select_case_<mlc::internal::a_simple_case,				\
Index: mlc/cmp.hh
--- mlc/cmp.hh	(revision 452)
+++ mlc/cmp.hh	(working copy)
@@ -50,12 +50,16 @@
 # define mlc_is_found(T)     mlc::is_found_<T>
 # define mlc_is_not_found(T) mlc::is_not_found_<T>
 
+// FIXME: or (?) mlc_is_not_defined below
 # define mlc_is_undefined(T) mlc::is_undefined_<T>
 # define mlc_is_defined(T)   mlc::is_defined_<T>
 
 # define mlc_is_ok(T)     mlc::is_ok_<T>
 # define mlc_is_not_ok(T) mlc::is_not_ok_<T>
 
+# define mlc_is_builtin(T)     mlc::is_builtin_<T>
+# define mlc_is_not_builtin(T) mlc::is_not_builtin_<T>
+
 /// \}
 
 
@@ -162,6 +166,46 @@
   /// \}
 
 
+
+  /// Check whether a type is a builtin type.
+  /// \{
+
+  template <typename T>
+  struct is_builtin_ : public bexpr_<false>
+  {
+  };
+
+  template <typename T> struct is_builtin_ < const T > : public is_builtin_< T >::bexpr {};
+  template <typename T> struct is_builtin_ < T*      > : public is_builtin_< T >::bexpr {};
+  template <typename T> struct is_builtin_ < T[]     > : public is_builtin_< T >::bexpr {};
+  template <typename T,
+            unsigned n> struct is_builtin_ < T[n]    > : public is_builtin_< T >::bexpr {};
+
+  template <> struct is_builtin_ < void > : public bexpr_<true> {}; // FIXME: ?
+  template <> struct is_builtin_ < bool > : public bexpr_<true> {};
+  template <> struct is_builtin_ < char > : public bexpr_<true> {};
+
+  template <> struct is_builtin_ <          float  > : public bexpr_<true> {};
+  template <> struct is_builtin_ <          double > : public bexpr_<true> {};
+  template <> struct is_builtin_ <     long double > : public bexpr_<true> {};
+
+  template <> struct is_builtin_ < unsigned char   > : public bexpr_<true> {};
+  template <> struct is_builtin_ <   signed char   > : public bexpr_<true> {};
+  template <> struct is_builtin_ < unsigned short  > : public bexpr_<true> {};
+  template <> struct is_builtin_ <   signed short  > : public bexpr_<true> {};
+  template <> struct is_builtin_ < unsigned int    > : public bexpr_<true> {};
+  template <> struct is_builtin_ <   signed int    > : public bexpr_<true> {};
+  template <> struct is_builtin_ < unsigned long   > : public bexpr_<true> {};
+  template <> struct is_builtin_ <   signed long   > : public bexpr_<true> {};
+
+  template <typename T>
+  struct is_not_builtin_ : public not_< is_builtin_<T> >::bexpr
+  {
+  };
+
+  /// \}
+
+
 } // end of namespace mlc
 
 
Index: mlc/bexpr.hh
--- mlc/bexpr.hh	(revision 452)
+++ mlc/bexpr.hh	(working copy)
@@ -28,7 +28,7 @@
 #ifndef METALIC_BEXPR_HH
 # define METALIC_BEXPR_HH
 
-# include <mlc/type.hh>
+# include <mlc/abstract/bexpr.hh>
 # include <mlc/flags.hh>
 
 
@@ -46,28 +46,6 @@
 
 
 
-  namespace abstract {
-
-    /*! \class mlc::abstract::bexpr
-    **
-    ** Abstract base class for mlc Boolean expression types.
-    **
-    ** When you define a new class for a Boolean expression type, you
-    ** should not directly derive from this class from fom its
-    ** subclass: bexpr_<b>.
-    **
-    ** \see bexpr_<b>
-    */
-
-    struct bexpr : public type
-    {
-      // typedef void eval;
-    };
-
-  } // end of namespace mlc::abstract
-
-
-
   /*! \class mlc::bexpr_<b>
   **
   ** Base class for any class of mlc Boolean expression types.
@@ -109,6 +87,10 @@
 
     // FIXME: doc
     typedef bexpr_<true> bexpr;
+
+  protected:
+    /// Ctor is protected to prevent instantiations.
+    bexpr_() {}
   };
   
 
@@ -128,6 +110,10 @@
     typedef mlc::false_ eval;
 
     typedef bexpr_<false> bexpr;
+
+  protected:
+    /// Ctor is protected to prevent instantiations.
+    bexpr_() {}
   };
 
 
Index: mlc/abstract/type.hh
--- mlc/abstract/type.hh	(revision 0)
+++ mlc/abstract/type.hh	(working copy)
@@ -25,8 +25,8 @@
 // reasons why the executable file might be covered by the GNU General
 // Public License.
 
-#ifndef METALIC_TYPE_HH
-# define METALIC_TYPE_HH
+#ifndef METALIC_ABSTRACT_TYPE_HH
+# define METALIC_ABSTRACT_TYPE_HH
 
 
 namespace mlc {
@@ -48,8 +48,8 @@
 
     struct type
     {
-    private:
-      /// Ctor is private to prevent instantiations.
+    protected:
+      /// Ctor is protected to prevent instantiations.
       type() {}
     };
 
@@ -58,4 +58,4 @@
 } // end of namespace mlc
 
 
-#endif // ! METALIC_TYPE_HH
+#endif // ! METALIC_ABSTRACT_TYPE_HH
Index: mlc/abstract/bexpr.hh
--- mlc/abstract/bexpr.hh	(revision 0)
+++ mlc/abstract/bexpr.hh	(revision 0)
@@ -0,0 +1,65 @@
+// Copyright (C) 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef METALIC_ABSTRACT_BEXPR_HH
+# define METALIC_ABSTRACT_BEXPR_HH
+
+# include <mlc/abstract/type.hh>
+# include <mlc/flags.hh>
+
+
+
+namespace mlc
+{
+
+  namespace abstract
+  {
+
+    /*! \class mlc::abstract::bexpr
+    **
+    ** Abstract base class for mlc Boolean expression types.
+    **
+    ** When you define a new class for a Boolean expression type, you
+    ** should not directly derive from this class from fom its
+    ** subclass: bexpr_<b>.
+    **
+    ** \see bexpr_<b>
+    */
+
+    struct bexpr : public mlc::abstract::type
+    {
+      // typedef void eval;
+    };
+
+
+  } // end of namespace mlc::abstract
+
+} // end of namespace mlc
+
+
+
+#endif // ! METALIC_ABSTRACT_BEXPR_HH
Index: mlc/value.hh
--- mlc/value.hh	(revision 452)
+++ mlc/value.hh	(working copy)
@@ -28,7 +28,7 @@
 #ifndef METALIC_VALUE_HH
 # define METALIC_VALUE_HH
 
-# include <mlc/type.hh>
+# include <mlc/abstract/type.hh>
 // # include <mlc/assert.hh>
 // # include <mlc/is_a.hh>
 
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog
from  Nicolas Widynski  <nicolas.widynski(a)lrde.epita.fr>
	Update for opened and closed snakes.
	* oln/appli/snakes/snakes.hh: Update for opened and closed snakes.
 snakes.hh |   58 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 46 insertions(+), 12 deletions(-)
Index: oln/appli/snakes/snakes.hh
--- oln/appli/snakes/snakes.hh	(revision 451)
+++ oln/appli/snakes/snakes.hh	(working copy)
@@ -51,6 +51,7 @@
 	return sqr(x1 - x2) + sqr(y1 - y2);
       }
 
+
       template <typename T>
       void verify_integrity_(const image2d<T>& grad,
 			     int &x1,
@@ -206,6 +207,7 @@
 	    x2 = p2.row() + dmax;
 	    y2 = p2.col();
 	  }
+
 	verify_integrity_(grad, x1, x2, y1, y2);
 
 	return draw_line_(point2d(x1, y1), point2d(x2, y2));
@@ -229,11 +231,15 @@
 				       const std::vector<point2d>& v,
 				       unsigned int fen,
 				       float lambda,
-				       unsigned int dmax)
+				       unsigned int dmax,
+				       unsigned int type)
       {
 	std::vector<point2d>::const_iterator it = v.begin();
 	std::vector<point2d> res;
 
+	if (type)
+	  res.push_back(v[0]);
+
 	for (; (it + 2) != v.end(); it++)
 	  {
 	    point2d p1 = *it;
@@ -257,9 +263,13 @@
 	    res.push_back(n_pt);
 	  }
 
+	if (type == 0)
+	  {
 	res.push_back(res[0]);
 	res.push_back(res[1]);
-
+	  }
+	else
+	  res.push_back(*(v.end() - 1));
 
 	if (lambda != 0)
 	  {
@@ -272,6 +282,7 @@
 		std::vector<point2d>::iterator it3 = res.begin();
 		std::vector<point2d>::iterator p_s;
 		point2d n_pt(0,0);
+
 		for (; (it3 + 2) != res.end(); it3++)
 		  {
 		    point2d p1 = *it3;
@@ -282,7 +293,6 @@
 		    std::vector<point2d>::const_iterator it2 = v_normal.begin();
 
 		    float angle_ref = angle_force(p1, p2, p3);
-
 		    float force_ref = grad[p2] - (180 - angle_ref) * lambda;
 
 		    for (; it2 != v_normal.end(); it2++)
@@ -302,6 +312,8 @@
 		if (max > 0)
 		  {
 		    conv = false;
+		    if (type == 0)
+		      {
 		    if (p_s == (res.begin() + 1)) // 2nd
 		      {
 			(*(res.end() - 1)).col() = n_pt.col();
@@ -313,6 +325,7 @@
 			  (*(res.begin())).col() = n_pt.col();
 			  (*(res.begin())).row() = n_pt.row();
 			}
+		      }
 		    (*p_s).col() = n_pt.col();
 		    (*p_s).row() = n_pt.row();
 		  }
@@ -322,8 +335,8 @@
 	return res;
       }
 
-
-      std::vector<point2d> regen_snaxels(std::vector<point2d>& v)
+      std::vector<point2d> regen_snaxels(std::vector<point2d>& v,
+					 int type)
       {
 	std::vector<point2d> res;
 	std::vector<point2d> tmp;
@@ -338,15 +351,24 @@
 	  }
 
 	int nb_pts = v.size() * 2;
-	int cpt = 1;
+	int cpt = 0;
 
 	for (it2 = tmp.begin(); it2 != tmp.end(); it2++, cpt++)
 	  if ((cpt % (tmp.size() / nb_pts)) == 0)
 	    res.push_back(*it2);
 
+	if (type == 0)
+	  {
+	    res.push_back(res[0]);
+	    res.push_back(res[1]);
+	  }
+	else
+	  res.push_back(*(v.end() - 1));
+
 	return res;
       }
 
+
       template <typename T>
       void clean_ima(image2d<T>& ima)
       {
@@ -367,25 +389,35 @@
       template <typename T>
       std::vector<point2d>
       snakes_(const image2d<T>& input,
+	      const std::vector<point2d>& v_init,
 	      unsigned int fen,
 	      unsigned int nb_gen,
 	      float lambda,
-	      unsigned int dmax)
+	      unsigned int dmax,
+	      unsigned int type)
       {
 	image2d<T> grad = morpho::gradient_morpho(input, win_c4p());
 	clean_ima(grad);
 
 	std::vector<point2d> res;
+	std::vector<point2d>::const_iterator it = v_init.begin();
+	for (it = v_init.begin(); it != v_init.end(); it++)
+	  res.push_back(*it);
 
-	// build init points + 2 (close snake)
+	if (type == 0)
+	  {
+	    res.push_back(res[0]);
+	    res.push_back(res[1]);
+	  }
 
 	int i = 0;
+
 	while (i < nb_gen)
 	  {
-	    res = gen_snakes_(grad, res, fen, lambda, dmax);
+	    res = gen_snakes_(grad, res, fen, lambda, dmax, type);
 	    i++;
 	    if (i < nb_gen)
-	      res = regen_snaxels(res);
+	      res = regen_snaxels(res, type);
 	  }
 
 	return res;
@@ -397,12 +429,14 @@
     template <typename T>
     std::vector<point2d>
     snakes(const image2d<T>& input,
+	   const std::vector<point2d>& v_init,
 	   unsigned int fen,
 	   unsigned int nb_gen,
 	   float lambda,
-	   unsigned int dmax)
+	   unsigned int dmax,
+	   unsigned int type) // 0 : ferme, 1 : ouvert
     {
-      return impl::snakes_(input, fen, nb_gen, lambda, dmax);
+      return impl::snakes_(input, v_init, fen, nb_gen, lambda, dmax, type);
     }
 
   } // end of namespace oln::appli
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog
from  Nicolas Widynski  <nicolas.widynski(a)lrde.epita.fr>
	Add a closed snake algorithm.
	* oln/appli/snakes: New. Directory.
	* oln/appli/snakes/snakes.hh: New. Snake algorithm.
				      2 forces : gradient and snake perimeter.
 snakes.hh |  413 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 413 insertions(+)
Index: oln/appli/snakes/snakes.hh
--- oln/appli/snakes/snakes.hh	(revision 0)
+++ oln/appli/snakes/snakes.hh	(revision 0)
@@ -0,0 +1,413 @@
+// Copyright (C) 2001-2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLENA_SNAKES_HH
+# define OLENA_SNAKES_HH
+
+# include <mlc/is_a.hh>
+# include <oln/basics2d.hh>
+# include <ntg/all.hh>
+# include <oln/morpho/gradient_morpho.hh>
+# include <ntg/int.hh>
+# include <vector>
+
+#define sqr(u) ((u)*(u))
+const float PI = 3.14159265;
+
+
+namespace oln {
+
+  namespace snakes {
+
+    namespace impl {
+
+      inline
+      float euclidian_distance(int x1, int x2, int y1, int y2) // sqr
+      {
+	return sqr(x1 - x2) + sqr(y1 - y2);
+      }
+
+      template <typename T>
+      void verify_integrity_(const image2d<T>& grad,
+			     int &x1,
+			     int &x2,
+			     int &y1,
+			     int &y2)
+      {
+	if (x1 < 0)
+	  x1 = 0;
+	if (x2 < 0)
+	  x2 = 0;
+	if (x1 > grad.nrows())
+	  x1 = grad.nrows() - 1;
+	if (x2 > grad.nrows())
+	  x2 = grad.nrows() - 1;
+
+	if (y1 < 0)
+	  y1 = 0;
+	if (y2 < 0)
+	  y2 = 0;
+	if (y1 > grad.ncols())
+	  y1 = grad.ncols() - 1;
+	if (y2 > grad.ncols())
+	  y2 = grad.ncols() - 1;
+      }
+
+
+      std::vector<point2d> draw_line_(const point2d& p,
+				      const point2d& q)
+      {
+	std::vector<point2d> res;
+
+	point2d p_cur = p;
+	if (q.col() == p.col()) // cas vertical
+	  {
+	    int sens = q.row() > p.row() ? 1 : -1;
+	    while (p_cur != q)
+	      {
+		double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col());
+		double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col());
+		double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col());
+
+		res.push_back(p_cur);
+		p_cur.row() = p_cur.row() + sens;
+	      }
+	  }
+	else
+	  {
+	    if (q.row() == p.row()) // cas horizontal
+	      {
+		int sens = q.col() > p.col() ? 1 : -1;
+		while (p_cur != q)
+		  {
+		    double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col());
+		    double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col());
+		    double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col());
+
+		    res.push_back(p_cur);
+		    p_cur.col() = p_cur.col() + sens;
+		  }
+	      }
+	    else // cas diagonal
+	      {
+		long decalage = 0;
+
+		long nom = q.row() - p.row();
+		long denom = q.col() - p.col();
+		int signe = (nom * denom) > 0 ? 1 : -1;
+		nom = nom * signe;
+		denom = denom * signe;
+
+		int vsens = q.row() > p.row() ? 1 : -1;
+		int hsens = q.col() > p.col() ? 1 : -1;
+
+		int deboule = 0;
+
+		while (p_cur != q)
+		  {
+		    double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col());
+		    double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col());
+		    double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col());
+
+		    res.push_back(p_cur);
+
+		    if (abs(decalage) >= abs(denom))
+		      {
+			p_cur.row() = p_cur.row() + vsens;
+			decalage -= vsens * denom;
+		      }
+		    else
+		      {
+			p_cur.col() = p_cur.col() + hsens;
+			decalage += nom * hsens;
+		      }
+		  }
+	      }
+	  }
+	return res;
+      }
+
+
+
+
+      template <typename T>
+      std::vector<point2d> compute_normal_points_(const image2d<T>& grad,
+						  const point2d& p1,
+						  const point2d& p2,
+						  const point2d& p3,
+						  unsigned int dmax)
+      {
+	float x_c = p2.row();
+	float y_c = p2.col();
+	float a_p1_p3 = (p1.col() - p3.col()) != 0 ? (float)(((float)(p1.row() - p3.row())) / (p1.col() - p3.col())) : 0;
+	float a = -a_p1_p3;
+	float b = p2.col() - a * p2.row(); // use of - slope of p1 et p3
+
+	int x1 = 0;
+	int y1 = 0;
+	int x2 = 0;
+	int y2 = 0;
+
+	if (a != 0)
+	  {
+	    float A = 1 + sqr(a);
+	    float B = -2 * (x_c + a * y_c - a * b);
+	    float C = sqr(x_c) + sqr((b - y_c)) - sqr(dmax);
+
+	    float delta = sqr(B) - (4 * A * C);
+
+	    if (delta > 0)
+	      {
+		x1 = (int)(roundf((-B + sqrt(delta)) / (2 * A)));
+		x2 = (int)(roundf((-B - sqrt(delta)) / (2 * A)));
+
+		if (x1 == x2)
+		  {
+		    float tmp1 = roundf((-B + sqrt(delta)) / (2 * A));
+		    float tmp2 = roundf((-B - sqrt(delta)) / (2 * A));
+		    if (tmp1 > tmp2)
+		      x1++;
+		    else
+		      x2++;
+		  }
+
+		y1 = (int)(a * x1 + b);
+		y2 = (int)(a * x2 + b);
+	      }
+	  }
+	else
+	  {
+	    x1 = p2.row() - dmax;
+	    y1 = p2.col();
+	    x2 = p2.row() + dmax;
+	    y2 = p2.col();
+	  }
+	verify_integrity_(grad, x1, x2, y1, y2);
+
+	return draw_line_(point2d(x1, y1), point2d(x2, y2));
+      }
+
+
+      float angle_force(const point2d& p1, const point2d& p2, const point2d& p3)
+      { // al kashi
+	float b = euclidian_distance(p1.row(), p2.row(), p1.col(), p2.col());
+	float c = euclidian_distance(p3.row(), p2.row(), p3.col(), p2.col());
+	float a = euclidian_distance(p1.row(), p3.row(), p1.col(), p3.col());
+	float angle =  acos((b + c - a) / (2 * sqrt(b) * sqrt(c))); // rad
+	angle = (angle * 180) / PI; //deg
+	return angle;
+      }
+
+
+
+      template <typename T>
+      std::vector<point2d> gen_snakes_(const image2d<T>& grad,
+				       const std::vector<point2d>& v,
+				       unsigned int fen,
+				       float lambda,
+				       unsigned int dmax)
+      {
+	std::vector<point2d>::const_iterator it = v.begin();
+	std::vector<point2d> res;
+
+	for (; (it + 2) != v.end(); it++)
+	  {
+	    point2d p1 = *it;
+	    point2d p2 = *(it + 1);
+	    point2d p3 = *(it + 2);
+	    std::vector<point2d> v_normal = compute_normal_points_(grad, p1, p2, p3, dmax);
+	    std::vector<point2d>::const_iterator it2 = v_normal.begin();
+
+	    float max = -1;
+	    point2d n_pt(0,0);
+
+	    for (; it2 != v_normal.end(); it2++)
+	      {
+		float force = grad[*it2];
+		if (max < force)
+		  {
+		    max = force;
+		    n_pt = *it2;
+		  }
+	      }
+	    res.push_back(n_pt);
+	  }
+
+	res.push_back(res[0]);
+	res.push_back(res[1]);
+
+
+	if (lambda != 0)
+	  {
+	    bool conv = false;
+
+	    while (conv == false)
+	      {
+		conv = true;
+		float max = 0;
+		std::vector<point2d>::iterator it3 = res.begin();
+		std::vector<point2d>::iterator p_s;
+		point2d n_pt(0,0);
+		for (; (it3 + 2) != res.end(); it3++)
+		  {
+		    point2d p1 = *it3;
+		    point2d p2 = *(it3 + 1);
+		    point2d p3 = *(it3 + 2);
+
+		    std::vector<point2d> v_normal = compute_normal_points_(grad, p1, p2, p3, dmax);
+		    std::vector<point2d>::const_iterator it2 = v_normal.begin();
+
+		    float angle_ref = angle_force(p1, p2, p3);
+
+		    float force_ref = grad[p2] - (180 - angle_ref) * lambda;
+
+		    for (; it2 != v_normal.end(); it2++)
+		      {
+			float angle = angle_force(p1, *it2, p3);
+			float force = grad[*it2] - (180 - angle) * lambda;
+
+			if (p2.col() != (*it2).col() and p2.row() != (*it2).row() and force - force_ref > max)
+			  {
+			    max = force - force_ref;
+			    p_s = it3 + 1;
+			    n_pt = *it2;
+			  }
+		      }
+		  }
+
+		if (max > 0)
+		  {
+		    conv = false;
+		    if (p_s == (res.begin() + 1)) // 2nd
+		      {
+			(*(res.end() - 1)).col() = n_pt.col();
+			(*(res.end() - 1)).row() = n_pt.row();
+		      }
+		    else
+		      if (p_s == (res.end() - 2)) // last
+			{
+			  (*(res.begin())).col() = n_pt.col();
+			  (*(res.begin())).row() = n_pt.row();
+			}
+		    (*p_s).col() = n_pt.col();
+		    (*p_s).row() = n_pt.row();
+		  }
+	      }
+	  }
+
+	return res;
+      }
+
+
+      std::vector<point2d> regen_snaxels(std::vector<point2d>& v)
+      {
+	std::vector<point2d> res;
+	std::vector<point2d> tmp;
+	std::vector<point2d>::iterator it = v.begin();
+	std::vector<point2d>::iterator it2;
+
+	for (it = v.begin(); (it + 1) != v.end(); it++)
+	  {
+	    std::vector<point2d> tmp2 = draw_line_(*it, *(it+1));
+	    for (it2 = tmp2.begin(); it2 != tmp2.end(); it2++)
+	      tmp.push_back(*it2);
+	  }
+
+	int nb_pts = v.size() * 2;
+	int cpt = 1;
+
+	for (it2 = tmp.begin(); it2 != tmp.end(); it2++, cpt++)
+	  if ((cpt % (tmp.size() / nb_pts)) == 0)
+	    res.push_back(*it2);
+
+	return res;
+      }
+
+      template <typename T>
+      void clean_ima(image2d<T>& ima)
+      {
+	for (int j = 0; j < ima.size().ncols(); j++)
+	  {
+	    ima(-1, j) = ima(0, j);
+	    ima(ima.size().nrows(), j) = ima(ima.size().nrows() - 1, j);
+	  }
+
+	for (int j = 0; j < ima.size().nrows(); j++)
+	  {
+	    ima(j, -1) = ima(j, 0);
+	    ima(j, ima.size().ncols()) = ima(j, ima.size().ncols() - 1);
+	  }
+      }
+
+
+      template <typename T>
+      std::vector<point2d>
+      snakes_(const image2d<T>& input,
+	      unsigned int fen,
+	      unsigned int nb_gen,
+	      float lambda,
+	      unsigned int dmax)
+      {
+	image2d<T> grad = morpho::gradient_morpho(input, win_c4p());
+	clean_ima(grad);
+
+	std::vector<point2d> res;
+
+	// build init points + 2 (close snake)
+
+	int i = 0;
+	while (i < nb_gen)
+	  {
+	    res = gen_snakes_(grad, res, fen, lambda, dmax);
+	    i++;
+	    if (i < nb_gen)
+	      res = regen_snaxels(res);
+	  }
+
+	return res;
+      }
+
+
+    } // end of namespace oln::impl::snakes
+
+    template <typename T>
+    std::vector<point2d>
+    snakes(const image2d<T>& input,
+	   unsigned int fen,
+	   unsigned int nb_gen,
+	   float lambda,
+	   unsigned int dmax)
+    {
+      return impl::snakes_(input, fen, nb_gen, lambda, dmax);
+    }
+
+  } // end of namespace oln::appli
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_SNAKES_HH
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        
https://svn.lrde.epita.fr/svn/oln/trunk/extended
Index: ChangeLog
from  Thierry Geraud  <theo(a)lrde.epita.fr>
	Add some math functions and clean up file deps.
	* xtd/math.hh: Add includes.
	* xtd/math/log.hh: New.
	* xtd/math/floor.hh: New.
	* xtd/math/log10.hh: New.
	* xtd/math/tan.hh: New.
	* xtd/math/atan.hh: New.
	* xtd/math/cos.hh: New.
	* xtd/math/trigo.hh: Remove; dispatch contents into several files.
	* xtd/math/acos.hh: New.
	* xtd/math/sin.hh: New.
	* xtd/math/sqrt.hh: New.
	* xtd/math/asin.hh: New.
	* xtd/math/tanh.hh: New.
	* xtd/math/exp.hh: New.
	* xtd/math/cosh.hh: New.
	* xtd/math/id.hh: Update includes.
	* xtd/math/sinh.hh: New.
	* xtd/math/atan2.hh: New.
	* xtd/math/abs.hh: New.
	* xtd/math/pow.hh: New.
	* xtd/math/includes.hh: New.
	* xtd/math/constraints.hh: New.
	* xtd/math/ceil.hh: New.
	* xtd/ops_expr.hh: Remove; dispatch contents into...
	* xtd/internal/opmacros.hh: ...this new file and the following three
	files.
	* xtd/math/arith.hh: Update.
	* xtd/math/cmp.hh: New.
	* xtd/math/logic.hh: New.
	* xtd/traits.hh: Rename as...
	* xtd/optraits.hh: ...this; update.
	* xtd/builtin/traits.hh: Update.
	* tests/cos.cc: Update.
	* tests/Makefile.am: Update.
	* tests/math.cc: New.
	* tests/cast.cc: Update.
 tests/Makefile.am        |    4 +
 tests/cast.cc            |    2 
 tests/cos.cc             |   16 +++---
 tests/math.cc            |   14 +++++
 xtd/builtin/traits.hh    |    2 
 xtd/internal/opmacros.hh |  124 +++++++++++++++++++++++++++--------------------
 xtd/math.hh              |   60 +++++++++++++++++++---
 xtd/math/abs.hh          |  115 +++++++++++++++++++++++++++++++++++++++++++
 xtd/math/acos.hh         |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/arith.hh        |  104 ++-------------------------------------
 xtd/math/asin.hh         |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/atan.hh         |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/atan2.hh        |   94 +++++++++++++++++++++++++++++++++++
 xtd/math/ceil.hh         |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/cmp.hh          |   49 ++++++++++++++++++
 xtd/math/constraints.hh  |   63 +++++++++++++++++++++++
 xtd/math/cos.hh          |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/cosh.hh         |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/exp.hh          |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/floor.hh        |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/id.hh           |    3 -
 xtd/math/includes.hh     |   40 +++++++++++++++
 xtd/math/log.hh          |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/log10.hh        |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/logic.hh        |   48 ++++++++++++++++++
 xtd/math/pow.hh          |  109 +++++++++++++++++++++++++++++++++++++++++
 xtd/math/sin.hh          |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/sinh.hh         |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/sqrt.hh         |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/tan.hh          |   93 +++++++++++++++++++++++++++++++++++
 xtd/math/tanh.hh         |   93 +++++++++++++++++++++++++++++++++++
 xtd/optraits.hh          |    6 +-
 32 files changed, 2076 insertions(+), 172 deletions(-)
Index: xtd/math.hh
--- xtd/math.hh	(revision 449)
+++ xtd/math.hh	(working copy)
@@ -28,17 +28,61 @@
 #ifndef EXTENDED_MATH_HH
 # define EXTENDED_MATH_HH
 
-# include <cmath>
 
-# include <xtd/abstract/plain_fun.hh>
-# include <xtd/mfun.hh>
-# include <xtd/arg.hh>
-# include <xtd/ops_expr.hh>
 
-# include <xtd/math/id.hh>
-# include <xtd/math/trigo.hh>
+// FIXME: preconditions are not handled in code included below...
+
+
+
+/// \{
+/// Definition of xtd cmath-like functions.
+
+# include <xtd/math/abs.hh>
+# include <xtd/math/acos.hh>
+# include <xtd/math/asin.hh>
+# include <xtd/math/atan.hh>
+# include <xtd/math/atan2.hh>
+# include <xtd/math/ceil.hh>
+# include <xtd/math/cos.hh>
+# include <xtd/math/cosh.hh>
+# include <xtd/math/exp.hh>
+// 'fabs' is obsolete
+# include <xtd/math/floor.hh>
+// fmod
+// frexp
+// ldexp
+# include <xtd/math/log.hh>
+# include <xtd/math/log10.hh>
+// modf
+# include <xtd/math/pow.hh>
+# include <xtd/math/sin.hh>
+# include <xtd/math/sinh.hh>
+# include <xtd/math/sqrt.hh>
+# include <xtd/math/tan.hh>
+# include <xtd/math/tanh.hh>
+
+/// \}
+
+
+
+/// \{
+/// Definition of xtd operators and related functions.
+
 # include <xtd/math/arith.hh>
-// # include <xtd/math/logic.hh>
+# include <xtd/math/logic.hh>
+# include <xtd/math/cmp.hh>
+
+/// \}
+
+
+
+/// \{
+/// Misc functions.
+
+# include <xtd/math/id.hh>
+
+/// \}
+
 
 
 
Index: xtd/math/log.hh
--- xtd/math/log.hh	(revision 0)
+++ xtd/math/log.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_LOG_HH
+# define EXTENDED_MATH_LOG_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd (base-2) logarithm functions.
+
+
+  template <typename T> struct log_;
+
+  template <> struct constraints_< log_, float > {};
+  template <> struct constraints_< log_, double > {};
+  template <> struct constraints_< log_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< log_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct log_
+
+    : public abstract::plain_nary_fun_< 1, log_<T> >,
+
+      private constraints_< log_, T >
+  {
+    xtd_res(log_<T>) impl_op(const T& arg) const
+    {
+      return std::log(arg);
+    }
+  };
+
+
+  typedef m1fun_<log_> log_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::log_f : float -> float.
+  const log_<float>       log_f;
+
+  /// \brief Plain function object xtd::log_d : double -> double.
+  const log_<double>      log_d;
+
+  /// \brief Plain function object xtd::log_ld : long double -> long double.
+  const log_<long double> log_ld;
+
+  /// \brief Meta function object xtd::log.
+  const log_type          log;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_LOG_HH
Index: xtd/math/floor.hh
--- xtd/math/floor.hh	(revision 0)
+++ xtd/math/floor.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_FLOOR_HH
+# define EXTENDED_MATH_FLOOR_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd floor functions.
+
+
+  template <typename T> struct floor_;
+
+  template <> struct constraints_< floor_, float > {};
+  template <> struct constraints_< floor_, double > {};
+  template <> struct constraints_< floor_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< floor_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct floor_
+
+    : public abstract::plain_nary_fun_< 1, floor_<T> >,
+
+      private constraints_< floor_, T >
+  {
+    xtd_res(floor_<T>) impl_op(const T& arg) const
+    {
+      return std::floor(arg);
+    }
+  };
+
+
+  typedef m1fun_<floor_> floor_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::floor_f : float -> float.
+  const floor_<float>       floor_f;
+
+  /// \brief Plain function object xtd::floor_d : double -> double.
+  const floor_<double>      floor_d;
+
+  /// \brief Plain function object xtd::floor_ld : long double -> long double.
+  const floor_<long double> floor_ld;
+
+  /// \brief Meta function object xtd::floor.
+  const floor_type          floor;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_FLOOR_HH
Index: xtd/math/log10.hh
--- xtd/math/log10.hh	(revision 0)
+++ xtd/math/log10.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_LOG10_HH
+# define EXTENDED_MATH_LOG10_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd base-10 logarithm functions.
+
+
+  template <typename T> struct log10_;
+
+  template <> struct constraints_< log10_, float > {};
+  template <> struct constraints_< log10_, double > {};
+  template <> struct constraints_< log10_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< log10_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct log10_
+
+    : public abstract::plain_nary_fun_< 1, log10_<T> >,
+
+      private constraints_< log10_, T >
+  {
+    xtd_res(log10_<T>) impl_op(const T& arg) const
+    {
+      return std::log10(arg);
+    }
+  };
+
+
+  typedef m1fun_<log10_> log10_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::log10_f : float -> float.
+  const log10_<float>       log10_f;
+
+  /// \brief Plain function object xtd::log10_d : double -> double.
+  const log10_<double>      log10_d;
+
+  /// \brief Plain function object xtd::log10_ld : long double -> long double.
+  const log10_<long double> log10_ld;
+
+  /// \brief Meta function object xtd::log10.
+  const log10_type          log10;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_LOG10_HH
Index: xtd/math/tan.hh
--- xtd/math/tan.hh	(revision 0)
+++ xtd/math/tan.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_TAN_HH
+# define EXTENDED_MATH_TAN_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd tangent functions.
+
+
+  template <typename T> struct tan_;
+
+  template <> struct constraints_< tan_, float > {};
+  template <> struct constraints_< tan_, double > {};
+  template <> struct constraints_< tan_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< tan_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct tan_
+
+    : public abstract::plain_nary_fun_< 1, tan_<T> >,
+
+      private constraints_< tan_, T >
+  {
+    xtd_res(tan_<T>) impl_op(const T& arg) const
+    {
+      return std::tan(arg);
+    }
+  };
+
+
+  typedef m1fun_<tan_> tan_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::tan_f : float -> float.
+  const tan_<float>       tan_f;
+
+  /// \brief Plain function object xtd::tan_d : double -> double.
+  const tan_<double>      tan_d;
+
+  /// \brief Plain function object xtd::tan_ld : long double -> long double.
+  const tan_<long double> tan_ld;
+
+  /// \brief Meta function object xtd::tan.
+  const tan_type          tan;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_TAN_HH
Index: xtd/math/atan.hh
--- xtd/math/atan.hh	(revision 0)
+++ xtd/math/atan.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_ATAN_HH
+# define EXTENDED_MATH_ATAN_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd arc tangent functions.
+
+
+  template <typename T> struct atan_;
+
+  template <> struct constraints_< atan_, float > {};
+  template <> struct constraints_< atan_, double > {};
+  template <> struct constraints_< atan_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< atan_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct atan_
+
+    : public abstract::plain_nary_fun_< 1, atan_<T> >,
+
+      private constraints_< atan_, T >
+  {
+    xtd_res(atan_<T>) impl_op(const T& arg) const
+    {
+      return std::atan(arg);
+    }
+  };
+
+
+  typedef m1fun_<atan_> atan_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::atan_f : float -> float.
+  const atan_<float>       atan_f;
+
+  /// \brief Plain function object xtd::atan_d : double -> double.
+  const atan_<double>      atan_d;
+
+  /// \brief Plain function object xtd::atan_ld : long double -> long double.
+  const atan_<long double> atan_ld;
+
+  /// \brief Meta function object xtd::atan.
+  const atan_type          atan;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_ATAN_HH
Index: xtd/math/cos.hh
--- xtd/math/cos.hh	(revision 0)
+++ xtd/math/cos.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_COS_HH
+# define EXTENDED_MATH_COS_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd cosine functions.
+
+
+  template <typename T> struct cos_;
+
+  template <> struct constraints_< cos_, float > {};
+  template <> struct constraints_< cos_, double > {};
+  template <> struct constraints_< cos_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< cos_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct cos_
+
+    : public abstract::plain_nary_fun_< 1, cos_<T> >,
+
+      private constraints_< cos_, T >
+  {
+    xtd_res(cos_<T>) impl_op(const T& arg) const
+    {
+      return std::cos(arg);
+    }
+  };
+
+
+  typedef m1fun_<cos_> cos_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::cos_f : float -> float.
+  const cos_<float>       cos_f;
+
+  /// \brief Plain function object xtd::cos_d : double -> double.
+  const cos_<double>      cos_d;
+
+  /// \brief Plain function object xtd::cos_ld : long double -> long double.
+  const cos_<long double> cos_ld;
+
+  /// \brief Meta function object xtd::cos.
+  const cos_type          cos;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_COS_HH
Index: xtd/math/acos.hh
--- xtd/math/acos.hh	(revision 0)
+++ xtd/math/acos.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_ACOS_HH
+# define EXTENDED_MATH_ACOS_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd arc cosine functions.
+
+
+  template <typename T> struct acos_;
+
+  template <> struct constraints_< acos_, float > {};
+  template <> struct constraints_< acos_, double > {};
+  template <> struct constraints_< acos_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< acos_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct acos_
+
+    : public abstract::plain_nary_fun_< 1, acos_<T> >,
+
+      private constraints_< acos_, T >
+  {
+    xtd_res(acos_<T>) impl_op(const T& arg) const
+    {
+      return std::acos(arg);
+    }
+  };
+
+
+  typedef m1fun_<acos_> acos_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::acos_f : float -> float.
+  const acos_<float>       acos_f;
+
+  /// \brief Plain function object xtd::acos_d : double -> double.
+  const acos_<double>      acos_d;
+
+  /// \brief Plain function object xtd::acos_ld : long double -> long double.
+  const acos_<long double> acos_ld;
+
+  /// \brief Meta function object xtd::acos.
+  const acos_type          acos;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_ACOS_HH
Index: xtd/math/sin.hh
--- xtd/math/sin.hh	(revision 0)
+++ xtd/math/sin.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_SIN_HH
+# define EXTENDED_MATH_SIN_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd sine functions.
+
+
+  template <typename T> struct sin_;
+
+  template <> struct constraints_< sin_, float > {};
+  template <> struct constraints_< sin_, double > {};
+  template <> struct constraints_< sin_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< sin_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct sin_
+
+    : public abstract::plain_nary_fun_< 1, sin_<T> >,
+
+      private constraints_< sin_, T >
+  {
+    xtd_res(sin_<T>) impl_op(const T& arg) const
+    {
+      return std::sin(arg);
+    }
+  };
+
+
+  typedef m1fun_<sin_> sin_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::sin_f : float -> float.
+  const sin_<float>       sin_f;
+
+  /// \brief Plain function object xtd::sin_d : double -> double.
+  const sin_<double>      sin_d;
+
+  /// \brief Plain function object xtd::sin_ld : long double -> long double.
+  const sin_<long double> sin_ld;
+
+  /// \brief Meta function object xtd::sin.
+  const sin_type          sin;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_SIN_HH
Index: xtd/math/sqrt.hh
--- xtd/math/sqrt.hh	(revision 0)
+++ xtd/math/sqrt.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_SQRT_HH
+# define EXTENDED_MATH_SQRT_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd square root functions.
+
+
+  template <typename T> struct sqrt_;
+
+  template <> struct constraints_< sqrt_, float > {};
+  template <> struct constraints_< sqrt_, double > {};
+  template <> struct constraints_< sqrt_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< sqrt_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct sqrt_
+
+    : public abstract::plain_nary_fun_< 1, sqrt_<T> >,
+
+      private constraints_< sqrt_, T >
+  {
+    xtd_res(sqrt_<T>) impl_op(const T& arg) const
+    {
+      return std::sqrt(arg);
+    }
+  };
+
+
+  typedef m1fun_<sqrt_> sqrt_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::sqrt_f : float -> float.
+  const sqrt_<float>       sqrt_f;
+
+  /// \brief Plain function object xtd::sqrt_d : double -> double.
+  const sqrt_<double>      sqrt_d;
+
+  /// \brief Plain function object xtd::sqrt_ld : long double -> long double.
+  const sqrt_<long double> sqrt_ld;
+
+  /// \brief Meta function object xtd::sqrt.
+  const sqrt_type          sqrt;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_SQRT_HH
Index: xtd/math/asin.hh
--- xtd/math/asin.hh	(revision 0)
+++ xtd/math/asin.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_ASIN_HH
+# define EXTENDED_MATH_ASIN_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd arc sine functions.
+
+
+  template <typename T> struct asin_;
+
+  template <> struct constraints_< asin_, float > {};
+  template <> struct constraints_< asin_, double > {};
+  template <> struct constraints_< asin_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< asin_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct asin_
+
+    : public abstract::plain_nary_fun_< 1, asin_<T> >,
+
+      private constraints_< asin_, T >
+  {
+    xtd_res(asin_<T>) impl_op(const T& arg) const
+    {
+      return std::asin(arg);
+    }
+  };
+
+
+  typedef m1fun_<asin_> asin_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::asin_f : float -> float.
+  const asin_<float>       asin_f;
+
+  /// \brief Plain function object xtd::asin_d : double -> double.
+  const asin_<double>      asin_d;
+
+  /// \brief Plain function object xtd::asin_ld : long double -> long double.
+  const asin_<long double> asin_ld;
+
+  /// \brief Meta function object xtd::asin.
+  const asin_type          asin;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_ASIN_HH
Index: xtd/math/tanh.hh
--- xtd/math/tanh.hh	(revision 0)
+++ xtd/math/tanh.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_TANH_HH
+# define EXTENDED_MATH_TANH_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd hyperbolic tangent functions.
+
+
+  template <typename T> struct tanh_;
+
+  template <> struct constraints_< tanh_, float > {};
+  template <> struct constraints_< tanh_, double > {};
+  template <> struct constraints_< tanh_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< tanh_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct tanh_
+
+    : public abstract::plain_nary_fun_< 1, tanh_<T> >,
+
+      private constraints_< tanh_, T >
+  {
+    xtd_res(tanh_<T>) impl_op(const T& arg) const
+    {
+      return std::tanh(arg);
+    }
+  };
+
+
+  typedef m1fun_<tanh_> tanh_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::tanh_f : float -> float.
+  const tanh_<float>       tanh_f;
+
+  /// \brief Plain function object xtd::tanh_d : double -> double.
+  const tanh_<double>      tanh_d;
+
+  /// \brief Plain function object xtd::tanh_ld : long double -> long double.
+  const tanh_<long double> tanh_ld;
+
+  /// \brief Meta function object xtd::tanh.
+  const tanh_type          tanh;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_TANH_HH
Index: xtd/math/exp.hh
--- xtd/math/exp.hh	(revision 0)
+++ xtd/math/exp.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_EXP_HH
+# define EXTENDED_MATH_EXP_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd exponential functions.
+
+
+  template <typename T> struct exp_;
+
+  template <> struct constraints_< exp_, float > {};
+  template <> struct constraints_< exp_, double > {};
+  template <> struct constraints_< exp_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< exp_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct exp_
+
+    : public abstract::plain_nary_fun_< 1, exp_<T> >,
+
+      private constraints_< exp_, T >
+  {
+    xtd_res(exp_<T>) impl_op(const T& arg) const
+    {
+      return std::exp(arg);
+    }
+  };
+
+
+  typedef m1fun_<exp_> exp_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::exp_f : float -> float.
+  const exp_<float>       exp_f;
+
+  /// \brief Plain function object xtd::exp_d : double -> double.
+  const exp_<double>      exp_d;
+
+  /// \brief Plain function object xtd::exp_ld : long double -> long double.
+  const exp_<long double> exp_ld;
+
+  /// \brief Meta function object xtd::exp.
+  const exp_type          exp;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_EXP_HH
Index: xtd/math/cosh.hh
--- xtd/math/cosh.hh	(revision 0)
+++ xtd/math/cosh.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_COSH_HH
+# define EXTENDED_MATH_COSH_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd hyperbolic cosine functions.
+
+
+  template <typename T> struct cosh_;
+
+  template <> struct constraints_< cosh_, float > {};
+  template <> struct constraints_< cosh_, double > {};
+  template <> struct constraints_< cosh_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< cosh_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct cosh_
+
+    : public abstract::plain_nary_fun_< 1, cosh_<T> >,
+
+      private constraints_< cosh_, T >
+  {
+    xtd_res(cosh_<T>) impl_op(const T& arg) const
+    {
+      return std::cosh(arg);
+    }
+  };
+
+
+  typedef m1fun_<cosh_> cosh_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::cosh_f : float -> float.
+  const cosh_<float>       cosh_f;
+
+  /// \brief Plain function object xtd::cosh_d : double -> double.
+  const cosh_<double>      cosh_d;
+
+  /// \brief Plain function object xtd::cosh_ld : long double -> long double.
+  const cosh_<long double> cosh_ld;
+
+  /// \brief Meta function object xtd::cosh.
+  const cosh_type          cosh;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_COSH_HH
Index: xtd/math/id.hh
--- xtd/math/id.hh	(revision 449)
+++ xtd/math/id.hh	(working copy)
@@ -28,8 +28,7 @@
 #ifndef EXTENDED_MATH_ID_HH
 # define EXTENDED_MATH_ID_HH
 
-# include <xtd/abstract/plain_nary_fun.hh>
-# include <xtd/mfun.hh>
+# include <xtd/math/includes.hh>
 
 
 namespace xtd
Index: xtd/math/logic.hh
--- xtd/math/logic.hh	(revision 0)
+++ xtd/math/logic.hh	(revision 0)
@@ -0,0 +1,48 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_LOGIC_HH
+# define EXTENDED_MATH_LOGIC_HH
+
+# include <xtd/internal/opmacros.hh>
+
+
+namespace xtd
+{
+
+  xtd_internal_decl_binary_operator( land, and );
+  xtd_internal_decl_binary_operator( lor,  or );
+  xtd_internal_decl_binary_operator( lxor, xor );
+
+  xtd_internal_decl_unary_operator( lnot, not );
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_LOGIC_HH
Index: xtd/math/sinh.hh
--- xtd/math/sinh.hh	(revision 0)
+++ xtd/math/sinh.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_SINH_HH
+# define EXTENDED_MATH_SINH_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd hyperbolic sine functions.
+
+
+  template <typename T> struct sinh_;
+
+  template <> struct constraints_< sinh_, float > {};
+  template <> struct constraints_< sinh_, double > {};
+  template <> struct constraints_< sinh_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< sinh_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct sinh_
+
+    : public abstract::plain_nary_fun_< 1, sinh_<T> >,
+
+      private constraints_< sinh_, T >
+  {
+    xtd_res(sinh_<T>) impl_op(const T& arg) const
+    {
+      return std::sinh(arg);
+    }
+  };
+
+
+  typedef m1fun_<sinh_> sinh_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::sinh_f : float -> float.
+  const sinh_<float>       sinh_f;
+
+  /// \brief Plain function object xtd::sinh_d : double -> double.
+  const sinh_<double>      sinh_d;
+
+  /// \brief Plain function object xtd::sinh_ld : long double -> long double.
+  const sinh_<long double> sinh_ld;
+
+  /// \brief Meta function object xtd::sinh.
+  const sinh_type          sinh;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_SINH_HH
Index: xtd/math/atan2.hh
--- xtd/math/atan2.hh	(revision 0)
+++ xtd/math/atan2.hh	(revision 0)
@@ -0,0 +1,94 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_ATAN2_HH
+# define EXTENDED_MATH_ATAN2_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd arc tangent functions taking two arguments.
+
+
+  template <typename T1, typename T2> struct atan2_;
+
+  template <> struct constraints_2_< atan2_, float, float > {};
+  template <> struct constraints_2_< atan2_, double, double > {};
+  template <> struct constraints_2_< atan2_, long double, long double > {};
+
+  template <typename T>
+  struct fun_traits_< atan2_<T, T> >
+  {
+    typedef T arg1_type;
+    typedef T arg2_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T1, typename T2>
+  struct atan2_
+
+    : public abstract::plain_nary_fun_< 2, atan2_<T1, T2> >,
+
+      private constraints_2_< atan2_, T1, T2 >
+  {
+    xtd_res(mlc_comma_1(atan2_<T1,T2>)) impl_op(const T1& arg1, const T2& arg2) const
+    {
+      return std::atan2(arg1, arg2);
+    }
+  };
+
+
+  typedef m2fun_<atan2_> atan2_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::atan2_f : (float, float) -> float.
+  const atan2_<float, float>             atan2_f;
+
+  /// \brief Plain function object xtd::atan2_d : (double, double) -> double.
+  const atan2_<double, double>           atan2_d;
+
+  /// \brief Plain function object xtd::atan2_ld : (long double, long double) -> long double.
+  const atan2_<long double, long double> atan2_ld;
+
+  /// \brief Meta function object xtd::atan2.
+  const atan2_type                       atan2;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_ATAN2_HH
Index: xtd/math/abs.hh
--- xtd/math/abs.hh	(revision 0)
+++ xtd/math/abs.hh	(revision 0)
@@ -0,0 +1,115 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_ABS_HH
+# define EXTENDED_MATH_ABS_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd absolute value functions.
+
+
+  template <typename T> struct abs_;
+
+  template <> struct constraints_< abs_, int > {};
+  template <> struct constraints_< abs_, long int > {};
+
+  template <> struct constraints_< abs_, float > {};
+  template <> struct constraints_< abs_, double > {};
+  template <> struct constraints_< abs_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< abs_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+  namespace internal {
+
+    int           abs_(int i)           { return std::abs(i); }
+    long int      abs_(long int i)      { return std::abs(i); }
+
+    float         abs_(float i)         { return std::fabs(i); }
+    double        abs_(double i)        { return std::fabs(i); }
+    long double   abs_(long double i)   { return std::fabs(i); }
+
+  } // end of namespace xtd::internal
+
+
+  template <typename T>
+  struct abs_
+
+    : public abstract::plain_nary_fun_< 1, abs_<T> >,
+
+      private constraints_< abs_, T >
+  {
+    xtd_res(abs_<T>) impl_op(const T& arg) const
+    {
+      return internal::abs_(arg);
+    }
+  };
+
+
+  typedef m1fun_<abs_> abs_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::abs_f : int -> int.
+  const abs_<int>           abs_i;
+
+  /// \brief Plain function object xtd::abs_d : long int -> long int.
+  const abs_<long int>      abs_li;
+
+
+  /// \brief Plain function object xtd::abs_f : float -> float.
+  const abs_<float>         abs_f;
+
+  /// \brief Plain function object xtd::abs_d : double -> double.
+  const abs_<double>        abs_d;
+
+  /// \brief Plain function object xtd::abs_ld : long double -> long double.
+  const abs_<long double>   abs_ld;
+
+
+  /// \brief Meta function object xtd::abs.
+  const abs_type            abs;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_ABS_HH
Index: xtd/math/pow.hh
--- xtd/math/pow.hh	(revision 0)
+++ xtd/math/pow.hh	(revision 0)
@@ -0,0 +1,109 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_POW_HH
+# define EXTENDED_MATH_POW_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd arc tangent functions taking two arguments.
+
+
+  template <typename T1, typename T2> struct pow_;
+
+  template <> struct constraints_2_< pow_, float,       float > {};
+  template <> struct constraints_2_< pow_, double,      double > {};
+  template <> struct constraints_2_< pow_, long double, long double > {};
+
+  template <> struct constraints_2_< pow_, float,       int > {};
+  template <> struct constraints_2_< pow_, double,      int > {};
+  template <> struct constraints_2_< pow_, long double, int > {};
+
+  template <typename T1, typename T2>
+  struct fun_traits_< pow_<T1, T2> >
+  {
+    typedef T1 arg1_type;
+    typedef T2 arg2_type;
+    typedef T1 res_type;
+  };
+
+
+  template <typename T1, typename T2>
+  struct pow_
+
+    : public abstract::plain_nary_fun_< 2, pow_<T1, T2> >,
+
+      private constraints_2_< pow_, T1, T2 >
+  {
+    xtd_res(mlc_comma_1(pow_<T1,T2>)) impl_op(const T1& arg1, const T2& arg2) const
+    {
+      return std::pow(arg1, arg2);
+    }
+  };
+
+
+  typedef m2fun_<pow_> pow_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::pow_f : (float, float) -> float.
+  const pow_<float, float>             pow_f;
+
+  /// \brief Plain function object xtd::pow_d : (double, double) -> double.
+  const pow_<double, double>           pow_d;
+
+  /// \brief Plain function object xtd::pow_ld : (long double, long double) -> long double.
+  const pow_<long double, long double> pow_ld;
+
+
+  /// \brief Plain function object xtd::pow_f : (float, int) -> float.
+  const pow_<float, int>               pow_fi;
+
+  /// \brief Plain function object xtd::pow_d : (double, int) -> double.
+  const pow_<double, int>              pow_di;
+
+  /// \brief Plain function object xtd::pow_ld : (long double, int) -> long double.
+  const pow_<long double, int>         pow_ldi;
+
+
+  /// \brief Meta function object xtd::pow.
+  const pow_type                       pow;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_POW_HH
Index: xtd/math/includes.hh
--- xtd/math/includes.hh	(revision 0)
+++ xtd/math/includes.hh	(revision 0)
@@ -0,0 +1,40 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_INCLUDES_HH
+# define EXTENDED_MATH_INCLUDES_HH
+
+
+# include <cmath>
+# include <cassert>
+
+# include <xtd/abstract/plain_nary_fun.hh>
+# include <xtd/mfun.hh>
+# include <xtd/math/constraints.hh>
+
+
+#endif // ! EXTENDED_MATH_INCLUDES_HH
Index: xtd/math/arith.hh
--- xtd/math/arith.hh	(revision 449)
+++ xtd/math/arith.hh	(working copy)
@@ -28,109 +28,19 @@
 #ifndef EXTENDED_MATH_ARITH_HH
 # define EXTENDED_MATH_ARITH_HH
 
-# include <xtd/builtin/traits.hh>
-# include <xtd/abstract/plain_nary_fun.hh>
-# include <xtd/mfun.hh>
-
-
-// FIXME: doc
-
-# define xtd_internal_decl_plain_unary_fun_op(OperatorName,  OperatorSymbol)	\
-										\
-  template <typename T>								\
-  struct plain_##OperatorName##_;						\
-										\
-  template <typename T>								\
-  struct fun_traits_< plain_##OperatorName##_<T> >				\
-  {										\
-    typedef T arg_type;								\
-    typedef xtd_##OperatorName(T) res_type;					\
-  };										\
-										\
-  template <typename T>								\
-  struct plain_##OperatorName##_						\
-										\
-    : public abstract::plain_nary_fun_< 1, plain_##OperatorName##_<T> >		\
-  {										\
-    typedef plain_##OperatorName##_<T> self;					\
-    xtd_res(self) impl_op(const T& arg) const					\
-    {										\
-      return OperatorSymbol arg;						\
-    }										\
-  };										\
-										\
-  typedef m1fun_<plain_##OperatorName##_> OperatorName##_type;			\
-  const OperatorName##_type OperatorName;					\
-										\
-  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
-
-
-
-
-# define xtd_internal_decl_plain_binary_fun_op(OperatorName,  OperatorSymbol)	\
-										\
-  template <typename T1, typename T2>						\
-  struct plain_##OperatorName##_;						\
-										\
-  template <typename T1, typename T2>						\
-  struct fun_traits_< plain_##OperatorName##_<T1, T2> >				\
-  {										\
-    typedef T1 arg1_type;							\
-    typedef T2 arg2_type;							\
-    typedef xtd_##OperatorName(T1, T2) res_type;				\
-  };										\
-  										\
-  template <typename T1, typename T2>						\
-  struct plain_##OperatorName##_						\
-										\
-    : public abstract::plain_nary_fun_< 2, plain_##OperatorName##_<T1, T2> >	\
-  {										\
-    typedef plain_##OperatorName##_<T1, T2> self;				\
-    xtd_res(self) impl_op(const T1& arg1, const T2& arg2) const			\
-    {										\
-      return arg1 OperatorSymbol arg2;						\
-    }										\
-  };										\
-										\
-  typedef m2fun_<plain_##OperatorName##_> OperatorName##_type;			\
-  const OperatorName##_type OperatorName;					\
-										\
-  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
-
-
+# include <xtd/internal/opmacros.hh>
 
 
 namespace xtd
 {
 
-  // logic
-
-  xtd_internal_decl_plain_binary_fun_op( land, and );
-  xtd_internal_decl_plain_binary_fun_op( lor,  or );
-  xtd_internal_decl_plain_binary_fun_op( lxor, xor );
-
-  xtd_internal_decl_plain_unary_fun_op( lnot, not );
-
-
-  // cmp
-
-  xtd_internal_decl_plain_binary_fun_op( eq,      == );
-  xtd_internal_decl_plain_binary_fun_op( neq,     != );
-  xtd_internal_decl_plain_binary_fun_op( less,    <  );
-  xtd_internal_decl_plain_binary_fun_op( leq,     <= );
-  xtd_internal_decl_plain_binary_fun_op( greater, >  );
-  xtd_internal_decl_plain_binary_fun_op( geq,     >= );
-
-
-  // arith
-
-  xtd_internal_decl_plain_binary_fun_op( plus,  + );
-  xtd_internal_decl_plain_binary_fun_op( minus, - );
-  xtd_internal_decl_plain_binary_fun_op( mult,  * );
-  xtd_internal_decl_plain_binary_fun_op( div,   / );
-  xtd_internal_decl_plain_binary_fun_op( mod,   % );
+  xtd_internal_decl_binary_operator( plus,  + );
+  xtd_internal_decl_binary_operator( minus, - );
+  xtd_internal_decl_binary_operator( mult,  * );
+  xtd_internal_decl_binary_operator( div,   / );
+  xtd_internal_decl_binary_operator( mod,   % );
 
-  xtd_internal_decl_plain_unary_fun_op( uminus, - );
+  xtd_internal_decl_unary_operator( uminus, - );
 
 
 } // end of namespace xtd
Index: xtd/math/constraints.hh
--- xtd/math/constraints.hh	(revision 0)
+++ xtd/math/constraints.hh	(revision 0)
@@ -0,0 +1,63 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_CONSTRAINTS_HH
+# define EXTENDED_MATH_CONSTRAINTS_HH
+
+# include <mlc/abort.hh>
+
+
+namespace xtd
+{
+
+  namespace ERROR
+  {
+    struct FIXME;
+
+  } // end of namespace xtd::ERROR
+
+
+  template < template<typename> class pfun,
+	     typename T >
+  struct constraints_ : private mlc::abort_< ERROR::FIXME >
+  {
+  };
+
+
+  template < template<typename, typename> class pfun,
+	     typename T1,
+	     typename T2 >
+  struct constraints_2_ : private mlc::abort_< ERROR::FIXME >
+  {
+  };
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_CONSTRAINTS_HH
Index: xtd/math/ceil.hh
--- xtd/math/ceil.hh	(revision 0)
+++ xtd/math/ceil.hh	(revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_CEIL_HH
+# define EXTENDED_MATH_CEIL_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+  /// \{
+  /// Definition of xtd ceil functions.
+
+
+  template <typename T> struct ceil_;
+
+  template <> struct constraints_< ceil_, float > {};
+  template <> struct constraints_< ceil_, double > {};
+  template <> struct constraints_< ceil_, long double > {};
+
+  template <typename T>
+  struct fun_traits_< ceil_<T> >
+  {
+    typedef T arg_type;
+    typedef T res_type;
+  };
+
+
+  template <typename T>
+  struct ceil_
+
+    : public abstract::plain_nary_fun_< 1, ceil_<T> >,
+
+      private constraints_< ceil_, T >
+  {
+    xtd_res(ceil_<T>) impl_op(const T& arg) const
+    {
+      return std::ceil(arg);
+    }
+  };
+
+
+  typedef m1fun_<ceil_> ceil_type;
+
+
+  /// \}
+
+
+
+  /// \brief Plain function object xtd::ceil_f : float -> float.
+  const ceil_<float>       ceil_f;
+
+  /// \brief Plain function object xtd::ceil_d : double -> double.
+  const ceil_<double>      ceil_d;
+
+  /// \brief Plain function object xtd::ceil_ld : long double -> long double.
+  const ceil_<long double> ceil_ld;
+
+  /// \brief Meta function object xtd::ceil.
+  const ceil_type          ceil;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_CEIL_HH
Index: xtd/math/cmp.hh
--- xtd/math/cmp.hh	(revision 0)
+++ xtd/math/cmp.hh	(revision 0)
@@ -0,0 +1,49 @@
+// Copyright (C) 2002, 2005, 2006  EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef EXTENDED_MATH_CMP_HH
+# define EXTENDED_MATH_CMP_HH
+
+# include <xtd/internal/opmacros.hh>
+
+
+namespace xtd
+{
+
+  xtd_internal_decl_binary_operator( eq,      == );
+  xtd_internal_decl_binary_operator( neq,     != );
+  xtd_internal_decl_binary_operator( less,    <  );
+  xtd_internal_decl_binary_operator( leq,     <= );
+  xtd_internal_decl_binary_operator( greater, >  );
+  xtd_internal_decl_binary_operator( geq,     >= );
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_CMP_HH
Index: xtd/optraits.hh
--- xtd/optraits.hh	(revision 443)
+++ xtd/optraits.hh	(working copy)
@@ -25,8 +25,8 @@
 // reasons why the executable file might be covered by the GNU General
 // Public License.
 
-#ifndef EXTENDED_TRAITS_HH
-# define EXTENDED_TRAITS_HH
+#ifndef EXTENDED_OPTRAITS_HH
+# define EXTENDED_OPTRAITS_HH
 
 # include <mlc/flags.hh>
 
@@ -165,4 +165,4 @@
 
 
 
-#endif // ! EXTENDED_TRAITS_HH
+#endif // ! EXTENDED_OPTRAITS_HH
Index: xtd/builtin/traits.hh
--- xtd/builtin/traits.hh	(revision 449)
+++ xtd/builtin/traits.hh	(working copy)
@@ -28,7 +28,7 @@
 #ifndef EXTENDED_BUILTIN_TRAITS_HH
 # define EXTENDED_BUILTIN_TRAITS_HH
 
-# include <xtd/traits.hh>
+# include <xtd/optraits.hh>
 
 
 
Index: xtd/internal/opmacros.hh
--- xtd/internal/opmacros.hh	(revision 443)
+++ xtd/internal/opmacros.hh	(working copy)
@@ -25,22 +25,51 @@
 // reasons why the executable file might be covered by the GNU General
 // Public License.
 
-#ifndef EXTENDED_OPS_EXPR_HH
-# define EXTENDED_OPS_EXPR_HH
+#ifndef EXTENDED_INTERNAL_OPMACROS_HH
+# define EXTENDED_INTERNAL_OPMACROS_HH
+
+# include <xtd/math/includes.hh>
 
 # include <xtd/abstract/fun_expr.hh>
 # include <xtd/mexpr.hh>
-# include <xtd/math/arith.hh>
-
-
-
+# include <xtd/literal.hh>
 
-// FIXME: doc
+# include <xtd/optraits.hh>
+# include <xtd/builtin/traits.hh>
 
 
 
 # define xtd_internal_decl_unary_operator(OperatorName, OperatorSymbol)	\
 									\
+									\
+  template <typename T>							\
+  struct plain_##OperatorName##_;					\
+									\
+  template <typename T>							\
+  struct fun_traits_< plain_##OperatorName##_<T> >			\
+  {									\
+    typedef T arg_type;							\
+    typedef xtd_##OperatorName(T) res_type;				\
+  };									\
+									\
+									\
+  template <typename T>							\
+  struct plain_##OperatorName##_					\
+									\
+    : public abstract::plain_nary_fun_< 1, plain_##OperatorName##_<T> >	\
+  {									\
+    typedef plain_##OperatorName##_<T> self;				\
+    xtd_res(self) impl_op(const T& arg) const				\
+    {									\
+      return OperatorSymbol arg;					\
+    }									\
+  };									\
+									\
+									\
+  typedef m1fun_<plain_##OperatorName##_> OperatorName##_type;		\
+  const OperatorName##_type OperatorName;				\
+									\
+									\
   template <typename Expr>						\
   xtd::m1expr_<xtd::OperatorName##_type, Expr>				\
   operator OperatorSymbol (const xtd::abstract::fun_expr_<Expr>& expr)	\
@@ -49,10 +78,11 @@
     return tmp;								\
   }									\
 									\
-  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+									\
+  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n				\
 
 
-// FIXME: add something like:
+//   FIXME: does not specialize any template arguments
 
 //   template <typename Expr>
 //   struct OperatorName##_trait_ < Expr >
@@ -62,9 +92,38 @@
 
 
 
-
 # define xtd_internal_decl_binary_operator(OperatorName, OperatorSymbol)	\
 										\
+										\
+  template <typename T1, typename T2>						\
+  struct plain_##OperatorName##_;						\
+										\
+  template <typename T1, typename T2>						\
+  struct fun_traits_< plain_##OperatorName##_<T1, T2> >				\
+  {										\
+    typedef T1 arg1_type;							\
+    typedef T2 arg2_type;							\
+    typedef xtd_##OperatorName(T1, T2) res_type;				\
+  };										\
+										\
+										\
+  template <typename T1, typename T2>						\
+  struct plain_##OperatorName##_						\
+										\
+    : public abstract::plain_nary_fun_< 2, plain_##OperatorName##_<T1, T2> >	\
+  {										\
+    typedef plain_##OperatorName##_<T1, T2> self;				\
+    xtd_res(self) impl_op(const T1& arg1, const T2& arg2) const			\
+    {										\
+      return arg1 OperatorSymbol arg2;						\
+    }										\
+  };										\
+										\
+										\
+  typedef m2fun_<plain_##OperatorName##_> OperatorName##_type;			\
+  const OperatorName##_type OperatorName;					\
+										\
+										\
   template <typename Lexpr, typename Rexpr>					\
   xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr>				\
   operator OperatorSymbol (const xtd::abstract::fun_expr_<Lexpr>& lexpr,	\
@@ -74,10 +133,11 @@
     return tmp;									\
   }										\
 										\
-  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+										\
+  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n					\
 
 
-// FIXME: add something like:
+//   FIXME: does not specialize any template arguments
 
 //   template <typename Lexpr, typename Rexpr>
 //   struct OperatorName##_trait_ < Lexpr, Rexpr >
@@ -86,42 +146,4 @@
 //   };
 
 
-
-
-
-namespace xtd
-{
-
-  // logic
-
-  xtd_internal_decl_binary_operator( land, and );
-  xtd_internal_decl_binary_operator( lor,  or );
-  xtd_internal_decl_binary_operator( lxor, xor );
-
-  xtd_internal_decl_unary_operator( lnot, not );
-
-
-  // cmp
-
-  xtd_internal_decl_binary_operator( eq,      == );
-  xtd_internal_decl_binary_operator( neq,     != );
-  xtd_internal_decl_binary_operator( less,    <  );
-  xtd_internal_decl_binary_operator( leq,     <= );
-  xtd_internal_decl_binary_operator( greater, >  );
-  xtd_internal_decl_binary_operator( geq,     >= );
-
-
-  // arith
-
-  xtd_internal_decl_binary_operator( plus,  + );
-  xtd_internal_decl_binary_operator( minus, - );
-  xtd_internal_decl_binary_operator( mult,  * );
-  xtd_internal_decl_binary_operator( div,   / );
-  xtd_internal_decl_binary_operator( mod,   % );
-
-  xtd_internal_decl_unary_operator( uminus, - );
-
-} // end of namespace xtd
-
-
-#endif // ! EXTENDED_OPS_EXPR_HH
+#endif // ! EXTENDED_INTERNAL_OPMACROS_HH
Index: tests/cos.cc
--- tests/cos.cc	(revision 449)
+++ tests/cos.cc	(working copy)
@@ -1,6 +1,6 @@
 #include <iostream>
 
-#include <xtd/math.hh>
+#include <xtd/math/cos.hh>
 
 
 int main()
@@ -29,11 +29,11 @@
 //     std::cout << (cos(_1)(_2)).nargs() << std::endl; // gives: 2
 //   }
 
-  {
-    using xtd::cos;
-    using xtd::sin;
-    using xtd::_1;
-    using xtd::_2;
+//   {
+//     using xtd::cos;
+//     using xtd::sin;
+//     using xtd::_1;
+//     using xtd::_2;
 
 //     std::cout << (cos(_1) * cos(_1) + sin(_2) * sin(_2))(5.f, 5.f) << std::endl;
 
@@ -44,9 +44,9 @@
 //     (cos(_1) + sin(_1))(_1);
 //     std::cout << (cos(_1) * cos(_1) + sin(_1) * sin(_1))(_1)(51.f) << std::endl;
 
-    std::cout << (_1 * _1 + _2 * _2)(cos(_1), sin(_1))(51.f) << std::endl;
+//     std::cout << (_1 * _1 + _2 * _2)(cos(_1), sin(_1))(51.f) << std::endl;
 
 //     std::cout << ((cos(_1) + sin(_2))(_1, _1)).nargs() << std::endl;
-  }
+//   }
 
 }
Index: tests/Makefile.am
--- tests/Makefile.am	(revision 449)
+++ tests/Makefile.am	(working copy)
@@ -13,7 +13,8 @@
   cast						\
   cfun						\
   cos						\
-  lit
+  lit						\
+  math
 
 id_SOURCES = id.cc
 bind_SOURCES = bind.cc
@@ -21,5 +22,6 @@
 cfun_SOURCES = cfun.cc
 cos_SOURCES = cos.cc
 lit_SOURCES = lit.cc
+math_SOURCES = math.cc
 
 TESTS = $(check_PROGRAMS)
Index: tests/math.cc
--- tests/math.cc	(revision 0)
+++ tests/math.cc	(revision 0)
@@ -0,0 +1,14 @@
+#include <iostream>
+#include <xtd/math.hh>
+
+
+int main()
+{
+  using xtd::cos;
+  using xtd::sin;
+  using xtd::_1;
+  using xtd::_2;
+
+  std::cout << (cos(_1) * cos(_1) + sin(_2) * sin(_2))(_1, _1)(51.f) << std::endl;
+  std::cout << (_1 * _1 + _2 * _2)(cos(_1), sin(_1))(51.f) << std::endl;
+}
Index: tests/cast.cc
--- tests/cast.cc	(revision 449)
+++ tests/cast.cc	(working copy)
@@ -1,7 +1,7 @@
 #include <iostream>
 #include <xtd/cast.hh>
 #include <xtd/arg.hh>
-#include <xtd/math/trigo.hh>
+#include <xtd/math/cos.hh>
 
 
 int main()
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/metalic
I had to help the compiler regarding mlc_is_a (within a template context).
Tell me if the tests fail because of this change.
Index: ChangeLog
from  Roland Levillain  <roland(a)lrde.epita.fr>
	Add mlc::any.
	* mlc/contract.hh: New (imported from Olena proto-1.0).
	* mlc/any.hh: New (imported from Olena proto-1.0).
	Aesthetic changes.
	(any__simple): New class.
	* mlc/is_a.hh (mlc_is_a, mlc_is_not_a): Use the `template' keyword
	to remove an ambiguity w.r.t the nature of the template struct
	`ret' within mlc::form::of.
	* tests/any.cc: New test.
	* tests/Makefile.am (check_PROGRAMS): Add any.
	(any_SOURCES): New.
 mlc/Makefile.am   |    1 
 mlc/any.hh        |   78 +++++++++++++++++++----------
 mlc/contract.hh   |   12 +---
 mlc/is_a.hh       |    8 ++-
 tests/Makefile.am |    2 
 tests/any.cc      |  143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 209 insertions(+), 35 deletions(-)
Index: tests/Makefile.am
--- tests/Makefile.am	(revision 448)
+++ tests/Makefile.am	(working copy)
@@ -8,6 +8,7 @@
 # when oln.m4 is available in the distribution.
 
 check_PROGRAMS =				\
+  any						\
   case						\
   if						\
   is_a						\
@@ -17,6 +18,7 @@
   switch					\
   typedef
 
+any_SOURCES       = any.cc
 case_SOURCES = case.cc
 if_SOURCES = if.cc
 is_a_SOURCES = is_a.cc
Index: tests/any.cc
--- tests/any.cc	(revision 0)
+++ tests/any.cc	(revision 0)
@@ -0,0 +1,143 @@
+/// Test mlc::any.
+
+#include <mlc/any.hh>
+#include <mlc/cmp.hh>
+#include <mlc/assert.hh>
+#include <mlc/logic.hh>
+#include <mlc/is_a.hh>
+
+// FIXME: Test other flavors of mlc::any.
+
+/* Linear hierachy.
+
+   - Abstractions.
+
+                           mlc::any<Exact>
+                                  ^
+                                  |
+                               A<Exact>
+                                  ^
+                                  |
+                               B<Exact>
+                                  ^
+                                  |
+                                Exact
+
+
+   -  Concrete class C, deriving from B.
+
+                             mlc::any<C>
+                                  ^
+                                  |
+                                 A<C>
+                                  ^
+                                  |
+                                 B<C>
+                                  ^
+                                  |
+                                  C
+
+*/
+
+template <typename Exact>
+struct A : public mlc::any__simple< Exact > {};
+
+template <typename Exact>
+struct B : public A< Exact > {};
+
+struct C : public B<C> {};
+
+
+/* A more complex hierarchy (several subclasses, diamond inheritance).
+
+   - Abstractions.
+
+                           mlc::any<Exact>
+                                  ^
+                                  |
+                               T<Exact>
+                               ^  ^   ^
+                              /   |    \
+                             /    |     \
+                     U<Exact>  X<Exact>  Y<Exact>
+                        ^         ^         ^
+                        |         |         |
+                      Exact     Exact     Exact
+
+   - Concrete classes V and Z, deriving from U and from X and Y resp.
+
+
+                 mlc::any<Z>          mlc::any<Z>
+                     ^                    ^
+                     |                    |
+                    T<Z>                 T<Z>
+                     ^                    ^
+                     |                  /   \
+                    U<Z>              X<Z>  Y<Z>
+                     ^                 ^     ^
+                     |                  \   /
+                     V                    Z
+
+*/
+
+template <typename Exact>
+struct T : public mlc::any__simple< Exact > {};
+
+template <typename Exact>
+struct U : public T< Exact > {};
+
+struct V : public U<V> {};
+
+template <typename Exact>
+struct X : virtual public T< Exact > {};
+
+template <typename Exact>
+struct Y : virtual public T< Exact > {};
+
+struct Z : public X<Z>, public Y<Z> {};
+
+// The struct enclosing these two functions (methods) is used to
+// factor the code w.r.t. the tested hierarchy.
+template <template < class > class Top>
+struct assuming_top_class_is
+{
+  template <template < class > class T, typename E>
+  static void
+  test_exact_is_a(Top<E>& a)
+  {
+    typedef typeof(a.exact()) exact_type;
+    
+    mlc::assert_< mlc::eq_<exact_type, E> >::check();
+    mlc::assert_< mlc_is_a(exact_type, T) >::check();
+  };
+
+  template <template <class> class T, typename E>
+  static void
+  test_exact_is_not_a(Top<E>& a)
+  {
+    typedef typeof(a.exact()) exact_type;
+    
+    mlc::assert_< mlc::eq_<exact_type, E> >::check();
+    mlc::assert_< mlc_is_not_a(exact_type, T) >::check();
+  }
+};
+
+int
+main()
+{
+  C c;
+  assuming_top_class_is<A>::test_exact_is_a<A>(c);
+  assuming_top_class_is<A>::test_exact_is_a<B>(c);
+
+  Z z;
+  assuming_top_class_is<T>::test_exact_is_a<T>(z);
+  assuming_top_class_is<T>::test_exact_is_a<X>(z);
+  assuming_top_class_is<T>::test_exact_is_a<Y>(z);
+
+  X<Z> x;
+  assuming_top_class_is<T>::test_exact_is_a<T>(x);
+  // Bad branch.
+  assuming_top_class_is<T>::test_exact_is_not_a<U>(x);
+  // Bad hierachy.
+  assuming_top_class_is<T>::test_exact_is_not_a<B>(x);
+}
Index: mlc/any.hh
--- mlc/any.hh	(revision 0)
+++ mlc/any.hh	(working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006  EPITA Research and
+// Development Laboratory.
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -29,19 +30,21 @@
 #ifndef METALIC_ANY_HH
 # define METALIC_ANY_HH
 
-# include <mlc/contract.hh>
+/// \file mlc/any.hh
+/// \brief Implementation of mlc::any classes (top of static hierachies).
 
 
-// abbrev
-#define any_mem(E) any <E, dispatch_policy::best_memory>
+# include <mlc/contract.hh>
 
 
+// \def Shortcut.
+#define any_mem(E) any<E, dispatch_policy::best_memory>
 
-// 'any' classes
 
 namespace mlc
 {
 
+  /// Tags selecting a dispatch for mlc::any.
   struct dispatch_policy
   {
     struct best_speed;
@@ -50,14 +53,16 @@
   };
 
 
-  // any
-
+  /// Top class of a static hierachy.
   template <typename E, typename Dispatch_Policy = dispatch_policy::simple>
   struct any;
 
 
-  // "best speed" version of 'any'
+  /*-----------------------.
+  | mlc::any__best_speed.  |
+  `-----------------------*/
 
+  /// "Best speed" version of `any'.
   template <typename E>
   struct any <E,
               dispatch_policy::best_speed>
@@ -72,7 +77,6 @@
     }
 
     /// Assignment (op=).
-
     any& operator=(const any& rhs)
     {
       // do nothing
@@ -81,19 +85,19 @@
     }
 
     /// Copy Ctor.
-
     any(const any& rhs) :
-      exact_ptr(0) // safety
+      // For safety purpose.
+      exact_ptr(0)
     {
-      // this->exact_ptr is *not* copied
-      // its value has to be set in subclasses copy ctors.
+      // this->exact_ptr is *not* copied; its value has to be set in
+      // subclasses copy ctors.
     }
 
   protected:
     any(E* exact_ptr) : exact_ptr(exact_ptr) {}
     virtual ~any() {}
 
-    /// Only attribute.
+    /// Sole attribute.
     E* exact_ptr;
   };
 
@@ -106,14 +110,21 @@
     any__best_speed(E* exact_ptr = 0) : super(exact_ptr) {}
   };
 
-  // "best memory" version of 'any'
 
-  // FIXME:
-  // We should test with autotools if the compiler allows us to write a 
-  // static_cast or not (diamond inheritance problem). gcc-2.95 gives a
-  // different adress but not gcc-3.
-  // On Mac OS X, the compilation fails with a strange link error if you
-  // try to use the offset computation.
+  /*------------------------.
+  | mlc::any__best_memory.  |
+  `------------------------*/
+
+  /// "Best memory" version of 'any'
+  /* FIXME:
+     We should test with autotools if the compiler allows us to write a 
+     static_cast or not (diamond inheritance problem). gcc-2.95 gives a
+     different adress but not gcc-3.
+     On Mac OS X, the compilation fails with a strange link error if you
+     try to use the offset computation.
+
+     2006-03-24 Roland: Investigate this bug/behavior of Apple's GCC.
+     This is not the first time that Apple GCC 3.3 behaves strangely. */
   template <typename E>
   struct any <E,
 	      dispatch_policy::best_memory>
@@ -141,8 +152,10 @@
 
   protected:
     any() {}
-    any(E* exact_ptr_does_not_exist_in_this_version); // safety
-    virtual ~any() {} // FIXME: virtual for a "best memory" version!?
+    // For safety purpose.
+    any(E* exact_ptr_does_not_exist_in_this_version);
+    // FIXME: virtual for a "best memory" version!?
+    virtual ~any() {}
   };
 
   template <typename E>
@@ -155,15 +168,19 @@
 
 # if not defined  __GNUC__ || __GNUC__ < 3
   template <typename E> const E any_mem(E)::exact_obj = E();
-  template <typename E> const any_mem(E)& any_mem(E)::ref_exact_obj = any_mem(E)::exact_obj;
+  template <typename E> const any_mem(E)& any_mem(E)::ref_exact_obj =
+  any_mem(E)::exact_obj;
   template <typename E> const int any_mem(E)::exact_offset =
                                      (const char*)(void*)(&any_mem(E)::ref_exact_obj)
                                        - (const char*)(void*)(&any_mem(E)::exact_obj);
 # endif
 
 
-  // "simple" version of 'any'
+  /*-------------------.
+  | mlc::any__simple.  |
+  `-------------------*/
 
+  /// "Simple" version of `any'.
   template <typename E>
   struct any <E,
               dispatch_policy::simple>
@@ -176,7 +193,16 @@
     }
   protected:
     any() {}
-    any(E* exact_ptr_does_not_exist_in_this_version); // safety
+    // For safety purpose.
+    any(E* exact_ptr_does_not_exist_in_this_version);
+  };
+
+  template <typename E>
+  struct any__simple : public any<E, dispatch_policy::simple>
+  {
+  protected:
+    typedef any<E, dispatch_policy::simple> super;
+    any__simple() : super() {}
   };
 
 
Index: mlc/is_a.hh
--- mlc/is_a.hh	(revision 448)
+++ mlc/is_a.hh	(working copy)
@@ -239,7 +239,9 @@
 */
 
 # define mlc_is_a(T, U) \
-mlc::wrap_< typename mlc::is_a_< sizeof(mlc::form::of< U >()) >::ret< T, U > >
+mlc::wrap_<								    \
+  typename mlc::is_a_< sizeof(mlc::form::of< U >()) >::template ret< T, U > \
+>
 
 # define mlc_is_a_(T, U) \
 mlc::is_a_< sizeof(mlc::form::of< U >()) >::ret< T, U >
@@ -254,7 +256,9 @@
 */
 
 # define mlc_is_not_a(T, U) \
-mlc::not_< typename mlc::is_a_<sizeof(mlc::form::of<U >())>::ret<T,U > >
+mlc::not_<								 \
+  typename mlc::is_a_<sizeof(mlc::form::of<U >())>::template ret< T, U > \
+>
 
 # define mlc_is_not_a_(T, U) \
 mlc::not_< mlc::is_a_< sizeof(mlc::form::of<U >())>::ret<T,U > >
Index: mlc/Makefile.am
--- mlc/Makefile.am	(revision 448)
+++ mlc/Makefile.am	(working copy)
@@ -2,6 +2,7 @@
 
 mlcdir = $(includedir)/mlc
 nobase_mlc_HEADERS = 				\
+  any.hh					\
   bool.hh					\
   case.hh					\
   cmp.hh					\
Index: mlc/contract.hh
--- mlc/contract.hh	(revision 0)
+++ mlc/contract.hh	(working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005  EPITA Research and
+// Development Laboratory.
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -28,11 +29,10 @@
 #ifndef METALIC_CONTRACT_HH
 # define METALIC_CONTRACT_HH
 
+# include <cassert>
 
-# include <assert.h>
-
-// FIXME: a lot of code has been removed here
-// for simplification purpose only
+// FIXME: a lot of code has been removed here for simplification
+// purpose only.
 
 # define assertion(expr)     assert(expr)
 # define invariant(expr)     assert(expr) 
@@ -40,7 +40,6 @@
 # define postcondition(expr) assert(expr) 
 
 
-
 # define mlc_check_method_impl(WHERE, RETURN, NAME, ARG, CONST)	\
 {								\
   typedef RETURN (WHERE::*meth)(ARG) CONST;			\
@@ -58,5 +57,4 @@
 }										\
 struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
 
-
 #endif // ! METALIC_CONTRACT_HH
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from  Roland Levillain  <roland(a)lrde.epita.fr>
	Static: Catch up with current Metalic
	* tests/entry.cc (mlc::abort_): Remove this fake and use
	mlc/abort.hh instead.
	* stc/properties.hh: s/mlc::is_found/mlc::is_found_/g.
 stc/properties.hh |    4 ++--
 tests/entry.cc    |    8 +-------
 2 files changed, 3 insertions(+), 9 deletions(-)
Index: tests/entry.cc
--- tests/entry.cc	(revision 447)
+++ tests/entry.cc	(working copy)
@@ -5,13 +5,7 @@
 #include <mlc/case.hh>
 #include <mlc/assert.hh>
 #include <mlc/is_a.hh>
-
-// FIXME: Fake.  Remove this when mlc::abort_ is added to the project.
-namespace mlc
-{
-  template <typename T>
-  class abort_ {};
-}
+#include <mlc/abort.hh>
 
 
 /*----------.
Index: stc/properties.hh
--- stc/properties.hh	(revision 447)
+++ stc/properties.hh	(working copy)
@@ -333,9 +333,9 @@
 									      \
     /* Did we found the virtual type? */				      \
     static const bool found_external_p =				      \
-      mlc_bool(mlc::is_found<external_typedef>);			      \
+      mlc_bool(mlc::is_found_<external_typedef>);			      \
     static const bool found_internal_p =				      \
-      mlc_bool(mlc::is_found<internal_typedef>);			      \
+      mlc_bool(mlc::is_found_<internal_typedef>);			      \
 									      \
     typedef typename							      \
     internal::select_typedef<found_external_p, found_internal_p,	      \
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0