2009/11/2 Steven Watanabe
<watanabesj@gmail.com>
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