January 2013

Quick Q: Does the range-based for loop make std algorithms obsolete? -- StackOverflow

Here's a fine question from StackOverflow[C++11]. Click through for some fine answers.

Does the Range-based for Loop Make std Algorithms Obsolete?

Algorithm solution:

std::generate(numbers.begin(), numbers.end(), rand);

Range-based for-loop solution:

for (int& x : numbers) x = rand();

Why would I want to use the more verbose std::generate over range-based for-loops in C++11?

Continue reading...

 

Stroustrup's Tour of C++: Third chapter posted

Part 3 of Bjarne Stroustrup's draft Tour of C++ is now available. This material is a preview draft of Chapter 4 of Stroustrup's upcoming The C++ Programming Language, 4th Edition.

A Tour of C++, Part 3: Containers and Algorithms

by Bjarne Stroustrup

Stroustrup writes:

No significant program is written in just a bare programming language,
it would be too tedious.

However, just about any task can be rendered simple by the use of good libraries.

This third chapter of my tour of C++ begins the presentation of the standard library, which is about half of the C++ standard.

Constructive comments would be most welcome.

C++ Concurrency - Herb Sutter

Another C++ and Beyond 2012 talk is now available online on Channel 9.

[Ed.: Note that the talk title and abstract should read as below. The initial Channel 9 video posting used an outdated title and abstract, and will be corrected soon.]

C++ and Beyond 2012: C++ Concurrency

by Herb Sutter

Herb says:

I've spoken and written on these topics before. Here's what's different about this talk:

 

  • Brand new: This material goes beyond what I've written and taught about before in my Effective Concurrency articles and courses.
  • Cutting-edge current: It covers the best-practices state of the art techniques and shipping tools, and what parts of that are standardized in C++11 already (the answer to that one may surprise you!) and what's en route to near-term standardization and why, with coverage of the latest discussions.
  • Blocking vs. non-blocking: What's the difference between blocking and non-blocking styles, why on earth would you care, which kinds does C++11 support, and how are we looking at rounding it out in C++1y?

The answers all matter to you – even the ones not yet in the C++ standard – because they are real, available in shipping products, and affect how you design your software today.

Preconditions, Part 1 -- Andrzej KrzemieĊ„ski

On preconditions, and their compile time enforcement with static_assert and a dash of regex.

Preconditions, Part 1

by Andrzej Krzemieński

In this post, I want to share my thoughts about the notion of precondition. In “Design by Contract” philosophy, preconditions are always mentioned along postconditions and invariants, and in the context of OO design. In this post I focus only on preconditions and not necessarily related to any class. For instance, the following function specifies a precondition on its argument:

double sqrt(double x);

// precondition: x >= 0

Note that the function specifies the precondition even though there is no language feature for this purpose (at least in C++). A precondition is a “concept” or an “idea” rather than a language feature. This is the kind of preconditions that this post is about.

Continue reading...

C++ and Beyond 2012: Panel - Convincing your Colleagues

A new C++ and Beyond 2012 panel is now available:

C++ and Beyond 2012: Panel - Convincing your Colleagues

From C++ and Beyond 2012, Andrei, Herb and Scott present Convincing Your Colleagues - an interactive panel.

Abstract:

You can't do a better job if you don't change what you're doing, but change is hard.  It's especially hard when what needs to change is your colleagues' approach to software development. Moving your team forward often requires persuading your peers to change their behavior, sometimes to do something they're not doing, other times to stop doing something they've become accustomed to.  Whether the issue is to embrace or avoid C++ language features, to adopt new development tools or abandon old ones, to increase use of or scale back on overuse of design patterns, to adhere to coding standards, or any of the plethora of other matters that affect software creation, moving things forward typically requires getting your colleagues to buy into the change you're proposing.  But how can you do that?

In this panel session, Andrei, Herb, and Scott share how they go about convincing their colleagues to change and take questions from the audience.

 

C++ and Beyond 2013 dates announced

Scott Meyers has announced dates for another C++ and Beyond seminar with Scott, Herb Sutter, and Andrei Alexandrescu:

There will be a C++ and Beyond 2013!  The dates are tentatively set to be December 8-11, so block that time out on your calendar.  We have a venue picked out, but we haven’t signed a contract yet, so I can’t make any announcement about where C&B 2013 will take place.  I expect to be able to tell you all about it within the next few weeks, however.

Until then, hold December 8-11, 2013, for more in-depth, in-sightful, in-triguing, in-vestigations into the world of C++... and Beyond grin

Scott