Boost logo

Boost Users :

Subject: Re: [Boost-users] Template operator() overloading for types in a mpl::vector
From: Olivier Tournaire (olitour_at_[hidden])
Date: 2009-11-03 12:17:15


Thank you Steven for your reply. It works great.
Here is what I finally did:

// struct histogram_functor

    typename boost::enable_if< boost::mpl::contains<
boost::mpl::transform<gray_image_types,add_view_type<boost::mpl::_1>
>::type,
                                                     ViewType>,
                               result_type>::type operator()(const ViewType&
v) const
    {
         // ...
    }

    template<class ViewType>
    typename boost::enable_if< boost::mpl::or_< boost::mpl::contains<
boost::mpl::transform< rgb_image_types,

add_view_type<boost::mpl::_1 > >::type,

ViewType>,
                                                boost::mpl::contains<
boost::mpl::transform< rgba_image_types,

add_view_type<boost::mpl::_1 > >::type,

ViewType>
>,
                               result_type>::type operator()(const ViewType&
v) const
    {
         // ...
    }

// ...
template <typename ImageType>
struct add_view_type
{
    typedef typename ImageType::view_t type;
};

However, I have one other need: type reduction. For instance, all rgb image
types have the same overload operator(). I do not know if the solution I
came up instantiate the operator for all types, but if it is the case, it is
a valid but not a good solution. What I need is to have the same operator()
for all rgb types. I have read in a paper from L .Bourdev (
www.lubomir.org/academic/Minimizing*CodeBloat*.pdf) that I could use type
reduction, but I need some help. Can you help ?
Here is the definition of rgb_image_types:
#define RGB_IMAGE_TYPES
(boost::gil::rgb8_image_t)(boost::gil::rgb16_image_t)(boost::gil::rgb32_image_t)
typedef boost::mpl::vector< BOOST_PP_SEQ_ENUM( RGB_IMAGE_TYPES ) >
rgb_image_types;

Best regards,

Olivier



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