error C2064: term does not evaluate to a function taking 2

Hi guys. I'm getting this error

Error 5 error C2064: term does not evaluate to a function taking 2 arguments C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xrefwrap 431 1


after trying to do this

1
2
3
4
typedef std::function<int(int, int)> op;

op someOperator = std::plus<int>();
op someOtherOperator = std::minus<int>();


so I can call a function like

1
2
3
4
5
6
UpdateValues(int X, int Y, op One, op Two)
{
      //eventually doing something like
      One(X, someOtherInt);
      Two(Y, someOtherInt);
}


What is going on?

Here is a link to my files if you need them https://www.dropbox.com/s/vn2akcyb9f448e6/Checkers.rar?dl=0
Last edited on
std::plus<int> is a class so I think you will have to construct an object, using parentheses.

 
op someOperator = std::plus<int>();

ops, sorry, I was already doing that, I just didn't include it in the code! What else could it be?
Last edited on
Make sure the code that you post actually exhibit the problem that you are having, becasue I have no problem with your code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <functional>

typedef std::function<int(int, int)> op;

op someOperator = std::plus<int>();
op someOtherOperator = std::minus<int>();

const int someOtherInt = 5;

void UpdateValues(int X, int Y, op One, op Two)
{
	std::cout << One(X, someOtherInt) << std::endl;
	std::cout << Two(Y, someOtherInt) << std::endl;
}

int main()
{
	UpdateValues(1, 2, someOperator, someOtherOperator);
}
Last edited on
You were right, the problem was somewhere else! Thanks a lot for your answer, in the end there were three separate things that kept generating that error:

I was passing an op object in place of a bool parameter
I was passing an op* object in place of an op parameter
I was passing an op object in place of an op* paramater
Topic archived. No new replies allowed.