Archive for the ‘Uncategorized’ Category

Tim just added this comment on the GotW #3 Solution blog post from last year:

Are you sure you can use auto in lambda like this?
I can not compile the code and I’m pretty sure auto does not work here.

If you mean auto as a lambda parameter type, such as

[](auto& s){ use(s); }

then yes, it’s (now) legal): That’s a new feature in currently-being-finalized C++14 standard, and it’s called “generic lambdas.” It means that the compiler-generated closure object’s


is a template, so you can call the same closure object multiple times with different types and get the templated operator stamped out for each set of types it’s called with.

Major compilers are now adding support for this. As of this writing, all of GCC, Clang, and Visual C++ have implemented the basic feature and you can get it in CTP/preview/alpha releases of each, such as GCC or Clang trunk, or Visual C++ November 2013 CTP. I can’t remember offhand which of those compilers have shipped an official release since adding it (VC++ has not) but they’ll all have it in their next released versions.

By the way, isn’t it wonderful that, for the first time in the history of C++, multiple major compilers are in pretty good sync like this, both with each other and with the standard? I think that’s awesome.

Read Full Post »

Google’s doodle today reminded me of Grace Hopper’s amazing contributions.

I enjoyed this 10-minute video, and you might as well: Grace Hopper on Letterman in 1986 on the occasion of her (final) retirement.

It’s not deep, but especially in the second half Amazing Grace demonstrates how to talk to a non-specialist audience. Good reminders for all of us who speak Geek Jargon a little too fluently!

Read Full Post »

At Build in June, we announced that VC++ 2013 RTM “later this year” would include the ISO conformance features in the June preview (explicit conversion operators, raw string literals, function template default arguments, delegating constructors, uniform initialization and initializer_lists, and variadic templates) plus also several more to be added between the Preview and the RTM: non-static data member initializers, =default, =delete, “using” aliases, and library support for same plus four C99 features.

Four days ago in my talk at GoingNative (recording was just posted today!), I updated that by saying we would ship an update to VC++ 2013 Preview with all of those features, and again a go-live license, “in September.”

Well, today is “in September”: Today we shipped Visual Studio 2013 RC, which includes all of those features in a production-supported go-live Visual C++ product. Thank you very much to everyone on the front-end, back-end, and other VC++ teams for making this possible! See that post for additional features – there’s more there than just conformance work, from new auto-vectorizer optimizations to graphics and native/Javascript debugging to quite a bit more.

What’s next? As announced last week we’re going to be shipping another CTP in the fourth quarter (compiler tech preview, think of it as an “alpha”) containing another bunch of conformance features. It’s designed to give you early access to a raft of new conformance features in Visual C++, including the following (the first couple are small but I’m breaking them out because the usual C++11/14 conformance lists do it that way):

  • __func__
  • Extended sizeof
  • Implicit move generation
  • Ref-qualifiers: & and && for *this
  • Thread-safe function local static initialization (aka “magic statics”)
  • noexcept (note: this is unconditional noexcept; the CTP likely won’t have the noexcept(expr) style yet)
  • constexpr (note: except for constructors, so the CTP won’t support literal types yet)
  • C++14: generalized lambda capture
  • C++14: auto function return type deduction
  • C++14: decltype(auto)
  • Bonus: “await” as currently proposed for the ISO Concurrency TS

Those are the “high probability” features to make it into the CTP. There’s a chance we might also get a couple more “medium probability” features into the Q4 CTP, such as C++14 generic lambdas, but never fear, we’re implementing them all – whatever features don’t get into this CTP will be at the front of the next batch as we push toward full C++11/14 conformance including the C++14-accompanying specifications for the file system library, basic networking library, and especially Concepts Lite. We’ll keep you posted as we know more.

Read Full Post »


You will want to watch Chandler Carruth’s talk tomorrow at GoingNative. It will be livestreamed here starting at 2:30pm North American Pacific time. (See timeanddate.com for other time zones.)

Watch for the Ghostbusters reference.

That is all.

Read Full Post »

Comment delays and spam

In recent months, more comment spam has been getting through. To deal with it, I’ve had to tighten up and hold more comments for moderation, which means some comments may be delayed in appearing until I manually approve them. Also, I’ve noticed that WordPress seems to have similarly tightened their settings for auto-identifying spam that doesn’t even reach the moderation queue, and so those comments will be similarly delayed until I check the Spam folder and manually mark them as not-spam.

Unfortunately, this means your comment may be delayed in appearing, usually by a few hours but sometimes up to one business day (I have a day job). My policy is to approve all comments whether they agree with me or not, except only for spam and obscene or content-free flames, so if you leave a legitimate comment but don’t see it appear within a day or so, feel free to email me.

Read Full Post »

Lost two comments

As mentioned in my GotW kickoff post, I’m experimenting with software and a workflow that lets me maintain a single source document and use it to produce the work in multiple targets, in particular to post to the blog here, to produce print books, and to produce e-books.

However, there have been kinks. In particular, on the blog I sometimes repost an update to an already-posted solution, and though it usually correctly updates the existing one, sometimes it chooses to create a new post instead and I have to delete the duplicate. That happened this morning, and I had a remove an accidental duplicate of the GotW #6a solution post.

Unfortunately, people had already left two comments on that duplicate post, and those comments seem to have got lost in the ether. I apologize for that; I think this is the first time I’ve ever lost someone’s comment, but it did happen this morning as I’m still working out kinks in the software. I believe I have a workaround and that it won’t happen again.

Read Full Post »

Herb Sutter:

Day-before reminder: If you are interested in tablet apps using VC++, check out the livestream starting at 9am U.S. Pacific time tomorrow, or come back later to watch the talks on demand.

Originally posted on Sutter’s Mill:

Want to know how to write cool tablet apps using Visual C++?

On May 18, Microsoft is hosting a one-day free technical event for developers who want to write Metro apps for Windows 8 using Visual C++. I’m giving the opening talk, and the rest of the day is full of useful technical information on everything from XAML and DirectX to networking and VC++ compiler flags.

Please note: This event is Windows-specific, and talks will use both portable ISO C++ as well as Visual C++-specific libraries and compiler extensions; for brevity these are being referred to as "C++" to highlight to a Microsoft-specific audience that that this day is about Visual C++, not about Visual C# or Visual Basic or JavaScript.

From the page:

Join the Microsoft Visual C++ and Windows teams in Redmond on May 18, 2012 for a free, all-day event focused on building Windows 8 Metro…

View original 275 more words

Read Full Post »

WordPress.com expertise

I’m generally satisfied with the look and feel of this blog, but would like to tweak it in a few small ways to get a cleaner look, nicer formatting for code examples, and such.

If you or someone you know is familiar with WordPress.com blog customization, and is interested in a small project along these lines, please send me mail. Thanks.

Read Full Post »

I just posted two more sessions I’ll be giving next month at C++ and Beyond. (Aside: If you’re interested in coming, register soon; there are now only 11 seats left.)

  • “C++ Renaissance.” I’ve been asked to give the opening “Welcome, Everyone!” keynote talk at C&B 2011, and it’s time to cover an increasingly open secret: After a decade-long affair with managed languages where it became unfashionable to be interested in C++, C++’s power and efficiency are now getting very fashionable again. At the same time, C++ has been getting easier to use; key productivity features from the C++0x standard (aka C++11), like auto and lambdas, are increasingly widely available in commercial compilers and making using C++ easier than ever before without sacrificing its cornerstone — efficiency.This opening 40-minute talk covers the reasons why C++ is now enjoying a major renaissance, and why that will continue to grow over the next few years because of industry trends from processor design to mobile computing to cloud and datacenter environments.We already know that C++ is “the” language of choice for demanding applications. Here, we’ll cover why “demanding applications” increasingly means “most applications” and will be the bread and butter of our industry for the foreseeable future. We’ll see why and where other languages are still appropriate, but why C++’s applicability and demand is now again on an upswing more so than it has been for over a decade.
  • “How to Teach Today’s C++.”  With the C++ Renaissance gathering steam, I’ve personally noticed a growing need to train developers who are now turning or returning to C++. These developers don’t need to be taught how to program, but they aren’t familiar with how clean it is to write code using today’s C++. The key is: What is the best and clearest way to teach the essentials of today’s C++ — both what to teach, and what not to teach?This session shows that it is possible to show a very clean path through today’s C++ that is available to production developers right now, including use of key C++0x features already supported in many compilers, that shows how clean C++ code can be and how it compares favorably to code written in managed languages while still retaining its longstanding efficiency advantage.Many attendees coming to C++ and Beyond are experienced developers, often in senior or leadership positions. Your company may look to you to define or personally provide training in the best development techniques, whether through team brownbags or formal training sessions. As developers continue to come back to C++, you will find yourself increasingly called upon to help them quickly learn what “modern C++” really means today, and how clear and compelling it can be. This “train the trainers” session is intended to provide the foundation for that training, and give you the tools you need to train others, as we welcome them (and welcome them back) to our good friend C++.

I’ve already posted these other sessions, which round out my solo talk slots (not counting panels where Scott and Andrei and I will also all participate):

  • “C++ and the GPU… and Beyond.” I’ll cover the state of the art for using C++ (not just C) for general-purpose computation on graphics processing units (GPGPU). The first half of the talk discusses the most important issues and techniques to consider when using GPUs for high-performance computation, especially where we have to change our traditional advice for doing the same computation on the CPU. The second half focuses on upcoming C++ language and library extensions that bring key abstractions for GPGPU — and in time considerably more — directly into C++.
  •  “Exceptional C++0x (aka C++11)” that shows how the new features in C++0x change the way we solve problems, our C++ coding style, and even the way we think about our code. I’ll demonstrate that with code that works today on existing compilers, using selected familiar examples from my Exceptional C++ books. This is not rehashed material, as I’ll assume you’re already familiar with the pre-C++0x solutions (I’ll provide links to read as refreshers before the course), and then we’ll analyze and solve them entirely the 21st-century C++ way and see why C++0x feels like a whole new fresh language that leads to different approaches, new and changed guidelines, and even better solutions. As Bjarne put it: “Surprisingly, C++0x feels like a new language: The pieces just fit together better than they used to and I find a higher-level style of programming more natural than before and as efficient as ever.” This talk will show why — deeply, madly, and truly.

Read Full Post »

The fall 2010 ISO C++ meeting was held on November 8-13 in Batavia, IL, USA. The post-meeting mailing is now live, including meeting minutes and other information.

I attended this meeting virtually, as I was still recovering from some shoulder surgery. Fermilab’s teleconference facilities are excellent — I think it’s safe to say they’re the best I’ve ever used, and it was very helpful for several of us telecommuters to participate actively in the key design discussions below.

Where are we in the process?

For this and the next meeting (Madrid in March), the committee is doing ballot resolution and dealing with national body comments. Because we issued a Final Committee Draft, ISO C++0x can officially no longer add new features. All that we can do is address national body comments, and make any other bug fixes we find.

Things are going well and we are on track to complete the Final Draft International Standard (FDIS) for the C++0x standard after the Madrid meeting in March. If that happens and that ballot succeeds, the C++0x standard will be published in 2011. If it turns out we need another meeting to be able to handle the last of the comment tail, the fallback will be to target FDIS at the following meeting (Indiana in August).

For about five years now we’ve been having three six-day meetings a year, besides smaller unofficial subgroup meetings in person or by teleconference in between official meetings. Because things are going well, we also decided to scale back to two five-day meetings a year starting in 2011, which is what we had after C++98 shipped until work on C++0x began in earnest.

Key design decisions at this meeting

Note: For the first item, I’ll repeat much of the text from the August meeting trip report to make this a standalone post.

Attributes: alignment, noreturn, and virtual control. As reported in the previous trip report, my personal hot button for these past two meetings was that C++0x syntax for override control in particular not look like the following example:

class [[base_check]] Derived : public Base {
  virtual void f [[override]] ();
  virtual double g [[final]] ( int );
  virtual void h [[hiding]] ();

The committee has now decided replace these attributes with keywords. The two main options for keywords were:

  • fully reserved words, which can break existing user code that uses the words as variable or type names and so would mean we need to pick uglier names; and
  • contextual keywords as done in C++/CLI, which does not break existing user code and so lets us pick the ideal nice names, but which would be the first contextual keywords in ISO C++ (and there’s always resistance to being the first).

It was decided to follow the latter — contextual keywords pretty much as used in C++/CLI, down to renaming [[hiding]] as new. Here’s the paper with the wording changes, and here’s how the above example now looks:

class Derived explicit : public Base {
  virtual void f () override;
  virtual double g( int ) final;
  virtual void h() new;

The other two kinds of attributes that we considered changing to keywords were [[align]] to specify the alignment of a type, and [[noreturn]] to specify that a function never return. The committee confirmed the decision reported as tentative in the previous trip report, namely to change [[align]] to a keyword and leave [[noreturn]] alone.

With these changes, the only two standard attributes are [[noreturn]] and [[carries_dependency]].

noexcept, part 1: Destructor and delete operators noexcept by default. This tentative resolution from Rapperswil was mostly adopted. Briefly, every destructor will be noexcept by default unless a member or base destructor is noexcept(false); you can of course still explicitly override the default and write noexcept(false) on any destructor. This means that the vast majority of classes should be noexcept. The papers containing the exact wording changes are here (destructors) and here (delete operators). For detailed rationale and ranting about why this is a Good Thing, see the previous trip report.

noexcept, part 2: noexcept now partly applied to the standard library. We also passed the first set of papers to apply noexcept to the standard library, including changing functions marked throw() or specified “Throws: Nothing” to be marked noexcept, and removing non-empty exception specifications from the standard library.

Restricting implicit move generation. A hot topic going into this meeting was that move operations could be generated implicitly for an existing type in ways that would be surprising and incorrect (i.e., break the invariants that should hold on all objects of that type). The previous rule was to generate a move constructor and move assignment operator implicitly if the class had no user-declared copy constructor and the move constructor would not be implicitly defined as deleted. Several options were discussed at length, including not generating move implicitly at all. In the end, the decision was that implicit move was both desirable but needed to be generated less aggressively to ensure correctness, and so now the rule is to generate a move constructor and move assignment operator implicitly if the class had no user-declared copy constructor and the move constructor would not be implicitly defined as deleted (same as before) and the class has no user-declared copy or move assignment operator or user-declared destructor. Here’s the paper with the wording changes.

Looking forward

Finally, here are the scheduled dates and locations for next year’s ISO C++ standards committee meetings:

  • March 21-26, 2011: Madrid, Spain
  • August 15-19, 2011: Bloomington, IN, USA


Read Full Post »

Older Posts »


Get every new post delivered to your Inbox.

Join 2,103 other followers