TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

C++ : if constexpr isn't broken

74 点作者 Bl4ckb0ne超过 6 年前

8 条评论

roywiggins超过 6 年前
"a somewhat more awkward and uglier, yet slightly more correct way... all the functionality is right there. We’re not missing anything" might as well be C++'s motto :)
评论 #18912999 未加载
评论 #18913249 未加载
评论 #18916059 未加载
评论 #18914165 未加载
JabavuAdams超过 6 年前
I used to be a C++ guy from the early 90s &#x27;till about 2010. Every few months, I think &quot;I should really learn the new C++ hotness&quot;, and then I read something like this. It&#x27;s like a bunch of priests arguing about how best to fit a bunch of ugly angels on a pointless pin. It just feels so pointless.<p>If you must use C++, just use another language to generate the C++. All this template mumbo jumbo. Who says your meta-programming language has to be the same as your target language?<p>I used to spend some time looking for the perfect vector (as in linear-algebra) library. Templatized for vector dimension, data-type, blah blah blah. Dude, just use Python to generate it. Duplication doesn&#x27;t violate DRY if the duplication is generated from a single higher-level source.<p>Doing meta-programming in C++ is a really limited way of thinking.
评论 #18917687 未加载
评论 #18915144 未加载
评论 #18915261 未加载
mattnewport超过 6 年前
I had similar thoughts when looking through the slides for Andrei&#x27;s talk. A main argument in favor of static if over the mechanisms C++ offers to do the same things seems to be familiarity of if statements but having scope not be respected is such an unintuitive difference for anyone with experience in curly braces languages that it seems like a net loss in clarity to me. It looks more like using macros for conditional compilation.<p>Overuse of if statements is generally something of a code smell and tends to make code harder to follow. To my taste the C++ way of doing things is generally preferable as a result even if more verbose. Given this is probably somewhat a matter of taste it is hard to justify changing C++ to match the D way IMO.
mark-r超过 6 年前
Why is it every time I see a new article about C++ features my eyes glaze over? Am I just getting old, or has C++ jumped the shark?
评论 #18913286 未加载
评论 #18913065 未加载
评论 #18914154 未加载
wyldfire超过 6 年前
Slides from Alexandrescu&#x27;s referenced talk [1].<p>[1] <a href="http:&#x2F;&#x2F;erdani.com&#x2F;MeetingC++2018Keynote.pdf" rel="nofollow">http:&#x2F;&#x2F;erdani.com&#x2F;MeetingC++2018Keynote.pdf</a>
cjhanks超过 6 年前
I agree with this blog writer. Allowing typedefs to cross static if boundaries would be a major change to the way I read code. Unless there&#x27;s a more substantive example demonstrating why using the existing metaprogramming is insufficient, its benefits are imo outweighed by its cost.
评论 #18918802 未加载
choeger超过 6 年前
Oh my. If only C++ would have used proper macros from the start...
评论 #18914306 未加载
评论 #18914219 未加载
greesil超过 6 年前
I think I just got used to C++11. What is this dark magic?
评论 #18912929 未加载
评论 #18913142 未加载