When T
is double(float)const
I get this error when I try to use function<T>
.
implicit instantiation of undefined template 'std::function<double (float) const>'
But it's OK when T
is double(float)
. I tried to use std:: remove_cv<T>::type
to remove this const
, but that doesn't work. And yes, I have #include<functional>
.
So my main question is: How to fix this and remove const
so that I can put this function type into std:: function
.?
I came across this issue when working with the operator()
method of lambdas, but I think this question is generally about any method type, not just for lambdas
But my second question is: What does double(float)const
even mean ?!! I can understand
double (ClassName::) (float) const
as it means the member function cannot modify its ClassName
object. When I put this type into a template to remove the class type, then I get the double(float)const
which is causing trouble.
template<typename>
struct DropClassType;
template<typename Sig, typename C>
struct DropClassType<Sig (C::*)> {
typedef Sig type_without_class;
};
(clang 3.4.2. The errors from g++-4.9.1 are more cryptic, but basically the same)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…