C ++ - 二进制的操作数无效>表达

时间:2013-08-01 19:12:18

标签: c++

我正在尝试使用Storing boost::function objects in a container方法#3,而gcc正在抱怨这一点 - >

  

EventComparator.hpp:39,34 - 错误 - 二进制文件的操作数无效   表达式('const request_type'(又名'const std :: function')和'const request_type')

template<typename Callback, typename Function>
bool Comparator(const Function & lhs, const Function & rhs) {
    typedef typename std::conditional < std::is_function<Callback>::value,
            typename std::add_pointer<Callback>::type, Callback >::type request_type;
    if (const request_type * lhs_internal = lhs.template target<request_type>()) {
        if (const request_type * rhs_internal = rhs.template target<request_type>())
            return *rhs_internal == *lhs_internal;
    }
    return false;
}

template<typename ...Args>
class EventComparator : std::function<Args...> {
public:
    typedef std::function<Args...> Function;

    bool (*typeHolder)(const Function &, const Function &);
public:
    EventComparator() {
    }

    template<typename T>
    EventComparator(T function)
        : Function(function), typeHolder(Comparator<T, Function>) {
    }

    template<typename T>
    EventComparator & operator=(T function) {
        Function::operator=(function);
        typeHolder = Comparator<T, Function>;
        return *this;
    }

    friend bool operator==(const Function & lhs, const EventComparator & rhs) {
        return rhs.typeHolder(lhs, rhs);
    }

    friend bool operator==(const EventComparator & lhs, const Function & rhs) {
        return rhs == lhs;
    }

    friend void swap(EventComparator & lhs, EventComparator & rhs) {
        lhs.swap(rhs);
        lhs.typeHolder.swap(rhs.typeHolder);
    }
};

0 个答案:

没有答案