What does HackerNews think of draft?

C++ standards drafts

Language: TeX

> I don't have a copy of the standard at hand, can anyone quote the relevant section?

The C++ (draft) standard is on GitHub! [0] Compiling it needs Perl and some LaTeX packages, but is reasonably straightforwards otherwise. In addition, links to specific draft standards can be found on cppreference [1].

But anyways, in the first C++20 post-publication draft (N4868), the wording you're interested in is in multiple sections. Section 22.2.3 Sequence Containers [sequence.reqmts] has Table 78: Optional sequence container operations [tab:container.seq.opt] (starting on page 815), which states that a precondition of pop_back() is that empty() returns false. Section 16.3.2.4 Detailed Specifications [structure.specifications] (page 481) states:

> Preconditions: the conditions that the function assumes to hold whenever it is called; violation of any preconditions results in undefined behavior.

Therefore, calling pop_back() on an empty vector results in undefined behavior.

> Is this something that in practice is implemented in different (exception-throwing) ways?

Based on a quick glance at the major implementations (libc++ 15.0.7 at [2], MSVC at [3], libstdc++ at [4]), it looks like asserts are used. Whether those result in exceptions probably depends on whether the asserts are compiled in in the first place and how they are implemented, but it's definitely not a guaranteed exception.

[0]: https://github.com/cplusplus/draft

[1]: https://en.cppreference.com/w/cpp/links

[2]: https://github.com/llvm/llvm-project/blob/llvmorg-15.0.7/lib...

[3]: https://github.com/llvm/llvm-project/blob/8dfdcc7b7bf66834a7...

[4]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3...

The drafts are available in openstd, both of older versions of the standard[0], and the next, upcoming version[1].

Those are not technically the actual standards, but they're pretty close. But yes, I too dislike the fact that ISO standards are paid for. You know what bugs me the most? ISO 9660, the standard behind the .iso file format. It's been published in 1988, and today still costs roughly 130EUR to buy...

[0]: http://www.open-std.org/jtc1/sc22/wg21/docs/standards

[1]: https://github.com/cplusplus/draft

In the current version of the standard on the GitHub repo [0], Section 14.5 Paragraph 5 says:

> Whenever an exception is thrown and the search for a handler (14.4) encounters the outermost block of a function with a non-throwing exception specification, the function std::terminate is called (14.6.1).

I don't know when precisely noexcept was changed to call std::terminate, but I did find N3103 (included in the 2010-08 post-Rapperswil mailing [1]), which argued that the standard should require calling std::terminate to avoid security issues.

[0]: https://github.com/cplusplus/draft [1]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n310...

The example is very easy, get the latest ISO C++ draft, pay 198 CHF for the final version and do a PDF diff.

https://github.com/cplusplus/draft

https://www.iso.org/standard/68564.html

See I am even saving you the trouble to search where to buy it.

They link back from there to a April 1st post, however.

> Additionally, I refer to the post C++ Will no Longer Have Pointers by Fluent C++

Following the trail of references just loops around a half dozen April 1st posts.

With that, and nothing on the drafts [0], that I can see, I'm leaning towards joke.

[0] https://github.com/cplusplus/draft

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

Just go to 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.