当
但当T为double(float)时,这没关系。我尝试使用std::remove_cv::type来移除这个const,但是不起作用。是的,我已经包含了#include。
所以我的主要问题是:如何修复并删除const,以便我可以将此函数类型放入std :: function中?
在处理lambda的operator()方法时,我遇到了这个问题,但我认为这个问题通常适用于任何方法类型,而不仅仅是lambda。
但我的第二个问题是:double(float)const甚至是什么意思?! 我可以理解
(clang 3.4.2。来自 g++-4.9.1 的错误更加神秘,但本质上相同)
T
是 double(float)const
时,我在尝试使用 function<T>
时遇到了这个错误。implicit instantiation of undefined template 'std::function<double (float) const>'
但当T为double(float)时,这没关系。我尝试使用std::remove_cv::type来移除这个const,但是不起作用。是的,我已经包含了#include。
所以我的主要问题是:如何修复并删除const,以便我可以将此函数类型放入std :: function中?
在处理lambda的operator()方法时,我遇到了这个问题,但我认为这个问题通常适用于任何方法类型,而不仅仅是lambda。
但我的第二个问题是:double(float)const甚至是什么意思?! 我可以理解
double (ClassName::) (float) const
这意味着成员函数不能修改其 ClassName
对象。当我将此类型放入模板中以删除类类型时,我得到了 double(float)const
,这可能会引起麻烦。
template<typename>
struct DropClassType;
template<typename Sig, typename C>
struct DropClassType<Sig (C::*)> {
typedef Sig type_without_class;
};
(clang 3.4.2。来自 g++-4.9.1 的错误更加神秘,但本质上相同)
std::function
对象。只需在lambda表达式上运行decltype(&T::operator())
,就会返回一个类型,但需要从该类型中删除类类型和奇怪的const
。谢谢! - Aaron McDaid