https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix mln_ch_value w.r.t. stack_image.
* mln/trait/ch_value.hh (ch_value_< M< n, tag::image_<I> >, V>):
Fix the definition of this case, notably used to convert the value
type of a stack_image.
* tests/trait_ch_value.cc: Add a test to exercize this case.
mln/trait/ch_value.hh | 22 +++++++++++++++++-----
tests/trait_ch_value.cc | 16 ++++++++++++++--
2 files changed, 31 insertions(+), 7 deletions(-)
Index: mln/trait/ch_value.hh
--- mln/trait/ch_value.hh (revision 1634)
+++ mln/trait/ch_value.hh (working copy)
@@ -53,14 +53,15 @@
namespace trait
{
-
- template <typename I, typename V> struct ch_value; // Fwd decl.
+ // Fwd decl.
+ template <typename I, typename V> struct ch_value;
namespace impl
{
- template <typename I, typename V> struct ch_value_; // Decl.
+ // Decl.
+ template <typename I, typename V> struct ch_value_;
template < template <class> class M, typename T,
typename V >
@@ -90,12 +91,22 @@
typedef M< P, V > ret;
};
+ // For mln::value::stack_image<n,I>.
template < template <unsigned, class> class M, unsigned n, typename I,
typename V >
- struct ch_value_< M< n, tag::image_<I> >, V > // For
mln::value::stack_image<n,I> !
+ struct ch_value_< M< n, tag::image_<I> >, V >
{
+ /* FIXME: The code used to read
+
typedef metal::vec<n, V> value;
typedef mln_ch_value(I, value) ret;
+
+ here. But this is wrong IMHO (Roland). Changing the value
+ type of a stack image (in fact, a vectorial image) shall
+ alter the *value type* of the image, not the type of the
+ *components* of the vector. Hence the current definition.
+ */
+ typedef mln_ch_value(I, V) ret;
};
template < template <class, class> class M, typename I, typename S,
@@ -110,7 +121,8 @@
struct ch_value_< M< tag::function_<F>, tag::pset_<S> >, V
>
{
typedef typename S::mesh mesh;
- typedef typename image_from_mesh< mesh, V >::ret ret; // FIXME: from_psite
instead? coord=int!?
+ // FIXME: from_psite instead? coord=int!?
+ typedef typename image_from_mesh< mesh, V >::ret ret;
};
} // end of namespace mln::trait::impl
Index: tests/trait_ch_value.cc
--- tests/trait_ch_value.cc (revision 1634)
+++ tests/trait_ch_value.cc (working copy)
@@ -30,14 +30,26 @@
* \brief Tests on mln::trait::ch_value.
*/
-#include <mln/core/image2d.hh>
#include <mln/trait/ch_value.hh>
+#include <mln/core/image2d.hh>
+#include <mln/value/stack.hh>
+
int main()
{
using namespace mln;
typedef image2d<int> I;
- trait::ch_value<I, bool>::ret ima;
+ typedef trait::ch_value<I, bool>::ret J;
+ J ima1;
+
+ // Stack image.
+ typedef value::stack_image<3, I> K;
+ typedef trait::ch_value<K, float>::ret L;
+ L ima2;
+ mlc_equal(L, image2d<float>)::check();
+
+ // FIXME: Exercize more image types.
+ // ...
}