3 ms·
If constexpr is not inspired by static if. In fact, proposals of static if and things like it were explicitly rejected by the committee.
by milesrout 10y ago
If constexpr is not inspired by static if. In fact, proposals of static if and things like it were explicitly rejected by the committee.
- eco 10y agoWalter, Andrei, and Herb proposed "static if" in N3329 (after it's big success in D) which was ultimately rejected. Ville Voutilainen explicitly revived it in N4461 with changes. Ville then iterated on that proposal a few times (P0128R0 and P0128R1). Finally, Jens Maurer took that and made some syntax changes with commitee input resulting in P0292R1 which was the accepted proposal. "static if" from D absolutely was the inspiration for "constexpr if". Each proposal references the last in a chain going back to Walter, Andrei, and Herb's proposal.
- lomnakkus 10y agoAFAICT, yes it was. Obviously, it wasn't accepted as-is, but it was certainly motivated (i.e. "inspired") by the success of "static if" in D.
- milesrout 10y agoI do not agree at all. It's very obvious functionality, and would be in D either way.
- lomnakkus 10y agoI'm not sure I understand what you're trying to say. IIUC the causality in your last sentence is opposite to what've you been arguing? Maybe it's just a typo, but either way you're going to have to provide evidence.
- milesrout 10y agoI meant 'would be in C++ either way', typo. C++ has been gaining constexpr features for years. These have nothing to do with D at all, except in the sense that all languages everywhere influence each other slightly. Certainly constexpr wasn't drawn directly from D. if constexpr was the obvious logical next step. It has been suggested and proposed for years. Yes people formally proposed static if, which was heavily inspired by D's static if, but that proposal was rejected because it was poorly designed, and C++'s new if constexpr is about as different as it's possible for two compile-time conditional compilation constructs to be.