constexpr string_view 比较

Constexpr string_view comparison

我有 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版本。