c++ - no overloaded function takes 2 arguments(functors) -


i run probles while trying implement custom comparator support heap data structure here's how want like:

    template <class t, class pred = std::less<t>>     class concurrentpriorityqueue {     private:          template <class t>         class node         {         private:             t data;             bool operator < (const node<t>& t) {             return pred(data, t.data);          }             };      }; 

and compare functor want use:

struct comp {             bool operator () (const std::pair<int, fn_type> &p1,                 const std::pair<int, fn_type> &p2) const{                 return p1.first < p2.first;             }         }; 

concurrentpriorityqueue<std::pair<int, fn_type>, comp> fqueue; 

everything looks pretty right me, error

error 2 error c2661: 'threadpool::comp::comp' : no overloaded function takes 2 arguments c:\users\usr\documents\visual studio 2013\projects\secondtask\queue.hpp. please me out this.

pred refers type, not instance of type.


currently trying invoke constructor of type pred when doing pred(data, t.data), first have create instance of pred able call matching operator() (...) on it.

the below example creates temporary instance of type pred, , calls operator();

        return pred () (data, t.data); // 1) create temporary instance of `pred`                                        // 2) call operator() `data` , `t.data` 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -