将 decltype 与虚拟成员函数指针一起使用
Using decltype with virtual member function pointers
将
decltype
与虚拟成员函数指针一起使用是否合法?
下面使用 VS2012 生成内部错误 (C1001)。
struct C
{
virtual void Foo() {}
typedef decltype(&C::Foo) type; //pointer
}
但这编译得很好:
struct C
{
virtual void Foo() {}
typedef decltype(C::Foo) type; //not pointer
}
这是一个错误吗?
MSVC 在decltype
成员函数指针方面存在多个已知问题;另请参阅将 decltype 与成员函数指针一起使用
这是合法语法;g++对此非常满意(http://ideone.com/sTZi6)。 标准中没有任何内容限制decltype
对成员函数的操作。
相关文章:
- 在将 new 与指针一起使用时,创建数组的指定长度
- 尝试将指针与结构一起使用时出错
- 为什么我们将 [ ] 与指向数组的指针一起使用?
- 如何将数组与指针一起使用?
- 将函数指针和对象放在一起
- 如何将 string.erase() 与指针一起使用?
- 将智能指针与容器一起使用的原因
- 为什么指针和c++中的函数放在一起
- 为什么当我尝试将priority_queue与参数一起使用作为指向结构的指针时会弹出错误
- __unaligned说明符何时与指针一起使用?
- 如何定义与将 Lambda 与捕获作为回调一起使用兼容的函数指针
- 是否可以将引用类型别名与指针运算符一起使用来声明对指针的引用?
- 为什么在将多态行为与指向接口的指针一起使用时没有调用析构函数?
- 自动关键字与智能指针一起
- 当直接分配时,为什么此功能指针分配起作用,而不是与有条件的操作员一起使用
- shared_ptr ::重置仅与原始指针一起使用
- 将 boost::function 与指向派生类的共享指针的参数一起使用
- 为什么在 sizeof() 函数中与 * 运算符一起使用和不使用 * 运算符时,指向结构变量的指针大小会有所不同?
- 为什么动态演员只能与参考和指针一起使用
- 是否可以将SDL2与智能指针一起使用