C++ std::function declaration
Posted: Mon Jun 22, 2015 8:06 pm
First an apology as I think this is perhaps too off topic for OSDev but I would be happy for either an answer or a direct to a more relevant forum.
Having stepped into every pot hole on the road I no have a working kernel cross compiler and am working my way back to where I was about 2 months ago. I have chosen to implement using C++, which may turn out to be a poor choice in the long run but for now it is certainly exercising my limits.
I have just begun to use lambdas instead of explicit for or while loop and they have worked well in my hosted environment and I am now porting them across to the kernel which means I require some minimal headers to support these features.
So I have begun with <functional> and the very minimal content shown below which fails to compile giving an error saying the function is not a class template. I have looked for examples and explanations finding none that descibe this form of template declarations. Given it is a straight copy and severe trim of the declration from the GCC include file I am stumped.
It indicates, of course, that I do not really understand what is going on here, so I am trying to find the c++14 spec to read, but in the mean time is there a compiler switch I should use (doubtful) or is it clear that I have missed something that would allow a declaration of this form?
Having stepped into every pot hole on the road I no have a working kernel cross compiler and am working my way back to where I was about 2 months ago. I have chosen to implement using C++, which may turn out to be a poor choice in the long run but for now it is certainly exercising my limits.
I have just begun to use lambdas instead of explicit for or while loop and they have worked well in my hosted environment and I am now porting them across to the kernel which means I require some minimal headers to support these features.
So I have begun with <functional> and the very minimal content shown below which fails to compile giving an error saying the function is not a class template. I have looked for examples and explanations finding none that descibe this form of template declarations. Given it is a straight copy and severe trim of the declration from the GCC include file I am stumped.
It indicates, of course, that I do not really understand what is going on here, so I am trying to find the c++14 spec to read, but in the mean time is there a compiler switch I should use (doubtful) or is it clear that I have missed something that would allow a declaration of this form?
Code: Select all
template<typename _Res, typename... _ArgTypes>
class function<_Res(_ArgTypes...)>
: public _Maybe_unary_or_binary_function<_Res, _ArgTypes...>,
private _Function_base
{
...
}