Boost Your Productivity with C++11 and Templates (Sep 9-13, Oct 7-11) -- Peter Gottschling

peter-gottschling.jpgThis course is being held in English and German:

Boost Your Productivity with C++11 and Templates

by Peter Gottschling

  • September 9-13 (German)
  • October 7-11 (English)

Abstract:

Templates (generic programming)

  • Function templates
  • Class templates
  • Variadic Templates (C++11)
  • Concepts
  • Specialization
  • Template arguments that are not types
  • Functors
  • Lambda functions (C++11)

Standard Template Library

  • Iterator concept
  • Containers
  • Functions
  • Meta-programming
  • Let the compiler compute
  • Providing type informations
  • Auto and decltype (C++11)
  • Const-adaptive classes
  • Expression templates

Other advanced and new techniques

  • Calling functions from derived classes without overhead
  • RValues and move semantics (C++11)
  • Initialization lists (C++11)
  • New for-loops (C++11)

Peter Gottschling is author of the Matrix Template Library 4, co-author of the Boost Graph Library and other scientific libraries. He is vice-chair of DIN's programming language group and head of the German delegation in the ISO committee for C++ standardization. He is managing director of SimuNova and taught C++ at TU Dresden, TU Berlin and Indiana University.

Intel Concurrent Collections for C++ 0.9 now supports Xeon Phi on Windows and Linux

intel.png

Note that some of these concurrent collections are also currently being proposed for ISO standardization.

From the announcement:

Intel Releases New Version of  Intel® Concurrent Collections for C++

Intel released a new version of Intel® Concurrent Collections for C++, a library that helps developers write and tune parallel software. Now with Version 0.9, computers powered by Intel® Xeon Phi™ co-processors are supported and can experience unified programming in the same seamless way that single Intel multi-core workstations and clusters of workstations have experienced with earlier versions. Additionally, its tuning layer was extended, giving developers even easier control over the execution of their application, offering greater potential for performance, scalability and productivity.

Intel Concurrent Collections for C++ is available for Windows and Linux as a free download through the Intel Software Network.

Expression Templates -- Volker Krause

volker-krause.jpgFrom this month's KDE Akademy conference:

Expression Templates: How I Learned to Stop Worrying and Love Template Meta-Programming (30 min video) (slides)

by Volker Krause

The speaker's opening words should be enough to get you to set aside a half hour:

"I'm going to talk about template metaprogramming in general and expression templates in particular. And that's obviously something we use every day. <laughter> You laugh, but in half an hour you will see that we actually do..."

 

Abstract:

Contrary to common perception, expression templates are not bizarre meta-programming theory but something you are (possibly unknowingly) using every day. We'll see what they are good for, how they work and and what to do if they don't.

Originally invented by Todd Veldhuizen for the use in the math library Blitz++, expression templates are often seen as one of those esoteric applications of C++ template meta-programming that results in completely incomprehensible code that only Marc and Thiago understand at best, and that gives you compiler errors longer than an average discussion on the right display manager.

In this talk we will try to counter this (wrong) perception, by looking at why and how this (syntactically) indeed somewhat complex code results in very elegant API and often outperforms conventional implementations. On the way we will see that C++ template meta-programming code is actually not that scary, and that template-related compiler errors aren't that bad either.

Now why would this be of interest to the average Qt or KDE developer? Well, since the introduction of QStringBuilder in Qt 4.7 we have expression templates for a very common use case, string concatenations. And if your code is somewhere in KDE Git, it's very likely Laurent enabled the use of QStringBuilder for you already. So, we are not talking about exotic theory here, but about tools you are using every day.

Is Moving Objects Worth the Hassle? -- Andrew Koenig

Koenig's latest just went live at DDJ:

Is Moving Objects Worth the Hassle?

by Andrew Koenig

From the article:

Last week, I discussed how C++ compilers use overloading to decide whether to move or copy an object. This week, I'd like to take a step back and discuss why moving instead of copying is worth doing in the first place.

You might think that this claim needs no justification. After all, copying takes time; so programs that copy a lot of data will be slower than programs that avoid doing so. However, this kind of unthinking optimization can lead to trouble. For example...

New paper: N3705, Agenda and Meeting Notice for WG21 Telecon Meeting -- Herb Sutter

A new WG21 paper is available. A copy is linked below, and the paper will also appear in the next normal WG21 mailing. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

 

Document number: N3705

Date: 2013-07-23

Agenda and Meeting Notice for WG21 Telecon Meeting

by Herb Sutter

Excerpt:

Note: As discussed at the previous telecon and in committee email, this telecon is being held one week before the face-to-face meeting, rather than two weeks, to avoid holidays and other conflicts.

The Universal Reference/Overloading Collision Conundrum -- Scott Meyers

meyers-nwcpp-13.PNG[Blog suggestion by NoSenseEtAl. Text below added by editor.]

Scott Meyers gave a well-received "beta" talk last week at NWCPP on the topic below, which he described as the most complex Item he's encountered as he prepares his upcoming book Effective C++11/14:

The Universal Reference/Overloading Collision Conundrum

by Scott Meyers

Abstract:

To help address the confusion that arises when rvalue references become lvalue references through reference collapsing, Scott Meyers introduced the notion of "universal references." In this presentation, he builds on this foundation by explaining that overloading functions on rvalue references is sensible and useful, while seemingly similar overloading on universal references yields confusing, unhelpful behavior. But what do you do when you want to write a perfect forwarding function (which requires universal references), yet you want to customize its behavior for certain types? If overloading is off the table, what's on? In this talk, Scott surveys a variety of options.

Though Scott will give a one-slide overview of the idea behind universal references at the beginning of the presentation, attendees are encouraged to familiarize themselves with the notion in more detail prior to the talk. Links to written and video introductions to universal references are available here.

How do you write a universal memoization function in C++? -- StackOverflow

From Python to C++:

Writing Universal memoization function in C++

Looking for a way to implement a universal generic memoization function which will take a function and return the memoized version of the same?

Looking for something like @memo (from Norving's site) decorator in python.

def memo(f):
    table = {}
    def fmemo(*args):
        if args not in table:
            table[args] = f(*args)
        return table[args]
    fmemo.memo = table
    return fmemo

Going more general, is there a way to express decorators in C++?

The Point of No Return -- bulldozer00

A cute nugget about [[noreturn]]:

The Point of No Return

by bulldozer00

As part of learning the new feature set in C++11, I stumbled upon the weird syntax for the new “attribute” feature: [[ ]]. One of these new C++11 attributes is [[noreturn]]. ...

Quick Q: When should you use constexpr? -- StackOverflow

Quick A: When you want to potentially evaluate a calculation at compile time. You can do much, much more than just "return 5;".

When should you use constexpr capability in C++11?

It seems to me that having a "function that always returns 5" is breaking or diluting the meaning of "calling a function". There must be a reason, or a need for this capability or it wouldn't be in C++11. Why is it there?

// preprocessor.
#define MEANING_OF_LIFE 42
// constants:
const int MeaningOfLife = 42;
// constexpr-function:
constexpr int MeaningOfLife () { return 42; }

It seems to me that if I wrote a function that return a literal value, and I came up to a code-review, someone would tell me, I should then, declare a constant value instead of writing return 5.