简体   繁体   中英

Constrained auto doesn't work for msvc function parameters?

I have decided to go all out and use C++ 20's concepts in a library I am starting.

I have tested the following code on GCC trunk and it runs just fine, however fails on MSVC 16.5.4 with C++20 enabled. Is this feature not confirmed by the standard, has it not been implemented yet, or is my version out-of-date>

Thanks!

#include <concepts>

void myFunc(std::integral auto value)
{
    value += 1;
}

int main()
{
    myFunc(1);
    return 0;
}

MSVC's compiler, as of 19.28 doesn't support constrained auto.

Live example .

Note that the compiler version is independent of the MSVC suite version. The compiler major version indicates an ABI change, and minor an improvement. The suite version is more tied to marketing-ish releases.

Constrained auto did make it into the standard (not a primary source, but 99.9% reliable).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM