|
Boost Users : |
Subject: Re: [Boost-users] Template operator() overloading for types in a mpl::vector
From: Olivier Tournaire (olitour_at_[hidden])
Date: 2009-11-02 12:44:03
Thank you Steven,
2009/11/2 Steven Watanabe <watanabesj_at_[hidden]>
> AMDG
>
>>
>> <snip>
>>
>>
>
> You can define two overloads of operator() and use enable_if to
> distinguish them.
I thought about this solution but did not know how to implement it. Could
you please provide a small sample?
My current solution is to build mpl::vector from sequences and
boost::preprocessor. Then, with BOOST_PP_SEQ_FOR_EACH I can automagically
generate overloads for all types.
// image_types.hpp
#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;
// ...
// min_max_functor.hpp
#define OVERLOAD_MIN_MAX_PARENTHESIS_OPERATOR( r , n , data ) template <> \
any_view_min_max::result_type
any_view_min_max::operator()<data::view_t>(const data::view_t& v) const \
{ \
// ...
}
BOOST_PP_SEQ_FOR_EACH( OVERLOAD_MIN_MAX_PARENTHESIS_OPERATOR , ~ ,
RGB_IMAGE_TYPES )
Regards,
Olivier
>
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
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