Wie aktiviere ich C++ 17 in Xcode (9.4.1) unter OSX High Sierra (10.13.5)?
Schritte zur Verwendung von C++ 17 in Xcode (9.4.1) unter OSX High Sierra (10.13.5):
Überprüfungsschritte:
Wenn ich jetzt __cplusplus ausgebe, sehe ich 201703 und kann C++ 17-Funktionen kompilieren, z. B. constexpr.
template<class T>
int compute(T x) {
if constexpr( supportsAPI(T{}) ) {
// only gets compiled if the condition is true
return x.Method();
} else {
return 0;
}
}
int main(){
cout << __cplusplus << endl;
return 0;
}
Ausgabe:
201703
Program ended with exit code: 0