Naz*_*nho 7 c++ templates visual-c++
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;
}
Run Code Online (Sandbox Code Playgroud)
与(3): error C2065: 'N': unknown identifier
(10): error C2975: 'V': invalid template argument 'A', constant expression expected(粗略翻译)。
clang默默地编译它。
那么问题来了:烂代码还是疯狂的 MSVC?
MSVC版本= VS 2019。