advanced

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.

Boost 1.54.0 released!

Release 1.54.0 of the Boost C++ Libraries is now available.

These open-source libraries work well with the C++ Standard Library, and are usable across a broad spectrum of applications.
The Boost license encourages both commercial and non-commercial use.

This release contains five new libraries and numerous enhancements and bug fixes for existing libraries.

New Libraries:
Log: Logging library, from Andrey Semashev.
TTI: Type Traits Introspection library, from Edward Diener.
Type Erasure: Runtime polymorphism based on concepts.

For details, including download links, see http://www.boost.org/users/news/version_1.54.0

You can also download directly from SourceForge: http://sourceforge.net/projects/boost/files/boost/1.54.0/

To install this release on your system, see http://www.boost.org/doc/libs/release/more/getting_started/index.html

Thanks,

--The Boost release team

Efficient Programming with Components -- Alexander Stepanov

stepanov-components.PNGA wonderful video series by the inventor of the Standard Template Library (STL).

Video Series: Efficient Programming with Components

by Alexander Stepanov

Performance is essential for infrastructure software. Modern infrastructure software depends heavily on components. Therefore, writing performant code in this environment requires deep understanding of the characteristics of such components. The course will help programmers to improve performance of their code by learning how to use these existing generic components effectively. In addition, it will teach them to extend the library with new high-performance components. Along the way, participants will learn how to use C++ as a high-performance language.The course will be taught interactively with the class discussing, discovering, and developing components together.

Code is available here.

 

 

 

Scaling with C++11 -- Edouard Alligand

cppnow13-alligand.PNGFrom the recent BoostCon/C++Now event. If you missed it there, check it out online. An updated version of this talk is also slated for the upcoming Meeting C++ this fall if you want to catch it in person.

Scaling with C++11

Edouard Alligand

As the number of cores per processor increases, software needs to be able to execute multiple tasks in parallel in order to benefit from Moore's law. This is not only a question of writing parallel algorithms, but also a matter of designing the application properly to reduce inter-thread dependencies. These dependencies may be very hard to find and are the results of decades of serial programming. Thus, writing truly scalable software is less a question of technical expertise than adopting the appropriate state of mind.

This presentation is about the design, techniques and tools used by the team who wrote the hyperscalable database "quasardb." Building upon concrete scalability challenges, the presenter will expose typical multithreading anti-patterns and how to avoid them. The topics covered include: atomics, micro locks, lock-free and wait-free containers, memory management strategies (copy on write, smart pointers, perfect forwarding...), thread local storage, asynchronous I/O, and much more!

Core C++, 8 and 9: From do-while to variadic array sorter to lambdas -- Stephan T. Lavavej

core-8-9.PNGThe two latest C++ lectures by Stephan T. Lavavej, the eponymous STL, are now available:

Core C++, 8 of n

In part 8, STL digs into the do-while loop, casts, one definition rule (ODR), and his variadic template array sorter. There is a lot of information in this episode, so get comfortable, tune in, and learn.

Core C++, 9 of n

In part 9, STL digs into lambdas and other expressions. Lambdas are very useful and you've no doubt been enjoying them in your modern C++ programming. As you can imagine, STL will go deep and teach you things about lambdas that you may not know. You'll also learn a lot about order of precedence and associativity for expressions in only the way Stephan can teach you (thorough treatment). Tune in.

Clang/LLVM Conference videos and slides are now available

The recent 2013 European Clang/LLVM developer meeting talk videos and/or slides are now available here.

Here are a few of the talks of interest to C++ developers. All have videos available except the last. Check out the page for details and a full talk list.

Keynotes

Optimization in LLVM - Numbers, A Case Study, and Looking Forward
Chandler Carruth (Google)

Talks

clang-format - Automatic formatting for C++
Daniel Jasper (Google)

Performing Source-to-Source Transformations with Clang
Olaf Krzikalla (TU Dresden)

Run-time tracking of uninitialized data with MemorySanitizer
Evgeniy Stepanov (Google)

LLVM on IBM POWER processors: a progress report
Ulrich Weigand (IBM)

Tutorials

How to implement an LLVM Assembler
Simon Cook (Embecosm)

The Clang AST (slides only)
Manuel Klimek (Google)

For more talks, and video/slide links, head over to the site.