C 11 decltype成员
发布时间:2020-12-16 09:54:34 所属栏目:百科 来源:网络整理
导读:为什么我不能这样做: class Foo { void fn(); using fn_t = decltype(fn); //call to non-static member function without an object argument}; 但我能做到 class Foo { static void fn(); using fn_t = decltype(fn);}; This SO post声称: Within uneval
为什么我不能这样做:
class Foo { void fn(); using fn_t = decltype(fn); //call to non-static member function without an object argument }; 但我能做到 class Foo { static void fn(); using fn_t = decltype(fn); }; This SO post声称:
解决方法
fn是表示非静态成员函数的有效id-expression. §5.1.1[expr.prim.general] / p13(省略脚注):
§7.1.6.2[dcl.type.simple] / p4:
由于decltype不是可以使用表示非静态成员函数的id表达式的少数上下文之一,因此该程序是不正确的. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |