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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

C++ 20: The Core Language

282 点作者 juice_bus超过 5 年前

20 条评论

gumby超过 5 年前
I&#x27;m glad this hasn&#x27;t turned into (so far) the usual &quot;c++ is dumb&quot; flame fest.<p>I&#x27;ve really enjoyed programming in c++17 for the last three years (I had the luxury of starting from an empty buffer) and find the language pretty expressive. If you are able to use it as a &quot;new&quot; language, ignoring its C roots and features that exist pretty much just for back compatibility, it&#x27;s really quite expressive, powerful, and orthogonal.<p>I&#x27;m actually pretty glad the c++ committee has been willing to acknowledge and deprecate mistakes (e.g. auto_ptr), to squeeze out special cases (e.g. comma in subscripting) and to attempt to maintain generality. Conservatism on things like the graphics standard is reducing the chance of the auto_ptr or std::map mistakes.
评论 #21457219 未加载
评论 #21455898 未加载
评论 #21458156 未加载
评论 #21455883 未加载
评论 #21457505 未加载
评论 #21456318 未加载
DoofusOfDeath超过 5 年前
In commercial settings, I encounter several barriers to using C++ versions newer than 2011:<p>(1) Most C++ code <i>I</i> encounter is C++11, and I deal with lots of projects. It&#x27;s rarely sensible to change the language version of a large code base without a very good reason.<p>(2) Many developers are well-familiar with C++11.<p>(3) There&#x27;s no <i>widespread</i> perception that C++14 or later bring compelling language improvements.<p>(4) Some (most?) C++11 developers are already uneasy with the complexity of C++11, and aren&#x27;t eager to incur the learning curve and (perhaps) new set of pitfalls associated with newer C++ versions.<p>(5) Some C++11 developers look at the language trajectory, especially in terms of complexity, and have decided that their next language(s) will be e.g. Rust or Julia instead of C++14, C++17, etc.<p>I suspect these factors all contribute to the momentum that C++11 seems to have.
评论 #21455218 未加载
评论 #21454708 未加载
评论 #21454948 未加载
评论 #21454931 未加载
评论 #21455334 未加载
评论 #21455284 未加载
评论 #21454923 未加载
评论 #21454895 未加载
评论 #21457706 未加载
评论 #21455035 未加载
评论 #21457136 未加载
评论 #21460135 未加载
lasagnaphil超过 5 年前
Right now my biggest things I like from C++20 are:<p>- Concepts (Now I can use static polymorphism without all those SFINAE template hacks)<p>- Designated Initializers (Finally!!! Using POD structs became way more convenient now)<p>- Coroutines (Would be pretty nice for writing games &#x2F; interactive applications)<p>The things I don&#x27;t have any interest in (but don&#x27;t care if it&#x27;s in or not)<p>- Ranges (Too much complexity for something you could do with plain old for&#x2F;if loops...)<p>The things I&#x27;m worried about:<p>- Modules (Theoretically really good, but in practice the whole thing is starting to become a mess, especially when it&#x27;s interacting with the preprocessor and external libraries, and when trying to preserve backward compatibility.)
评论 #21454616 未加载
评论 #21455710 未加载
评论 #21460741 未加载
rosshemsley超过 5 年前
Features I wish C++20 had:<p>* An opinionated, modern packaging and dependency story (like go modules, Rust crates)<p>* built-in library support for logging, http, zip, gzip, json, yaml, template rendering, RFC3339 datetime reading&#x2F;writing<p>* the dream: compliant compilers must be able to compile down to static binaries, cross compiling built-in.<p>Features C++20 actually has:<p>* new fancy spaceship operator that I&#x27;ll now have to learn and never use...
评论 #21458056 未加载
评论 #21457429 未加载
评论 #21460102 未加载
评论 #21457868 未加载
gumby超过 5 年前
On thing I appreciate is mdspan -- multidimensional projections onto a regular linear vector. I&#x27;ve always had to spin these myself which means they don&#x27;t fully participate as ordinary containers (who&#x27;s going to go tho all that work for their own application code).<p>I&#x27;m hoping I can map them into GPU space -- looks like the standard has adequate control for this.
评论 #21456957 未加载
评论 #21457227 未加载
afranchuk超过 5 年前
I&#x27;ve been anxiously awaiting modules and concepts. Both are incredibly important to reduce developer burden and improve the development experience.<p>Modules: While it is important to be able to fine-tune linking and compilation in some settings, in most, and especially for beginners, this should be handled by the compiler. Especially when compared to other modern languages, C++ is much more complex to understand the toolchain and what&#x27;s going on under the covers with the dichotomy of compilation and linking. Header files were a hack that have been around for too long, and there needs to be less separation between the interface and actual binary code when compiling. This is a headache both for novices and the experienced.<p>Concepts: The missing link for templates. Besides removing some of the roundabout-ism of SFINAE by providing compile-time verifiable interfaces, I think the biggest benefit of concepts will be the error messages. Right now, the state of errors in heavily templated code is abysmal, and this translates to a lot of wasted time for developers. Concepts should allow the errors to indicate exactly what&#x27;s wrong.<p>I can&#x27;t wait to be able to use these in public code. Some compilers support concepts with a flag already (and GCC 10 has it without the special flag), though none support modules yet...
dgellow超过 5 年前
Could someone describes the keyword &quot;unlikely&quot; and &quot;likely&quot; in a bit more details? It seem to be a very niche thing to add to the language. Is it expected that those hints will have an impact important enough regarding what the optimizer can do?
评论 #21455091 未加载
评论 #21455140 未加载
评论 #21455174 未加载
评论 #21455596 未加载
评论 #21456256 未加载
评论 #21455012 未加载
beezle超过 5 年前
Been away from C++ a long time. If picking it up again, is it better to just start with C++17 or 20 or stick to C++11 which seems to be the defacto production version?
评论 #21456144 未加载
评论 #21456408 未加载
Ididntdothis超过 5 年前
I haven’t done C++ a while but I really like where this is going. It’s a complex language for sure but I always liked about it that whatever needed to be done the language would not get in the way. There is something to be said for working in the language your OS and a lot of other libraries are written with. You know that you have high probability of achieving what you need to do. It may need a lot of work though.
gumby超过 5 年前
With consteval (and its cousins), std::source_location and modules you could pretty much compile C++ without the preprocessor. Hooray!
评论 #21457702 未加载
CoolGuySteve超过 5 年前
Hopefully between consteval and string literal template parameters, we&#x27;ll be able to detect literal const char* in templates.<p>Would be nice for my threaded logger to know if it can copy the pointer instead of the whole string, knowing it was initialized statically.
评论 #21457414 未加载
eyegor超过 5 年前
Is there a good &quot;tutorial for modern c++&quot; resource out there? The last c++ I used heavily was c03 and a sprinkle of c11. I find reading modern c++ to be somewhere between frustrating and an exercise in hieroglyphics thanks to how much it&#x27;s changed. Something along the lines of &quot;basics of why to use the different std pointers&#x2F;views instead of raw pointers&quot;, lambdas, all the new const-like bits, and whatever else have become &quot;core&quot; features.
评论 #21458692 未加载
评论 #21459679 未加载
DeepYogurt超过 5 年前
I&#x27;m not sure I grok the `&lt;=&gt;` operator and the example they show seems to just show that `a == b`. Can someone explain what&#x27;s going on with that?
评论 #21454359 未加载
评论 #21454577 未加载
评论 #21454545 未加载
shaklee3超过 5 年前
This book is worth checking out if you don&#x27;t know c++17:<p><a href="https:&#x2F;&#x2F;www.bfilipek.com&#x2F;2018&#x2F;08&#x2F;cpp17indetail.html?m=1" rel="nofollow">https:&#x2F;&#x2F;www.bfilipek.com&#x2F;2018&#x2F;08&#x2F;cpp17indetail.html?m=1</a><p>That guy has a great blog where he writes at length about each feature, and the book is a compilation of that.
sharpneli超过 5 年前
Some parts of C++20 are really good, like most of what is stated in the article.<p>But C++ would not be C++ if it had no shenanigans coming. Unless they have changed things within some months the new calendar&#x2F;datetime library is hilarious.<p>It has features like being able to write a date like: 1&#x2F;2&#x2F;2000y. ooh fancy operatoe overloading. Which one is month? The first one ofcourse as it they didn’t standardize on any of the existing ISO standards, or allow you to choose, but selected ”Customary US way” as the Only True C++ Way(tm).<p>Also do not forget the abuse of operator overloading like in the good 90’s when misusing it was the recommended thing.
评论 #21456947 未加载
评论 #21457289 未加载
评论 #21456690 未加载
EamonnMR超过 5 年前
Are there any quality tutorials for learning C++17 for basic tasks? Much &quot;how do I do X in C++&quot; is very outdated from that perspective.
评论 #21456654 未加载
glouwbug超过 5 年前
Did modules make it?
评论 #21454543 未加载
gridlockd超过 5 年前
Why &#x27;basic_fixed_string&#x27;? Is it really <i>so basic</i> that it has to be mentioned in the name? Is it just in case there might be a &#x27;fixed_string&#x27; that isn&#x27;t quite as basic, in the future?
评论 #21456383 未加载
xvilka超过 5 年前
C++ should adopt Rust-like approach on deprecating things faster and a tools like `cargo fix`&#x2F;`cargo clippy --autofix` to automatically fix&#x2F;suggest more modern alternative to the deprecated language constructions.
评论 #21459554 未加载
lacampbell超过 5 年前
What are people using C++ for in 2019? Last time I used it was for a Qt desktop application of all things. I would imagine its main usage is in high performance or hardware constrained environments these days, but I&#x27;m curious what people are doing with it.<p>I do a lot of node.js programming, which uses C++ to write extensions, so here&#x27;s hoping I rememeber it if&#x2F;when I need to.
评论 #21457295 未加载
评论 #21459344 未加载
评论 #21457261 未加载