C++ 17 features in Visual Studio 2015 with Clang

2020-07-27 03:30发布

问题:

This is a perennial question here, but: does anyone know if there is a way to get Visual Studio 2015, with the Clang tool chain installed (tab for "cross compilation") to enable the 2017 features that Clang itself normally supports?

For example, I would like this to compile:

constexpr bool test(bool a){bool b= false; b = b || a; return b;}
static_assert(test(true),"");

With Clang itself, version 3.7, from command line with --std=++1z, this will compile correctly, but Visual Studio C++ is not yet at the level of supporting the full range of constexpr function features. I had hoped that by cross compiling with Clang it would take them, but no luck. I see that under properties, I'm only able to enable up through C++ 14 -- is this the core problem? Namely that the visual studio parser itself at the IDE level can't yet understand the full constexpr functionality, even though the Clang compiler would actually compile it correctly?