Trip report: Spring ISO C++ meeting

I just posted my Lenexa ISO C++ trip report over on covering our recent meeting.

The ISO C++ committee is shipping more work sooner via concurrent Technical Specifications, but it’s still fairly new to find ourselves doing so much work that the “new normal” is to issue an international ballot from every ISO C++ meeting. This time, we completed three Technical Specifications (Transactional Memory, Library Fundamentals, and Parallelism) and sent out another for its comment ballot (Concurrency). We also did quite a bit of forward-looking planning for C++17, which is much closer than one would think since we’re aiming for a comment draft in mid/late 2016.

And check out the CppCon angle… it’s great to see the committee/community interaction and collaboration, and I can’t wait for CppCon in September and the fall ISO C++ meeting in October.

Reader Q&A: Why was implicit int removed?

Today, Vikram Ojha asked via email:

I was just thinking why we removed “int” as default return type from C++ which was there in our traditional C type. Why we made such changes, is it to make language more safer?

Short answer: Because it’s ‘inherently dangerous’ in the words of the C committee.

For C++, see D&E (The Design and Evolution of C++) index “implicit int” which takes you to section 2.8.1. For C, see the C99 Rationale section 6.7.2 — interestingly, you can’t search for “implicit int” because that term isn’t used — this is where the string to search for is “inherent danger” :).

Cribbing from Bjarne’s writeup, “implicit int” was removed some 20 years ago for several reasons, including code clarity and in additional avoiding special cases, to simplify C++ code and/or the C++ grammar.

For example, what does this mean?

void f(const T);

In modern C++, it can mean only that f has a const parameter of type T that is unnamed.

If we had implicit int, this would be less obvious: Could it also be a const parameter of type int named T?

There are a number of other cases where just omitting the type, with the meaning that it’s a certain fixed type, makes the grammar and/or the program harder to think about than it should be. So the ability to do that was removed in both C and C++.

Reader Q&A: auto and for loop index variables

[Edit: I really like the ‘range of values’ several commenters proposed. We do need something like that in the standard library, and it may well come in with ranges, but as you can see there are several simple ways to roll your own in the meantime, and some third-party libraries have similar features already.]

Today a reader asked the following question:

So I’ve been reading all I can about c++11/c++14 and beyond when time permits.  I like auto, I really do, I believe in it.  I have a small problem I’m trying to decide what to do about.  So in old legacy code we have things like this:

for (int i = 0; i < someObject.size(); i++) { … }

For some object types size might be unsigned, size_t, int, int64_t etc…

Is there a proper way to handle this generically with auto?  The best I could come up with is:

auto mySize = someObject.size();

for (auto i = decltype(mySize){0}; i < mySize; i++) { … }

But I feel dirty for doing it because although it actually is very concise, it’s not newbie friendly to my surrounding coworkers who aren’t as motivated to be on the bleeding edge.

Good question.

First, of course, I’m sure you know the best choice is to use range-for where that’s natural, or failing that consider iterators and begin()/end() where auto naturally gets the iterator types right. Having said that, sometimes you do need an index variable (including for performance) so I’ll assume you’re in that case.

So here’s my off-the-cuff answer:

  • If this isn’t in a template, then I think for( auto i = 0; etc. is fine, and if you get a warning about signed/unsigned mismatch just write for(auto i = 0u; etc. This is all I’ve usually needed to do.
  • If this is truly generic code in a template, then I suppose for( auto i = 0*mySize; etc. isn’t too bad – it gets the type and it’s not terribly ugly. Disclaimer: I’ve never written this, personally, as I haven’t had a need (yet). And I definitely don’t know that I like it… just throwing it out as an idea.

But that’s an off-the-cuff answer. Dear readers, if you know other/better answers please tell us in the comments.

Updates to my trip report

(this is an echo of what I also just posted on

I wanted to add a few more things to my meeting trip report. I updated the trip report in-place, but for those who want to see the “diffs” I’ll also post just the new parts here as a standalone post:

There were 106 experts at this meeting, officially representing 7 nations. This meeting saw a recent-record number of papers, including over 120 in the pre-meeting mailing.

In addition to the other things I mentioned, we also approved several other interesting changes, including the following highlights:

  • Adopted N4230, which allows nested namespace definitions like namespace A::B::C { } as a convenient shorthand for namespace A { namespace B { namespace C { } } }.
  • Adopted N3922, which fixes the most common pitfall with auto and {}, so that auto x{y}; now deduces the sane and expected thing, namely the type of y. Before this, it deduced initializer_list which was unfortunate and surprising. So, fixed.
  • Adopted N4086, which removes trigraphs. Yes, we removed something from C++… and something that was inherited from C! But wait, there’s more…
  • Adopted N4190, and actually removed (not just deprecated) several archaic things from the C++ standard library, including auto_ptr, bind1st/bind2nd, ptr_fun/mem_fun/mem_fun_ref, random_shuffle, and a few more. Those are now all removed from the draft C++17 standard library and will not be part of future portable C++.

We also did work and made progress on a lot of other proposals, including modules. See the pre-meeting mailing for details about papers considered at this meeting.

Trip Report: Fall ISO C++ Meeting

I just posted my ISO C++ meeting trip report over on covering our meeting in Urbana-Champaign earlier this month.

The ISO C++ committee is shipping more work sooner via concurrent Technical Specifications, but it’s still fairly new to find ourselves doing so much work that the “new normal” is to issue an international ballot from every ISO C++ meeting. This time, we have four ballots coming out of this meeting — the first (of two) ballots for the Transactional Memory TS, the final ballots for the Library Fundamentals TS and the Parallelism TS, and a new work item for C++17 since this was the first meeting of the C++17 era.

Oh, and we had evening sessions. Did I mention evening sessions? Five nights’ worth.

Now, two weeks later, I’m almost caught up on sleep.


But what a blast. I’m looking forward to the next few smaller meetings over the winter, and the next full one in May.