Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If constexpr is not inspired by static if. In fact, proposals of static if and things like it were explicitly rejected by the committee.


Walter, 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.


AFAICT, 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.


I do not agree at all. It's very obvious functionality, and would be in D either way.


I'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.


I 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.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: