5 ms·
Is this a baby version of dependent types?
by zingermc 7y ago
Is this a baby version of dependent types?
- riffraff 7y agoI believe contracts are checked at runtime, so not really.
- bluGill 7y agoContracts come in several forms. Some are checked at compile time. Some are checked at run time. Some the check is too expensive to actually run but is left for documentation. Compilers are expected to have a switch to turn off run time checking for production (just like assert)
- bigcheesegs 7y agoNothing in C++20 contracts requires any checking to be done at compile time. The only options currently required are runtime checking and no checking.
- bluGill 7y agoContracts were designed so that they can be checked statically. Pedantically you are correct: checking contracts is expected to be too expensive to actually do as part of a build. C++ expects that static analysis will check contracts as well (static analysis is might take 10 hours to check what compiles in 10 minutes)
- jcelerier 7y agoC++ already had a level of dependent types for a long time. template<int N> class T; constexpr int N = f(); T<N> var;