小编deg*_*ong的帖子

Visual Studio 错误或 C++ 标准已更改?

#include <iostream>

template<typename T>
struct base {
    void hello() {
    }
};

template<typename T>
struct ttt : public base<ttt<T>> {
public:
    ttt() {
        hello();
    }
};

int main() {
    ttt<int> t();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我使用 c++ 17 或 11 时,这段代码就可以了。但是当我将 c++ 标准设置为 20 时,发生的 C3816 错误说找不到 hello 函数,我对原因感到困惑,为什么这个错误直到 c++ 20 才会出现。

c++ c++20 visual-studio-2017 visual-studio-2019

1
推荐指数
1
解决办法
212
查看次数