|
Boost Users : |
Subject: Re: [Boost-users] Template operator() overloading for types in a mpl::vector
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-11-02 10:34:32
AMDG
Olivier Tournaire wrote:
> I am currently trying to write a simple functor, and I would like to have
> the same overload for the operator () for all types in a mpl::vector.
>
> <snip>
>
> struct any_view_min_max
> {
> typedef std::pair<float, float> result_type;
>
> template <typename View>
> result_type operator()(const View& v) const
> {
> typedef typename View::iterator iterator;
> std::pair< iterator, iterator > result = boost::minmax_element(
> v.begin() , v.end() , pixel_compare_less() );
> return std::make_pair( *(result.first) , *(result.second) );
> }
> };
>
> This works fine for 'gray_image_types', but need to be specialized for types
> in rgb_image_types. The specialization is the same, so, I am looking for an
> automated way to do this. "Manually", I can write this:
>
> <snip>
>
You can define two overloads of operator() and use enable_if to
distinguish them.
In Christ,
Steven Watanabe
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