Index: integre/ChangeLog
from Nicolas Burrus <burrus_n(a)lrde.epita.fr>
* ntg/utils/cast.hh: Fix comparison casts.
Index: olena/ChangeLog
from Nicolas Burrus <burrus_n(a)lrde.epita.fr>
* oln/arith/internal/opdecls.hh: Add missing default functors.
* oln/level/cc.hh: Use default arithmetic functor.
* oln/convert/cast.hh: New.
* oln/convert/basics.hh: Include it.
Index: olena/oln/arith/internal/opdecls.hh
--- olena/oln/arith/internal/opdecls.hh Wed, 08 Oct 2003 23:36:51 +0200 burrus_n
(oln/b/22_opdecls.hh 1.14 640)
+++ olena/oln/arith/internal/opdecls.hh Fri, 07 Nov 2003 17:26:19 +0100 burrus_n
(oln/b/22_opdecls.hh 1.15 640)
@@ -63,7 +63,12 @@
{ \
return OPCODE; \
} \
- } /* no ; */
+ }; \
+ \
+ template <class T1, class T2 = T1> \
+ struct default_f_##OPNAME \
+ : public f_##OPNAME< T1, T2, ntg_return_type(OPNAME, T1, T2) > \
+ {} /* no ; */
// Functor used by operations between an image and a constant
Index: olena/oln/convert/basics.hh
--- olena/oln/convert/basics.hh Thu, 31 Jul 2003 15:42:27 +0200 reda (oln/23_basics.hh 1.5
640)
+++ olena/oln/convert/basics.hh Fri, 07 Nov 2003 17:26:19 +0100 burrus_n (oln/23_basics.hh
1.6 640)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2002, 2003 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
@@ -30,6 +30,7 @@
# include <oln/convert/abstract/conversion.hh>
# include <oln/convert/conversion.hh>
+# include <oln/convert/cast.hh>
# include <oln/convert/force.hh>
# include <oln/convert/bound.hh>
# include <oln/convert/stretch.hh>
Index: olena/oln/convert/force.hh
--- olena/oln/convert/force.hh Thu, 07 Aug 2003 02:08:21 +0200 david (oln/20_force.hh 1.11
640)
+++ olena/oln/convert/force.hh Fri, 07 Nov 2003 17:26:19 +0100 burrus_n (oln/20_force.hh
1.12 640)
@@ -35,8 +35,6 @@
namespace oln {
namespace convert {
- // FIXME: is this really useful with new types ?
-
/* Like cast::force, but as a conversion functor. */
template<class Output, class Exact = mlc::final>
struct force : public abstract::conversion_to_type< Output, typename
mlc::exact_vt<force<Output, Exact>, Exact>::ret >
Index: olena/oln/level/cc.hh
--- olena/oln/level/cc.hh Thu, 07 Aug 2003 02:37:23 +0200 burrus_n (oln/e/20_cc.hh
1.11.1.8 640)
+++ olena/oln/level/cc.hh Fri, 07 Nov 2003 17:26:19 +0100 burrus_n (oln/e/20_cc.hh
1.11.1.9 640)
@@ -163,7 +163,7 @@
template <class I>
oln_value_type(I) get_n_cc(const abstract::image<I>& input)
{
- return fold(arith::f_max<oln_value_type(I)>(), input);
+ return fold(arith::default_f_max<oln_value_type(I)>(), input);
}
} // end of namespace level
Index: integre/ntg/utils/cast.hh
--- integre/ntg/utils/cast.hh Tue, 05 Aug 2003 21:39:33 +0200 burrus_n (oln/i/26_cast.hh
1.3.1.9 640)
+++ integre/ntg/utils/cast.hh Fri, 07 Nov 2003 17:26:19 +0100 burrus_n (oln/i/26_cast.hh
1.3.1.10 640)
@@ -88,10 +88,10 @@
bound(const Tsrc& val)
{
if (ntg_max_val(Tsrc) > ntg_max_val(Tdest))
- if (val > Tsrc(ntg_max_val(Tdest)))
+ if (val > Tsrc(Tdest(ntg_max_val(Tdest))))
return ntg_max_val(Tdest);
if (ntg_min_val(Tsrc) < ntg_min_val(Tdest))
- if (val < Tsrc(ntg_min_val(Tdest)))
+ if (val < Tsrc(Tdest(ntg_min_val(Tdest))))
return ntg_min_val(Tdest);
return val;
}
@@ -220,9 +220,9 @@
template<class Tdest, class Tsrc> inline
const Tdest rbound(const Tsrc& val)
{
- if (val > ntg_cast(ntg_max_val(Tdest)))
+ if (val > Tsrc(Tdest(ntg_max_val(Tdest))))
return ntg_max_val(Tdest);
- if (val < ntg_cast(ntg_min_val(Tdest)))
+ if (val < Tsrc(Tdest(ntg_min_val(Tdest))))
return ntg_min_val(Tdest);
return cast::round<Tdest>(val);
}
Index: olena/oln/convert/cast.hh
--- olena/oln/convert/cast.hh Fri, 07 Nov 2003 17:38:17 +0100 burrus_n ()
+++ olena/oln/convert/cast.hh Fri, 07 Nov 2003 17:26:19 +0100 burrus_n (oln/v/35_cast.hh
1.1 600)
@@ -0,0 +1,61 @@
+// Copyright (C) 2001, 2002, 2003 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_CONVERT_CAST_HH
+# define OLENA_CONVERT_CAST_HH
+
+# include <oln/convert/abstract/conversion.hh>
+# include <ntg/utils/cast.hh>
+
+namespace oln {
+ namespace convert {
+
+ template<class Output, class Exact = mlc::final>
+ struct cast : public abstract::conversion_to_type< Output, typename
mlc::exact_vt<cast<Output, Exact>, Exact>::ret >
+ {
+ template< class Input >
+ Output
+ doit(const Input& v) const
+ {
+ return v;
+ }
+
+ static std::string
+ name()
+ {
+ // FIXME: ntg_name(Exact) will not work for mlc::final !
+ return std::string("cast<")
+ + ntg_name(Output) + ", "
+ + "FIXME: ntg_name(Exact)" + ">";
+ }
+
+ };
+
+ } // convert
+} // oln
+
+#endif // OLENA_CONVERT_CAST_HH