我有a small program在 GCC
上编译,但在 MSVC
上编译,哪个编译器不遵循 constexpr string_view
比较标准?
#include <iostream>
#include <string_view>
int main(int argc, char **argv) {
const constexpr auto a = "z";
const constexpr std::string_view test("z",1);
const constexpr std::string_view test2(a,1);
if constexpr(test == test2) {
return 5;
}
else{
return 2;
}
}
最佳答案
C++17 constexpr if
语句 are supported since MSVC 19.11 .
在报错信息中我们可以看到,Compiler Explorer目前使用的是19.10.25017版本。
关于c++ - constexpr string_view 比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49776429/