advanced

C++11 and Boost

What issues arise when combining C++11 and (older) Boost code that has pre-standard versions of C++11 features?

C++11 and Boost

by Jens Weller

From the article:

Some parts of the Standard Library in C++11 are predated in boost. When playing around with C++11, you get used to using some parts in the Standard Library that are used in C++03 with their boost counterpart. Also, there is some libraries now occuring, which are C++11 based, so interfacing with either boost or C++11 code is soon an issue.

Papers for Chicago: Concurrency

The start of my series about the papers for the upcoming Chicago meeting, starting with C for Concurrency:

C++ Papers for Chicago: Part 1 -- Concurrency

by Jens Weller

From the article:

As I did write a series about the papers for Bristol, this is the start of the series for Chicago, as at the end of this month the C++ committee will meet again for standardization. I try to...

C++ Conferences This Fall

I've created a short overview over the C++ Conferences this Fall:

  • Going Native (Seattle, 4.th-6.9) SOLD OUT
  • International Workshop on OpenMP (Canberra (AU), 16-18.9)
  • (not a conference, but...) Fall ISO C++ meeting (Chicago, 23-28.9)
  • QtDevDays Europe (Berlin, 7th - 9.10)
  • QtDevDays US (San Francisco, 6th-8.11)
  • Meeting C++ 2013 (Düsseldorf, 8th-9.11)
  • C++ and Beyond (Snoqualmie Falls (WA/US), 9th-12.12) SOLD OUT

More details at Meeting C++

by Jens Weller

Overload 116 available

overload-116.PNGOverload 116 is now available. It contains the following articles, and more:

 

Overload 116

Auto -- A Necessary Evil? Part 2 -- Roger Orr

When is the use of auto good, and when is it evil?

Dynamic C++, Part 2 -- Alex Fabijanic

Alex Fabijanic and Richard Saunders continue to explore dynamic solutions in C++.

Portable String Literals in C++ -- Alf Steinbach

How hard can it be to make a file in C++ with international text literals in its name? Alf Steinbach shows us how to write a file called π.recipe.

Hard Upper Limit on Memory Latency -- Sergey Ignatchenko

How low can latency really get?

 

... and more!

Universal References and the Copy Constructor -- Eric Niebler

The "universal references" term is getting traction:

Universal References and the Copy Constructor

by Eric Niebler

From the article:

At the most recent NWCPP meeting in Redmond, WA, the always-entertaining Scott Meyers shared his latest insights about so-called “universal references” and their pitfalls. In particular, he was warning about the hazards of overloading on universal references. His advice was good, I thought, but missed some important corner cases about the interactions between universal references and the special member functions. In this article, I show what the “special” problems are with the special member functions and universal references, and some ways to avoid the problems. ...

... 

Scott’s advice is simple and sound: avoid overloading on universal references. By which he means, don’t do this:
template<typename T>
void foo( T const & t )
  {/*...*/}

template<typename T>
void foo( T && t )
  {/*...*/}

In the code above, the author presumably wanted all lvalues to go to the first and all rvalues to go to the second. But that’s not what happens. What happens is this: ...

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.

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++?

When decltype meets auto -- Scott Meyers

A fresh Scott Meyers post about a brand-new C++14 feature:

When decltype meets auto

by Scott Meyers

... C++14 is on the horizon, and one of the new features sure to stifle even the strongest of yawns is the ability to declare types using decltype(auto). This feature leads to two questions, only the first of which is rhetorical:

  1. You can declare what?
  2. During type deduction for decltype(auto), which type deduction rules are to be followed: those for auto or those for decltype? Or does decltype(auto) have its own set of type deduction rules?

Living with Lambdas -- Alfons Haffmans

living-with-lambdas.PNGWe have such a powerful language, and what a powerful language it is.

Living with Lambdas

by Alfons Haffmans

From the article:

You can work in the functional programming paradigm in C++. And you may be surprised at how complete C++’s support for functional programming is.

... C++ has always been a multi-paradigm language. And while previous attempts to add practical functional programming features required significant effort, recent additions to the C++ standard, like lambdas, have improved the situation. This paper explores the out-of-box support for functional programming provided by the new standard. We’ll look at techniques typically found in introductory functional programming textbooks. This article assumes familiarity with C++, but not necessarily with basic functional programming.

The source code is available in github and is compiled using gcc 4.8 installed on Mac OSX using MacPorts.