Bomaz
Bomaz

Reputation: 1961

Constexpr string_view comparison

I have a small program that compiles on GCC but not on MSVCwhich compiler isn't following the standard for constexpr string_view comparison?

#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;
    }
}

Upvotes: 1

Views: 8053

Answers (1)

O&#39;Neil
O&#39;Neil

Reputation: 3849

C++17 constexpr if statements are supported since MSVC 19.11.

We can see in the error message that Compiler Explorer currently uses version 19.10.25017.

Upvotes: 3

Related Questions