为什么"if constexpr"无法使用Visual Studio 2017 15.3编译?

Ale*_*nko 8 c++ c++17 visual-studio-2017

根据本文档if constexpr,C++ 17引入的语法应该与/std:c++14编译器开关一起使用:C++ 17 Visual Studio 2017版本15.3预览版中的功能.

但是,它不起作用.而是生成以下编译器错误:

错误C4984:'if constexpr'是C++ 17语言扩展

文档错了吗?

如果是这样,如何if constexpr在Visual Studio 2017 15.3中编译?

Ale*_*nko 10

看起来问题中链接的文档在这里是不准确的.

if constexpr在Visual Studio 2017中使用,您需要使用/std:c++17/std:c++latest切换进行编译.