Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

type does not provide a call operator

Tags:

c++

c++11

I have this function, order, which returns vector<Node*>

vector<Node*> order(vector<string> nodes, vector<pair<string, string>> dependencies) {
             Graph graph = buildGraph(nodes, dependencies);
             vector<Node*> order = buildOrder(graph.getNodes());
             return order;
}

and I call it like this:

vector<Node*> order2 = order(nodes, deps);

However, the compiler gives this error:

error: type 'std::__1::vector<Node *, std::__1::allocator<Node *> >' does not provide a call operator
        vector<Node*> order2 = order(nodes, deps);
                               ^~~~~
1 error generated.

What is going wrong? 'std::__1::vector<Node *, std::__1::allocator<Node *> >' seems to suggest that there is a vector<Node*, <Node*>> or something going on, but I can't seem to figure this out.

like image 513
Julien Chien Avatar asked Jul 30 '16 06:07

Julien Chien


1 Answers

It's a bit hard to tell without your posting more complete code, but consider the following:

int order(int j, int k)
{   
    return 3;
}   

int main(int argc, char *argv[])
{   
    char order;

    // order(2, 3);                                                
}

This code builds fine. However, uncommenting

    // order(2, 3);                     

causes it to fail, as within main, order is a character, not a function. From the error message, it looks like you might have some similar problem.

like image 75
Ami Tavory Avatar answered Oct 13 '22 18:10

Ami Tavory