
C++17 Standard Published - whack
https://www.iso.org/standard/68564.html
======
snarfy
This summary has been helpful for me:

C++17 [https://github.com/AnthonyCalandra/modern-cpp-
features/blob/...](https://github.com/AnthonyCalandra/modern-cpp-
features/blob/master/CPP17.md)

17/14/11 [https://github.com/AnthonyCalandra/modern-cpp-
features](https://github.com/AnthonyCalandra/modern-cpp-features)

------
mratzloff
I can't even imagine the amount of work that goes into producing a
specification like this, BUT... I wish there were a reduced price option for
individuals. I just can't justify spending USD 200 on getting a copy for
myself. I'd love to have a copy so I don't have to rely on second-hand sources
like websites and implementation details from STL maintainers on Reddit or
Stack Overflow.

~~~
m-ou-se
You can build the pdf yourself from the LaTeX source:
[https://github.com/cplusplus/draft](https://github.com/cplusplus/draft)

Or get the latest public draft from
[https://wg21.link/standard](https://wg21.link/standard)

Or an html version: [http://eelis.net/c++draft/](http://eelis.net/c++draft/)

~~~
mratzloff
Thanks. I just like having an official (not draft) copy. I'm a nerd.

I just built from the LaTeX source and it's 32 pages longer than the public
draft in the second link from 6 weeks ago. Maybe just additional descriptive
language, but...

~~~
Someone
Reading
[https://github.com/cplusplus/draft](https://github.com/cplusplus/draft), it
seems you had to generate figures from their dot source.

If so, the result may depend on your installation (probably even if you use
the same version of GraphViz but a different OS and/or set of fonts), and that
can affect pagination.

Also, are you sure you built for the same paper size? A4 vs US letter could
explain the difference.

~~~
mratzloff
Well, you can see changes as recently as two days ago.

[https://github.com/cplusplus/draft/commit/83e302d3bb6a5f8855...](https://github.com/cplusplus/draft/commit/83e302d3bb6a5f88554b1ec75e8aa51760458c5f)

------
prewett
Do any of the standard's people read HN, or is there a way of submitting
requests? The STL could seriously use some improvements. std::string doesn't
do most of the stuff you want with a string; updating it to an interface like
Python's string would be nice. Having a std::vector::append() would be really
nice, so I don't have to remember that C++ uses something completely different
from every other language. Convenience things like std::set::contains() would
be nice because s.find() != s.end() is not very readable compared to
contains().

I'm really impressed at what the standards committee has done, but I'm
wondering if we ought to start thinking about a C++2.0 where we can write the
C++ that we've learned we want. The poor young-uns learning C++ still have to
learn all the old stuff, because otherwise it will bite them sooner or later.

~~~
cbsmith
Why Python string class? The Python 2 one or the Python 3 one? ;-)

String classes are fickle things. It's very hard to get them right. Still,
std::string, for all of its age, does let you do a lot of what Python does
with manipulation of bytes, particularly when combined with locales
(admittedly painful to use) and iostreams (also a bit painful at times).

Python does have a LOT of other functionality tied into strings, but there's a
legit design question as to whether that's really a good idea or not. What
particular functionality do you think ought to be there?

~~~
prewett
Python only because it's the string class that I've used that always has
everything I need. QString from Qt is pretty good, too. std::string is, like
you say, painful. Since QString exists, works great with a long history, so
why is std::string so limited? Design-wise, I'd say the few changes which
QString has had demonstrates the solidity of the design.

Off the top of my head, what I use frequently (and which is unavailable in
std::String) is:

\- replace(search, new). std::string can do it, but first you have to find the
index of the start, then you call replace() to replace a set of bytes. Too low
level.

\- endswith() and beginswith() are surprisingly helpful. endswith() in
particular. s.index("prefix") == 0 is pretty clear, but s.index("suffix") ==
s.size() - "suffix".size() is not very clear.

\- toupper()/tolower()/isspace()/isslanum()/isupper()/etc. are not something
you use every day, but you really don't want to have to write proper handling
of every language's idiosyncracies yourself, and it's not worth it to find a
library, so probably only European languages will work initially.

\- proper unicode handling. std::wstring (UTF16) is not it (to be fair, that
wasn't clear at the time of design), plus I don't think it works well with
either Microsoft's or Apple's UTF16

\- making a string from a number. QString does this well, Python 2's str(num)
is not really flexible enough. I don't want to have to create a stringstream
just because I need a numeric string.

\- create a string from a printf list. I know stringstream is supposed to do
that, but I never seem to be able to do exactly what I want (e.g. %.3f), and
regardless, I never can remember the correct syntax for the modifiers (e.g.
hex(), precision()), despite it appearing like it ought to be obvious.

I pretty much expect all the above in a string. std::string is basically a
veneer over an array of bytes. Maybe that was okay in 1998 when it was
designed, but the first thing I have to do is add all that in now, every time
I do anything UI-related with text.

I also would like split(), it makes simple parsing a lot easier.

------
75dvtwin
Seems like the meta-language (compile-time expressions) is now pretty much
full fledged.

Long gone days where template meta-programming was the only way to do compile-
time code generation and constant checks.... at least that's my impression of
the latest language-level features.

I have not worked professionally with c++ for a few years now, but his piece
from the article, just seems rather powerful incarnation of the compile-time
programming.

    
    
      constexpr auto add = [] (int x, int y) {
        auto L = [=] { return x; };
        auto R = [=] { return y; };
        return [=] { return L() + R(); };
      };

~~~
wtarreau
Bah what an horror. I doubt anyone can spot a more unreadable language (except
maybe brainfuck).

One of the issues I have with C++ is that they seem to have used basically all
the symbols you can find on a keyboard to create unspellable operators or
modifiers, and since they didn't have enough to avoid colliding with C, they
mixed them to create even more unreadable combinations. The other examples in
the doc are good readings as well suggesting I never approach this "modern
art".

~~~
krylon
I think the reason is that adding new keywords to the language always means
the risk of breaking somebody's code.

I can see why a standardization body would want to avoid that, even though I
agree wholeheartedly the result is not pretty.

------
nly
The way coroutines are implemented in C++17 is just beautiful. Minimal
language changes, compatible down to C function pointers and void*, and
extensible to almost any existing asynchronous library via trait
specialisation.

~~~
mattbierner
Didn’t coroutines get pushed out to at least c++20?

~~~
nly
Yeah, technically it's a TS, but it's live in MSVC 2015/17 and Clang 5.0

------
cominous
C++17 is a slight disappointment, I hope C++20 will be the real deal -
concepts could really be a game changer and move semantics needs more fixes
:/.

~~~
mratzloff
It's not as major of an update as previous releases, but there are a lot of
little convenience features.

String views, same-line nested namespaces, [[fallthrough]], if with init (I'm
sure Google single-handedly got this included; it's very Go-reminiscent and
really nice when not using exceptions), structured bindings, maybes with
std::optional (occasionally useful), and even just something as simple as
emplace returning a reference.

What fixes do you think std::move needs, out of curiosity?

~~~
cominous
Its not std::move, but the complexity coming with it. Its a hassle applying
move semantics correctly and there is not the one goto solution for simple
things. Im not aware of a proposal to change that issue, but at least there
should be better defaults.

This talk explains the pain quite well:
[https://www.youtube.com/watch?v=PNRju6_yn3o](https://www.youtube.com/watch?v=PNRju6_yn3o)

~~~
repsilat
The amount of prayer I have put into RVO and moves happening "right"... As
someone who isn't a C++ programmer, is there anything better than looking at
annotated asm? Templating everything and trying it with something that isn't
copyable? (Actually, would that even work with RVO?)

~~~
jcelerier
> As someone who isn't a C++ programmer, is there anything better than looking
> at annotated asm

put a debug breakpoint in the move constructor and run your tests :p

------
HalcyonicStorm
Can someone kindly post links or books for a beginner to dive into learning
C++? It is a bit intimidating to approach fresh.

~~~
parasight
I'd recommend to choose one of these two books:

Programming: Principles and Practice Using C++, 2nd Ed., Bjarne Stroustrup
[https://www.amazon.com/Programming-Principles-Practice-
Using...](https://www.amazon.com/Programming-Principles-Practice-
Using-2nd/dp/0321992784/ref=pd_sim_14_3?_encoding=UTF8&pd_rd_i=0321992784&pd_rd_r=DESRRXNFC61DR4BDRFY2&pd_rd_w=ykzg4&pd_rd_wg=9Nllh&psc=1&refRID=DESRRXNFC61DR4BDRFY2)

C++ Primer, 5th Ed., Stanley Lippman [https://www.amazon.com/Primer-5th-
Stanley-B-Lippman/dp/03217...](https://www.amazon.com/Primer-5th-Stanley-B-
Lippman/dp/0321714113/ref=pd_sim_14_7?_encoding=UTF8&pd_rd_i=0321714113&pd_rd_r=DESRRXNFC61DR4BDRFY2&pd_rd_w=ykzg4&pd_rd_wg=9Nllh&psc=1&refRID=DESRRXNFC61DR4BDRFY2)

For a very brief introduction:

A Tour of C++, Bjarne Stroustrup [https://www.amazon.com/Tour-C-
Depth/dp/0321958314/ref=sr_1_1...](https://www.amazon.com/Tour-C-
Depth/dp/0321958314/ref=sr_1_1?ie=UTF8&qid=1512544081&sr=8-1&keywords=C%2B%2B+tour)

~~~
sn9
Here's more info regarding book recs: [https://isocpp.org/wiki/faq/how-to-
learn-cpp#best-book](https://isocpp.org/wiki/faq/how-to-learn-cpp#best-book)

------
w8rbt
Awesome news. Long live C++ ;)

------
wasx
Awesome news. gcc has had experimental support for C++17 for a while now, any
idea on a potential time frame for it to move from experimental to final
standards compliant?

------
vadimberman
Really, UTF literals only now?

~~~
cbsmith
Nope. They just got a minor update.

~~~
vadimberman
Are my eyes failing me?

> C++17 includes the following __new __language features:

> ...

> utf-8 character literals

> ...

> char x = u8'x';

~~~
cbsmith
C++11 introduced utf-8 encoded string literals. However, when the parser was
reading the characters in the literal, they were interpreted in whatever
character set encoding the compiler was using (you could use escaped
characters to represent unicode characters that had no representation in that
encoding).

------
JamesUtah07
Do I really have to pay for a pdf of the standard? (sorry I just don't see
anyway else to download the pdf)

~~~
kccqzy
Just go to
[https://github.com/cplusplus/draft](https://github.com/cplusplus/draft) for
drafts. Choose a draft version that is produced right before the actual date
of standardization and there are only very minor differences between the draft
and the real deal.

~~~
vortico
Yes, I should emphasize that the minor differences are _really_ minor and
mostly typographical. There's no reason to need the published copy over the
draft unless you're IBM working on icc, one of the head gcc maintainers, etc.

