Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-07-16 19:31:56


AMDG

Michiel Helvensteijn wrote:
> But you understand why I'd like the templated version to
> work. I have other predicates to test

Ok. The compiler can't deduce T in

template <class T>
function<bool (T)> neg(function<bool (T)> func);

unless the argument is already a boost::function. No implicit conversions
allowed.

template<class F>
struct not_t {
    typedef bool result_type;
    template<class T>
    bool operator()(const T& t) { return(!f(t)); }
    F f;
};

template<class F>
not_t<F> neg(F f) {
    not_t<F> result = { f };
    return(result);
}

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