MSVC 在转发类模板声明中阻塞
MSVC chokes in forward class template declaration
MSVC 编译失败
#include <iostream>
template<int N, int = N>
struct A;
template<int, int V>
struct A{static constexpr int VALUE = V;};
int main() {
A<1> a;
std::cout << a.VALUE;
}
与(3): error C2065: 'N': unknown identifier
(10): error C2975: 'V': invalid template argument 'A', constant expression expected
(粗略翻译(。
叮当默编译。
那么,问题来了:烂代码还是痴呆的MSVC?
MSVC 版本 = VS 2019。
这是 MSVC 中的一个错误,在编译器版本 19.22 之前已经出现,并在 19.23 中修复。演示:https://gcc.godbolt.org/z/occvKEfc3
相关文章:
- 如何在 C++ 中转发声明 std::set?
- C++使用默认模板参数键入别名和转发声明
- 如何转发声明枚举?
- 使用函数指针转发声明作为 lamba 声明
- 如何将枚举类转发声明为模板化类的内部类?
- 转发声明在命名空间中不起作用的替代方法
- 如何正确转发声明结构"using XXX"?
- 在类内和类外的定义处执行类转发声明是否有区别
- 为什么转发声明的好友类不能在类中引用?
- 如何访问转发声明类的成员
- 仅在标头开发中转发声明
- 无法转发声明C typedef结构-正在查找其他建议
- boost::hana 转发声明标头的用例是什么?
- 循环包含依赖项/转发声明
- c++ 使用复杂的依赖项获取正确的转发声明
- 如何转发声明依赖于变量定义的类,而变体定义又依赖于模板化类?
- 完美转发使用结构化绑定声明的变量
- 如何声明接受转发引用并返回引用或副本的函数模板
- MSVC 在转发类模板声明中阻塞
- 在 cpp 文件中声明转发的类定义,干什么