问题
I'm interested in studying the recently accepted contract programming for C++20 for learning and investigation purpose.
As I'm looking around for compiler support, I'm disappointed to not find any. Both gcc
and clang
are quite clear they do not support this feature within their --std=c++2a
mode.
Since the approval is pretty recent, I'm not too surprised that current compilers do not support the exact semantic proposed. What is more surprising to me though is that there is absolutely nothing, not even a compiler-specific extension which would mimic, even in a limited way, the same feature.
I was expecting the C++ committee to only consider features that have proven themselves on the field, typically through compiler or target specific extensions. Approving this feature for C++20 suggests that the feature should be accessible somewhere. But so far, I've been unable to find it.
Is there a way to experiment with C++ contract programming currently ? even using a set of compiler-specific extensions ?
回答1:
You might want to try this experimental implementation of contracts in Clang.
回答2:
The July 2019 WG21 meeting in Cologne agreed to remove contracts from the C++20 working draft. See proposal P1823 from Nicolai Josuttis here.
来源:https://stackoverflow.com/questions/53717956/c2a-contract-programming-and-compilers