Click here to Skip to main content
15,867,704 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.
Udesh-Ranjan 22-Dec-20 10:33am    
They are abstract classes.
Udesh-Ranjan 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.
Udesh-Ranjan 23-Dec-20 0:37am    
@Richard MacCutchan thanks, am trying to find where I am doing mistake.

1 solution

Include this header for std::function.
C++
#include <functional>
 
Share this answer
 
Comments
Udesh-Ranjan 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.
Udesh-Ranjan 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