Click here to Skip to main content
14,930,183 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error which I am getting

'template argument 1 is invalid'
   std::function<AbstractStrategyHelper*(AbstractStrategy*)> strategyHelperAccessor;
'std::function’ is not a type
   void setStrategyHelperAccessor(std::function<AbstractStrategyHelper*(AbstractStrategy*)> f);


In this line of code

void setStrategyHelperAccessor(std::function<AbstractStrategyHelper*(AbstractStrategy*)> f);


What I have tried:

Why am I getting this error and how to fix it?
Posted
Updated 22-Dec-20 13:47pm
v2
Comments
Richard MacCutchan 22-Dec-20 10:25am
   
Where are AbstractStrategyHelper and AbstractStrategy declarde, and what are they.
Dev Parzival 22-Dec-20 10:33am
   
They are abstract classes.
Dev Parzival 22-Dec-20 10:38am
   
I have include the above classes and functional headerfile as well
Richard MacCutchan 22-Dec-20 10:43am
   
I just compiled that using Windows C++ compiler and it works. There must be something else in your code that is causing the problem.
Dev Parzival 23-Dec-20 0:37am
   
@Richard MacCutchan thanks, am trying to find where I am doing mistake.
Richard MacCutchan 23-Dec-20 6:00am
   
There is other information which you are not showing here.

1 solution

Include this header for std::function.
C++
#include <functional>
   
Comments
Dev Parzival 22-Dec-20 20:10pm
   
I have included this header file
Shao Voon Wong 22-Dec-20 22:55pm
   
Then your error in your post is misleading. Please include the actual error messages.
Shao Voon Wong 22-Dec-20 23:05pm
   
Your code looks fine. The problem could be the compiler cannot find the class declaration/definition you supplied to std::function.
Dev Parzival 23-Dec-20 0:38am
   
@Shao Voon Wong thanks for helping {:)I am trying to find what mistake I am doing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900