5 ms·
For those who wants to know c++17 features http://stackoverflow.com/questions/38060436/what-are-the-new-features-in-c17 http://stackoverflow.com/questions/3806
by asitdhal 10y ago
For those who wants to know c++17 features
http://stackoverflow.com/questions/38060436/what-are-the-new-features-in-c17 http://stackoverflow.com/questions/38060436/what-are-the-new...
std::optional and std::any are one of the good things. std::apply and std::invoke can help you write better functional c++17 code.
Anyway thanks for C++17. For sometime, I thought I will learn Rust.
- stinos 10y agoThat SO question has barely any code examples but mostly links to sometimes quite technical documents. I'd really love to see a comprehensive list of all features (if possible c++11, 14 and 17) together with small explanation + code samples: even though I am already using a lot of the new features I still feel like I'm missing out on certain things just because I don't know they exist and because the information is shattered. (e.g. I'm fairly sure SO has Q&A on like every new feature, but it would take an insane amount of time to go through every question tagged [c++17]).
- asitdhal 10y agoI don't know if similar things existed for C++11/14. But, it doesn't exist for C++17. I faced the similar problem. I invested some money in Effective Modern C++(Scott Mayer). It covers the language part. I borrowed a book for C++11 concurrency. But, modern C++ lacks high-quality material at one place like Golang/Rust(the language guys have very good documentation, not boring and good enough to learn quickly). There are tons of scattered example.
- surye 10y agohttps://github.com/tvaneerd/cpp17_in_TTs/blob/master/ALL_IN_ONE.md https://github.com/tvaneerd/cpp17_in_TTs/blob/master/ALL_IN_... This comes pretty close to what you're asking for I believe.
- stinos 10y agoYes, thanks, that's bascially the sort of thing I was looking for!
- brcha 10y agocppreference.com usually has [c++XYZ] marks on features introduced by a specific version of C++ and it is usually current with updates while having some basic examples for most things. The site doesn't have a comprehensive list of all the features introduced in the specific version of C++, but which ever feature is interesting to you should be easy to find there.
- tmyklebu 10y agoIn modern gcc, std::variant doesn't look like a competent replacement for old-fashioned tagged unions. On x86_64 Linux, it looks like a function with signature `void f(std::variant<int, char>)` expects its (8-byte) argument to be passed by reference, whereas `void f2(tagged_union_of_int_and_char)` passes its argument in rdi. gcc (-O3) also generates miserable code for calling f(42): 4004f0: 48 83 ec 18 sub $0x18,%rsp 4004f4: 48 89 e7 mov %rsp,%rdi 4004f7: c7 04 24 2a 00 00 00 movl $0x2a,(%rsp) 4004fe: c6 44 24 04 00 movb $0x0,0x4(%rsp) 400503: e8 c8 ff ff ff callq 4004d0 <f> 400508: 48 83 c4 18 add $0x18,%rsp 40050c: c3 retq as compared with calling f2(42): 400510: 48 bf 00 00 00 00 2a movabs $0x2a00000000,%rdi 400517: 00 00 00 40051a: eb c4 jmp 4004e0 <f2> std::optional seems to have the same disease; the ABI is different from a plain struct containing a bool and the value and you get worse initialisation code. There's also a build time penalty to using std::optional; on my machine, including the code that uses optionals makes my trivial test program take 320ms to compile and link rather than 50ms. These look like yet more new C++ features that are worse than what they're trying to replace.
- Sharlin 10y agoEh, I get that one of the points of C++ is to minimize abstraction penalty even when you do use abstractions, but these things are compromises. In almost all real-world software development the advantages of abstraction far outweigh micro-optimizations that shave off individual cycles...
- tmyklebu 10y agoWriting ad-hoc tagged unions and two-element 'optional' structs is a completely straightforward mechanical task---exactly the sort of thing that a programming language ought to automate. Why does there need to be a "compromise" between boilerplate and performance here? Why should I have to pay performance to use standard tagged unions and optionals, or conversely, pay by writing boilerplate in order to get performance?
- wolf550e 10y ago
- poland2 10y agoI hope c++20 will be c++18 :)
- adrift 10y agoDon't worry, it won't be.
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- YZF 10y agoThis has been in Boost for a while now so doesn't really change much.