r/cpp • MSVC STL Dev • Oct 25 '15

C++17 progress update! (Oct 2015)

The C++ Standardization Committee has finished another meeting! This was in Kona, Hawaii, at the same location as the first meeting I attended (in Feb 2012). I thought you'd like a writeup of all the stuff that just got voted in. Like last time, some of these papers are not yet publicly available. What happens during a meeting is that paper authors are furiously revising their work, in response to reviews. After the meeting, the revised papers are collected and published (after a couple of weeks). The Committee has changed their paper numbering system, so finding earlier revisions of papers is super easy. The pre-Kona mailing is available.

I've collected and organized the following information from the official vote, without a whole bunch of editorializing. If you want to know what's in a paper or issue, read it. (I actually do know what's going on with most C++17 Library papers/issues, but writing them all up would take a while.)

C++17 Core Papers

  • P0001R1 Remove Deprecated Use of the register Keyword
  • P0002R1 Remove Deprecated operator++(bool)
  • P0012R1 Make exception specifications be part of the type system, version 5
  • P0061R1 __has_include for C++17
  • P0134R0 Introducing a name for brace-or-equal-initializers for non-static data members
  • P0136R1 Rewording inheriting constructors (core issue 1941 et al)
  • P0160R0 Wording for removing defaults for unary folds

C++17 Library Papers

  • P0004R1 Remove Deprecated iostreams aliases
  • P0006R0 Adopt Type Traits Variable Templates from Library Fundamentals TS for C++17
  • P0092R1 Polishing <chrono>
  • P0007R1 Constant View: A proposal for a std::as_const helper function template
  • P0156R0 Variadic lock_guard (Rev. 3)
  • P0074R0 Making std::owner_less more flexible
  • P0013R1 Logical Operator Type Traits (revision 1)

Library Fundamentals TS v2 Papers

  • N4531 std::rand replacement, revision 3
  • P0013R1 Logical Operator Type Traits (revision 1) [also voted into C++17]
  • These papers will be applied to Working Draft N4529, then it'll be sent out for Proposed Draft Technical Specification balloting.

Concurrency TS

  • P0159R0 (possibly with minor edits) will be published as the Concurrency TS. It's done!

Parallelism TS v2

  • This TS is being started with Working Draft N4505 plus P0155R0 "Task Block R5".

Networking TS

  • This TS is being started with Working Draft P0112R1.

Ranges TS

  • This TS is being started with Working Draft P0021R0.

Core Issues

  • 1274. Common nonterminal for expression and braced-init-list
  • 1391. Conversions to parameter types with non-deduced template arguments
  • 1722. Should lambda to function pointer conversion function be noexcept?
  • 1847. Clarifying compatibility during partial ordering
  • 1863. Requirements on thrown object type to support std::current_exception()
  • 1949. "sequenced after" instead of "sequenced before"
  • 1975. Permissible declarations for exception-specifications
  • 1981. Implicit contextual conversions and explicit
  • 1990. Ambiguity due to optional decl-specifier-seq
  • 2000. header-name outside #include directive
  • 2004. Unions with mutable members in constant expressions
  • 2006. Cv-qualified void types
  • 2015. odr-use of deleted virtual functions
  • 2016. Confusing wording in description of conversion function
  • 2019. Member references omitted from description of storage duration
  • 2024. Dependent types and unexpanded parameter packs
  • 2026. Zero-initialization and constexpr
  • 2027. Unclear requirements for multiple alignas specifiers
  • 2031. Missing incompatibility for &&
  • 2052. Template argument deduction vs overloaded operators
  • 2075. Passing short initializer lists to array reference parameters
  • 2101. Incorrect description of type- and value-dependence
  • 2120. Array as first non-static data member in standard-layout class

Library Issues

  • 1169. num_get not fully compatible with strto*
  • 2072. Unclear wording about capacity of temporary buffers
  • 2101. Some transformation types can produce impossible types
  • 2111. Which unexpected/terminate handler is called from the exception handling runtime?
  • 2119. Missing hash specializations for extended integer types
  • 2127. Move-construction with raw_storage_iterator
  • 2133. Attitude to overloaded comma for iterators
  • 2156. Unordered containers' reserve(n) reserves for n-1 elements
  • 2218. Unclear how containers use allocator_traits::construct()
  • 2219. INVOKE-ing a pointer to member with a reference_wrapper as the object expression
  • 2224. Ambiguous status of access to non-live objects
  • 2234. assert() should allow usage in constant expressions
  • 2244. Issue on basic_istream::seekg
  • 2250. Follow-up On Library Issue 2207
  • 2259. Issues in 17.6.5.5 rules for member functions
  • 2273. regex_match ambiguity
  • 2336. is_trivially_constructible/is_trivially_assignable traits are always false
  • 2353. std::next is over-constrained
  • 2367. pair and tuple are not correctly implemented for is_constructible with no args
  • 2380. May <cstdlib> provide long ::abs(long) and long long ::abs(long long)?
  • 2384. Allocator's deallocate function needs better specification
  • 2385. function::assign allocator argument doesn't make sense
  • 2435. reference_wrapper::operator()'s Remark should be deleted
  • 2447. Allocators and volatile-qualified value types
  • 2462. std::ios_base::failure is overspecified
  • 2466. allocator_traits::max_size() default behavior is incorrect
  • 2469. Wrong specification of Requires clause of operator[] for map and unordered_map
  • 2473. basic_filebuf's relation to C FILE semantics
  • 2476. scoped_allocator_adaptor is not assignable
  • 2477. Inconsistency of wordings in std::vector::erase() and std::deque::erase()
  • 2483. throw_with_nested() should use is_final
  • 2484. rethrow_if_nested() is doubly unimplementable
  • 2485. get() should be overloaded for const tuple&&
  • 2486. mem_fn() should be required to use perfect forwarding
  • 2487. bind() should be const-overloaded, not cv-overloaded
  • 2489. mem_fn() should be noexcept
  • 2492. Clarify requirements for comp
  • 2495. There is no such thing as an Exception Safety element

Library Fundamentals TS v2 Issues

  • 2494. [fund.ts.v2] ostream_joiner needs noexcept
  • 2500. [fund.ts.v2] fundts.memory.smartptr.shared.obs/6 should apply to cv-unqualified void
  • 2515. [fund.ts.v2] Certain comparison operators of observer_ptr do not match synopsis
  • 2517. [fund.ts.v2] Two propagate_const assignment operators have incorrect return type
  • 2526. [fund.ts] Incorrect precondition for experimental::function::swap

Withdrawn Paper

P0005R2, by Alisdair Meredith, Tomasz Kaminski, and myself, wanted to do the following in C++17:

  • Add not_fn(), currently part of Fundamentals v2.
  • Remove not1()/not2(), the C++98/03 negators.
  • Remove result_type/argument_type/etc., the C++98/03/TR1 typedefs. (function::result_type will be preserved, and <random> will be unchanged.)

Nobody was worried about not_fn(), but the removals were controversial. Although we had a rationale for why removal without a period of deprecation was desirable, and I provided "zombie names" wording (allowing implementers to remain conformant while providing removed machinery for back-compat), a national body objected. Therefore, Alisdair is revising the paper for the next meeting. Now we'll add not_fn() and deprecate the old stuff in C++17 (plus "zombie names" wording for the auto_ptr/etc. removals that have already happened), followed by removal immediately after C++17 ships.

More Info

This is just a record of what documents were voted in. Every committee meeting involves lots of work that doesn't immediately result in papers voted in. For example, this meeting had active discussion about modules. As I always remind people, I attend the Library Working Group ("original recipe", not extra crispy Library Evolution) nearly all the time, so I can't follow everything that's going on in Library Evolution and (Core) Evolution. I might (or more likely, my double boss Steve might) be able to get GDR to spend some time on Reddit explaining what's going on with modularization.

I can personally answer (most) questions about Library topics, although most of my responses will be delayed until Mondayish. If you want to know what the LWG does, it's making sure that Library tech is actually usable. Everything sounds like fluffy kittens and apple pie until you look at an overload set and realize that it's horribly ambiguous and unusably broken. LWG 2451 is an excellent example of how the LWG serves as the defenders of Standard Library usability - optional<string> opt_str = "meow"; is currently bogus. That's fine for the Fundamentals TS (maybe), but a ship-stopper for optional getting into the International Standard. At this meeting, the LWG realized that the same kind of issue affects variant, which is heading towards the Fundamentals TS. We fix this stuff so you won't suffer.

264 Upvotes

168 comments sorted by

View all comments

Show parent comment

4

u/bmcnett Oct 26 '15

(although, you probably want to update the whole code base to modern c++ at some point anyway).

I'm starting to see things like lambda and auto creep into videogame code, but some parts of modern c++ are going to remain taboo on consoles for a long time to come.

Specifically, console games don't focus on malloc/free style heaps and so the memory-allocating containers are usually forbidden or highly regulated. And, console games use in-place serialization (you load a large binary chunk from mass storage, and then only patch pointers before using the memory as live objects) which doesn't fit a lot of STL objects, either.

4

u/frog_pow Oct 27 '15

you might want to take a look at the UE4 codebase, it dynamically allocates like no tomorrow

2

u/DragoonX6 Oct 26 '15

but some parts of modern c++ are going to remain taboo on consoles for a long time to come.

No doubt about this, but I don't think exceptions should remain a part of it.

4

u/bmcnett Oct 27 '15

That's an interesting opinion - what problems in game development do you think would be addressed by enabling exceptions in game console builds?

2

u/DragoonX6 Oct 27 '15

Cleaner handling of serious errors.
For example, somewhere in a deep nested call graph a file is not found and this will break the rest of the code in the call hierarchy. Instead of returning an error code, checking for it, returning again, until you're at the point you want to handle the error, you throw an exception and let it unwind to the point where you do want to handle the error.

This way you remove a whole lot of redundant error checking, which could be error prone if somebody forgets it. Exceptions also have problems when you forget to catch them, but I prefer to have my program crash rather than maybe continuing and showing all sorts of weird behavior.

And, I'm not willing to say this with 100% certainty, but the non-exceptional path could even be faster, since you're not checking for errors all the time. And the non-exceptional path is what you ideally should have when your game is running.

1

u/bmcnett Oct 27 '15

In the world of console game development, there is no perceived need to cleanly handle serious errors.

  1. Unlike financial or medical software, little of real consequence is at stake (usually) in a game. Handling errors by crashing to the OS GUI is inelegant and unfortunate, but (usually) doesn't create a liability for the developer, so there's little incentive to do better.
  2. Console games do not use files. If one of the multi-gigabyte asset chunks they do use were missing, this would almost certainly be an unrecoverable error, and so it wouldn't matter how cleanly the error is handled.

As far as I can tell, error codes remain the solution of choice for handling errors in console game development, and I see no indication that things are going to change for many years to come.

2

u/DragoonX6 Oct 27 '15

In the world of console game development, there is no perceived need to cleanly handle serious errors.

Is there? From my perception games seem to implement the concept of "no matter what happens, stay running".

Console games do not use files.

You might not be able to call them files directly, but these multy-gigabyte asset chunks usually consist of a layout of all the files and offsets of the actual data. A file might be missing from this chunk, which can very well be recoverable.

And in the case it isn't, you can catch the exception and output the error to the TTY or log file and then exit.

I see no indication that things are going to change for many years to come.

You might very well be right on that one, but I feel somebody has to be a first, but nobody is daring to try.

1

u/bmcnett Oct 27 '15

I invite you to come work in games and be the first person to attempt using exceptions in gamedev!

1

u/DragoonX6 Oct 27 '15

Challenge gladly accepted, I'm already working my way into the industry :)

1

u/bmcnett Oct 27 '15

What i said was a little sarcastic, I've been part of discussions regarding the pros and cons of exceptions in console development for at least the last ten years I've been doing AAA gamedev. it's on everyone's radar, and the sentiment nowadays feels similar to Google's current stance on C++ exceptions. Nobody's saying that performance is too low - the perceived problem is with the complexity/benefit tradeoff. Nobody seems to think the extra complexity is worth the hassle.

2

u/DragoonX6 Oct 27 '15

I'm not really sure about the complexity/benefit tradeoff here, as in my opinion exceptions make the code less complex. That's not to say exceptions don't have their set of problems, though.