Signed-off-by: Guillaume Lazzara <z(a)lrde.epita.fr>
---
milena/mln/algebra/vec.hh | 2 +-
milena/mln/convert/from_to.hxx | 2 +-
milena/mln/core/concept/proxy.hxx | 10 +++++-
milena/mln/core/dpoint.hh | 13 +++------
milena/mln/core/image/vmorph/thru_image.hh | 4 +-
milena/mln/core/internal/exact.hh | 4 +-
milena/mln/core/internal/force_exact.hh | 30 +++++++++++++++++++++
milena/mln/geom/chamfer.hh | 2 +-
milena/mln/metal/converts_to.hh | 6 ++--
milena/mln/metal/is.hh | 3 +-
milena/mln/metal/is_a.hh | 3 +-
milena/mln/morpho/tree/compute_attribute_image.hh | 4 +-
milena/mln/morpho/tree/data.hh | 11 ++++++-
milena/mln/trace/quiet.hh | 8 +++++-
14 files changed, 74 insertions(+), 28 deletions(-)
diff --git a/milena/mln/algebra/vec.hh b/milena/mln/algebra/vec.hh
index 22ebc02..b63b0da 100644
--- a/milena/mln/algebra/vec.hh
+++ b/milena/mln/algebra/vec.hh
@@ -55,7 +55,7 @@ namespace mln
// Forward declarations.
namespace algebra {
template <unsigned n, typename T> class vec;
- template <unsigned d, typename C> class h_vec;
+ template <unsigned d, typename C> struct h_vec;
template <unsigned n, unsigned m, typename T> class mat;
}
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index f4f690d..85f939c 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -68,7 +68,7 @@ namespace mln
namespace algebra {
template <unsigned n, typename T> class vec;
- template <unsigned d, typename C> class h_vec;
+ template <unsigned d, typename C> struct h_vec;
}
namespace fun {
diff --git a/milena/mln/core/concept/proxy.hxx b/milena/mln/core/concept/proxy.hxx
index 2f77cec..057ad60 100644
--- a/milena/mln/core/concept/proxy.hxx
+++ b/milena/mln/core/concept/proxy.hxx
@@ -117,6 +117,7 @@ namespace mln
{
typedef mln_exact(mlc_unqualif(O))& ret;
static ret on(O& obj);
+
};
@@ -310,17 +311,22 @@ namespace mln
template <typename P>
inline
- mln_exact(P)::HOT_actual_subject
+ // Fixme: This is a fix for compilation on MSVC.
+ typename helper_unproxy_rec< P, true >::ret
+ //Was: mln_exact(P)::HOT_actual_subject
helper_unproxy_rec< P, true >::on(P& p)
{
return unproxy_rec(exact(p).unproxy_());
}
+
// helper_unprox_rec
template <typename P>
inline
- mlc_const(mln_exact(P)::HOT_actual_subject)
+ // Fixme: This is a fix for compilation on MSVC.
+ typename helper_unproxy_rec< const P, true >::ret
+ //Was: mlc_const(mln_exact(P)::HOT_actual_subject)
helper_unproxy_rec< const P, true >::on(const P& p)
{
return unproxy_rec(exact(p).unproxy_());
diff --git a/milena/mln/core/dpoint.hh b/milena/mln/core/dpoint.hh
index f4d603e..dd43db6 100644
--- a/milena/mln/core/dpoint.hh
+++ b/milena/mln/core/dpoint.hh
@@ -119,7 +119,10 @@ namespace mln
/// Conversion towards a algebra::vec.
template <typename Q>
- operator mln::algebra::vec<dpoint<G,C>::dim, Q>() const;
+ operator mln::algebra::vec<dpoint<G,C>::dim, Q>() const
+ {
+ return to_vec();
+ }
/// Explicit conversion.
vec to_vec() const;
@@ -252,14 +255,6 @@ namespace mln
}
template <typename G, typename C>
- template <typename Q>
- inline
- dpoint<G,C>::operator mln::algebra::vec<dpoint<G,C>::dim, Q> ()
const
- {
- return to_vec();
- }
-
- template <typename G, typename C>
inline
typename dpoint<G,C>::vec
dpoint<G,C>::to_vec() const
diff --git a/milena/mln/core/image/vmorph/thru_image.hh
b/milena/mln/core/image/vmorph/thru_image.hh
index 2691d38..c6a5ad1 100644
--- a/milena/mln/core/image/vmorph/thru_image.hh
+++ b/milena/mln/core/image/vmorph/thru_image.hh
@@ -284,7 +284,7 @@ namespace mln
}
template <typename I, typename F>
- thru_image<const I, F> thru(const mln::Function<F>& f,
+ const thru_image<const I, F> thru(const mln::Function<F>& f,
const Image<I>& ima)
{
thru_image<const I, F> tmp(exact(ima), exact(f));
@@ -302,7 +302,7 @@ namespace mln
}
template <typename I, typename M>
- thru_image<const I, mln_fun_with(M, mln_value(I))>
+ const thru_image<const I, mln_fun_with(M, mln_value(I))>
thru(const mln::Meta_Function<M>& f, const Image<I>& ima)
{
typedef mln_fun_with(M, mln_value(I)) F;
diff --git a/milena/mln/core/internal/exact.hh b/milena/mln/core/internal/exact.hh
index e483cf3..5d3628b 100644
--- a/milena/mln/core/internal/exact.hh
+++ b/milena/mln/core/internal/exact.hh
@@ -75,7 +75,7 @@ namespace mln
template <typename E>
yes_ exact_selector_(Object<E>*);
- no_ exact_selector_(void*);
+ no_ exact_selector_(...);
template <typename E, typename T>
E* exact_run_(Object<E>* t, T*);
@@ -123,7 +123,7 @@ namespace mln
inline
E* exact_run_(Object<E>* t, T*)
{
- return (E*)(void*)t;
+ return static_cast<E*>(t);
}
template <typename T>
diff --git a/milena/mln/core/internal/force_exact.hh
b/milena/mln/core/internal/force_exact.hh
index fdcad01..3843b62 100644
--- a/milena/mln/core/internal/force_exact.hh
+++ b/milena/mln/core/internal/force_exact.hh
@@ -46,6 +46,35 @@ namespace mln
doing.
\see mln::exact. */
+
+
+ template <typename S, typename D>
+ struct safe_c_cast
+ {
+ static D* run(S* s, D* a = static_cast<D*>((S*)0))
+ {
+ return static_cast<D*>(s);
+ }
+ static D* run(S* s, ...)
+ {
+/* static const E* exact_obj;
+ static const T& exact_obj_ref = *exact_obj;
+ static const ptrdiff_t exact_offset =
+ (const char*)(void*)(&exact_obj_ref)
+ - (const char*)(void*)(exact_obj);
+ return *(E*)((char*)(s) - exact_offset);*/
+ return *reinterpret_cast<E*>(s);
+ }
+
+ };
+
+ template <typename E, typename T>
+ E& force_exact(const T& ref)
+ {
+ return *safe_c_cast<T, E>::run(const_cast<T*>(&ref), (E*)0);
+ }
+
+ /*
template <typename E, typename T>
E& force_exact(const T& ref)
{
@@ -56,6 +85,7 @@ namespace mln
- (const char*)(void*)(exact_obj);
return *(E*)((char*)(&ref) - exact_offset);
}
+ */
} // end of namespace mln::internal
diff --git a/milena/mln/geom/chamfer.hh b/milena/mln/geom/chamfer.hh
index 9603605..d62d9a1 100644
--- a/milena/mln/geom/chamfer.hh
+++ b/milena/mln/geom/chamfer.hh
@@ -111,7 +111,7 @@ namespace mln
template <typename I, typename W>
mln_ch_value(I, unsigned)
chamfer(const Image<I>& input_, const W& w_win_,
- unsigned max = mln_max(unsigned))
+ unsigned max)
{
trace::entering("mln::geom::chamfer");
// FIXME: check that input_ is binary.
diff --git a/milena/mln/metal/converts_to.hh b/milena/mln/metal/converts_to.hh
index 25be3e9..89e80c9 100644
--- a/milena/mln/metal/converts_to.hh
+++ b/milena/mln/metal/converts_to.hh
@@ -67,6 +67,8 @@ namespace mln
{
static yes_ selector(U, int);
static no_ selector(eat, ...);
+ enum { ret = sizeof(selector(*internal::make_<mlc_const(T)>::ptr(), 0)) };
+
};
} // end of namespace mln::metal::internal
@@ -75,9 +77,7 @@ namespace mln
/// \brief "converts-to" check.
template <typename T, typename U>
- struct converts_to : bool_<( sizeof(internal::helper_converts_to_<T, U>
- ::selector(*internal::make_<mlc_const(T)>::ptr(),
- 0) )
+ struct converts_to : bool_<( internal::helper_converts_to_<T, U>::ret
==
sizeof(internal::yes_) )>
{};
diff --git a/milena/mln/metal/is.hh b/milena/mln/metal/is.hh
index 10db237..16ac7e0 100644
--- a/milena/mln/metal/is.hh
+++ b/milena/mln/metal/is.hh
@@ -51,6 +51,7 @@ namespace mln
{
static yes_ selector(U*const);
static no_ selector(...);
+ enum { ret = sizeof(selector(internal::make_< T >::ptr())) };
};
} // end of namespace mln::metal::internal
@@ -61,7 +62,7 @@ namespace mln
/// Check whether T inherits from U.
//
template <typename T, typename U>
- struct is : bool_<( sizeof(internal::helper_is_<T,
U>::selector(internal::make_<T>::ptr()))
+ struct is : bool_<( internal::helper_is_<T, U>::ret
==
sizeof(internal::yes_) )>
{
diff --git a/milena/mln/metal/is_a.hh b/milena/mln/metal/is_a.hh
index 2244c33..8cfc345 100644
--- a/milena/mln/metal/is_a.hh
+++ b/milena/mln/metal/is_a.hh
@@ -81,6 +81,7 @@ namespace mln
template<class V>
static yes_ selector(M<V>*);
static no_ selector(...);
+ enum { ret = sizeof(selector(internal::make_< T >::ptr())) };
};
} // end of namespace mln::metal::internal
@@ -92,7 +93,7 @@ namespace mln
/// Check whether T inherits from _CONCEPT_ M.
//
template <typename T, template <class> class M>
- struct is_a : bool_<( sizeof( internal::helper_is_a_< T, M
>::selector(internal::make_< T >::ptr()) )
+ struct is_a : bool_<( internal::helper_is_a_< T, M >::ret
==
sizeof( internal::yes_ ) )>
{};
diff --git a/milena/mln/morpho/tree/compute_attribute_image.hh
b/milena/mln/morpho/tree/compute_attribute_image.hh
index 9126bf1..9116c2c 100644
--- a/milena/mln/morpho/tree/compute_attribute_image.hh
+++ b/milena/mln/morpho/tree/compute_attribute_image.hh
@@ -215,7 +215,7 @@ namespace mln
mln_ch_value(typename T::function, mln_result(A))
compute_attribute_image(const Accumulator<A>& a_,
const T& t,
- mln_ch_value(typename T::function, A)* accu_image = 0)
+ mln_ch_value(typename T::function, A)* accu_image)
{
trace::entering("morpho::tree::compute_attribute_image");
@@ -233,7 +233,7 @@ namespace mln
compute_attribute_image_from(const Accumulator<A>& a_,
const T& t,
const Image<V>& values,
- mln_ch_value(typename T::function, A)* accu_image = 0)
+ mln_ch_value(typename T::function, A)* accu_image)
{
trace::entering("morpho::tree::compute_attribute_image_from");
diff --git a/milena/mln/morpho/tree/data.hh b/milena/mln/morpho/tree/data.hh
index 1a0c404..1551574 100644
--- a/milena/mln/morpho/tree/data.hh
+++ b/milena/mln/morpho/tree/data.hh
@@ -470,7 +470,9 @@ namespace mln
template <typename I, typename S>
inline
- mln_rvalue_(mln_ch_value(I, mln_psite(I)))
+ // Fixme
+ // Was: mln_rvalue_(mln_ch_value(I, mln_psite(I)))
+ typename data<I,S>::parent_t::rvalue
data<I,S>::parent(const mln_psite(I)& p) const
{
mln_precondition(parent_.domain().has(p));
@@ -479,7 +481,10 @@ namespace mln
template <typename I, typename S>
inline
+ // Fixme
+ // Was: const mln_ch_value(I, mln_psite(I))&
const mln_ch_value(I, mln_psite(I))&
+ //mln_rvalue(typename data<I,S>::parent_t)
data<I,S>::parent_image() const
{
mln_precondition(is_valid());
@@ -588,7 +593,9 @@ namespace mln
template <typename I, typename S>
inline
- mln_rvalue_(mln_ch_value(I, p_array<mln_psite(I)>))
+ // Fixme
+ // Was: mln_rvalue_(mln_ch_value(I, p_array<mln_psite(I)>))
+ typename data<I,S>::children_t::rvalue
data<I,S>::children(const mln_psite(I)& p) const
{
mln_precondition(is_a_node(p));
diff --git a/milena/mln/trace/quiet.hh b/milena/mln/trace/quiet.hh
index f76e8d2..a982a43 100644
--- a/milena/mln/trace/quiet.hh
+++ b/milena/mln/trace/quiet.hh
@@ -32,7 +32,13 @@
*/
# include <ctime>
-# include <sys/time.h>
+
+# ifndef _WIN32
+# include <sys/time.h>
+# else
+# define NOMINMAX
+# include <windows.h>
+# endif
namespace mln
{
--
1.5.6.5