Q:

template metaprogramming problem

template <int p>    
bool FComapare (Node *lId, Node* rId)    
{    
    if(lId->getDiff(p) < rId->getDiff(p))
        return true;
    else if(lId->getDiff(p) == rId->getDiff(p))
    {
        if(lId->getLT() < rId->getLT())
            return true;
        else if(lId->getLT() == rId->getLT())
            return (lId->getTFG() < rId->getTFG());
    } 
    return false;
}

vector<set<Node*, bool (*)(Node*,Node*) > > m_F;

for (int i = 0;i < partNum; ++i)
{
    //This doesn`t workbecause of  const problem...
    set<Node *, bool (*)(Node*,Node*) > f(&FComapare<i>);
    m_F.push_back(f);
}

I am getting following error

error C2664:
      'std::set<_Kty,_Pr>::set(bool (__cdecl
      *const &)(Node *,Node *))' : cannot convert parameter 1 from 'bool
      (__cdecl *)(Node *,Node *)' to 'bool
      (__cdecl *const &)(Node *,Node *)' 1> 
      with 1>        [ 1>
      _Kty=Node *, 1>            _Pr=bool (__cdecl *)(Node *,Node *) 1>        ]
       Reason: cannot convert from
      'overloaded-function' to 'bool
      (__cdecl *const )(Node *,Node *)' 1>
      None of the functions with this name
      in scope match the target type

How can I solve the problem and get the same functionality?
How do I define correctly 
vector<set<Node*, bool (*)(Node*,Node*) > > m_F;

Thanks

A:

You can't use a variable for the non-type argument.
Instead of a template function, try a function object that stores the value of i.
class FCompare
{
    int p;
public:
    FCompare(int p): p(p) {}
    bool operator()(const Node *lId, const Node* rId) const {...}
};

set<Node *, FCompare > f((FCompare(i)));

