Boost logo

Boost Users :

Subject: Re: [Boost-users] [bind] Need Help - Function Composition
From: loadcom (loadcom_at_[hidden])
Date: 2008-12-20 00:43:54


One step further, will the following version save one copy construction
in make_less_by_func()?

template <typename F> struct less_by_func
{
        typedef bool result_type;

        const F & func_;
        less_by_func(const F & func) : func_(func) {}

        template<typename T>
        bool operator()(const T& lhs, const T& rhs) const
        { return func_(lhs) < func_(rhs); }
};

// helper function
template<typename F> less_by_func<F> make_less_by_func(const F& func)
{ return less_by_func<F>(func); }

Thanks again.
B/Rgds
Max


Hello Watanabe,

Your code works well. And it's much more generic and elegant
than the original version.

Thank you so much!

Best regards

Max

-------------------------------------------------------------------
ÐÂÀ˿ռ䡪¡ªÓëÅóÓÑ¿ªÐÄ·ÖÏíÍøÂçÐÂÉú»î£¡(http://space.sina.com.cn/ )


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