Boost logo

Boost Users :

Subject: [Boost-users] [GIL] does gil::variant<mpl::vector3<A, B, C> > constructor accept instances of gil::variant<mpl::vector2<A, B> > ?
From: Nicolas Lelong (rotoglup_at_[hidden])
Date: 2010-05-06 13:04:20


Hi !

the question is in the subject, but I can elaborate a bit. I have the set of
all views supported by my application, defined as :

  typedef mpl::vector9<
      gray8_view_t
    , rgb8_view_t, bgr8_view_t, rgba8_view_t, bgra8_view_t
    , rgb32f_view_t, bgr32f_view_t, rgba32f_view_t, bgra32f_view_t
>
    gil_all_views_t;

  typedef any_image_view<gil_all_views_t> any_view;

Then I have a function, reading a file and returning an any_image_view, of a
different type :

typedef boost::mpl::vector3<boost::gil::gray8_view_t,
boost::gil::bgr8_view_t, boost::gil::bgra8_view_t> tga_views_t;
typedef boost::gil::any_image_view<tga_views_t> any_tga_view;

The ' tga_views_t' is a subset of 'gil_all_views_t'.

It seems that I cannot construct an 'any_view' instance, from an
'any_tga_view' ; I receive a bad_cast exception.

Is there an existing function or construct I could use for this ?

If I'm not mistaken, boost::variant (not the gil one) allow such constructs
: it extracts the type of the value contained in the 'foreign' variant, and
assigns this value to the new variant.

Anyone could tell me what is the rationale behind having a special variant
for boost::gil ? performance ? Wouldn't it be easier to replace it by
boost::variant ?

Thanks is advance,
cheers,

Nicolas.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net