Articles & Books

All Meeting C++ Lightning Talk videos are online

Meeting C++ just started a week ago, and I already managed to edit and upload all lightning talks:

Meeting C++ 2015 - all lightning talks are now online at youtube

by Jens Weller

From the article:

This year for the very first time we had lightning talks at the Meeting C++ conference. Two sessions with each 5 lightning talks were held...

Modern Asynchronous Request/Reply with DDS-RPC -- Sumant Tambe

rtidds.PNGThis article is considers lots of approaches to solving a concurrency problem, but of particular interest are the sections showing the power of the Concurrency TS future.then extension and the coroutines proposal:

Modern Asynchronous Request/Reply with DDS-RPC

by Sumant Tambe

From the article:

A quick look into N4402 reveals that the await feature relies on composable futures, especially .then (serial composition) combinator. The compiler does all the magic of transforming the asynchronous code to a state machine that manages suspension and resumption automatically. It is a great example of how compiler and libraries can work together producing a beautiful symphony.

... Indeed, this is truly an exciting time to be a C++ programmer.

C++ Static Analysis using Clang -- Ehsan Akhgari

How to write/use C++ static analyzer using Clang.

C++ Static Analysis using Clang

by Ehsan Akhgari

From the article:

Large code bases typically develop rules around how various code constructs should be used.  These rules help eliminate bugs resulting from common mistakes.  C++ gives programmers a good amount of power over enforcing such rules using the facilities that the language provides.  As a simple example, if you have a class that should not be inherited from, you can mark the class as final.

Typically one finds themselves in a situation where the language doesn’t provide an easy way to enforcey something.  In that case, the solution is typically enforcing the rules through documentation, code review, etc.  Besides the obvious downside of people making mistakes when checking for these rules, detecting violations of the some rules may be completely impractical.

Quick Q: C++ regex: Conditional replace

Quick A: Use regex_token_iterator

Recently on SO:

C++ regex: Conditional replace

Use regex_token_iterator


#include <regex>
#include <string>
#include <sstream>
#include <set>
#include <map>

std::string replacer(std::string text) {
    std::string output_text;
    std::set<std::string> keywords = { "foo", "bar" };
    std::map<std::string, int> ids = {};

    int counter = 0;
    auto callback = [&](std::string const& m){
        std::istringstream iss(m);
        std::string n;
        if (iss >> n)
        {
            if (keywords.find(m) != keywords.end()) {
                output_text += m + " ";
            }
            else {
                if (ids.find(m) != ids.end()) {
                    output_text += "ID" + std::to_string(ids[m]) + " ";
                }
                else {
                    // not found
                    ids[m] = counter;
                    output_text += "ID" + std::to_string(counter++) + " ";
                }
            }
        }
        else
        {
            output_text += m;
        }
    };

    std::regex re("\\b\\w*\\b");
    std::sregex_token_iterator
        begin(text.begin(), text.end(), re, { -1, 0 }),
        end;
    std::for_each(begin, end, callback);
    return output_text;
}

 

Getting Started with Modules in C++--Kenny Kerr

The basics of creating and using a module:

Getting Started with Modules in C++

by Kenny Kerr

From the article:

Visual Studio 2015 Update 1 shipped with experimental support for a module system for C++. You can learn about it from this talk given by Gabriel Dos Reis at CppCon. Creating and consuming modules is very simple, but getting started with the compiler is not that obvious. At least it wasn’t very obvious to me, so here’s a quick introduction to get you started.

C++ Modules in VS 2015 Update 1--Gabriel Dos Reis and Andrew Pardoe

Modules in Visual:

C++ Modules in VS 2015 Update 1

by Gabriel Dos Reis and Andrew Pardoe

From the article:

The VC++ team is excited to preview a new feature in VS 2015 Update 1: The first experimental implementation of A Module System for C++, proposed for C++17. That proposal was approved by the C++ standards Evolution Working Group for a C++17 Technical Specification at the Fall 2015 meeting in Kona, Hawai’i. The draft wording for the Technical Specification is under review by the C++ Standards Core Working Group.

 

The most dangerous function in the C/C++ world

Most errors that I see in the projects are related to the usage of this particular memset() function.

The most dangerous function in the C/C++ world

by Andrey Karpov

From the article:

Now I have another interesting observation. Using one or another function, the programmers can make mistakes. That is clear, you may say. But the probability of the error may also depend on the function. In other words, some functions provoke errors, and some don't. And now I am ready to name the function which causes most of the troubles and using which you have the biggest chance of an epic fail.

IncludeOS: A C++ Unikernel now free and open source

The IncludeOS unikernel prototype is now free and open source at GitHub. IncludeOS offers a portable way to run a compiled C++ service directly on virtual x86 hardware; either locally on your Mac or Windows machine with VirtualBox, or in large scale cloud environments running KVM.

#include <os> // literally.

From the home page:

Run your C++ code directly on virtual hardware

IncludeOS aims to be the thinnest, lightest possible layer, between your C++ code and virtual hardware. We provide a bootloader, standard libraries, lots (we hope) of modules, and the build- and deployment system. You provide the service.

IncludeOS is designed for KVM/Linux but previous versions have also been tested successfully on VirtualBox (which again runs on OS X Windows and Linux) and Bochs

It's a prototype -- be patient!

IncludeOS is not production ready -- but we're working hard to become so.

It's a research project

IncludeOS is the result of a research project at Oslo and Akershus University College of Applied Science (hioa.no)

A paper titled IncludeOS: a resource efficient unikernel for cloud services, which presents the first prototype, will appear at IEEE CloudCom 2015

Contributors

IncludeOS was created by @alfred-bratterud, with lots of contributions from @fwsgonzo and others at the NETSYS group at HiOA.

Efficient parameter pack indexing--Louis Dionne

And you, how do you index your parameter pack?

Efficient parameter pack indexing

by Louis Dionne

From the article:

Recently, I’ve been looking at ways to index into parameter packs with as little compile-time overhead as possible. This is not a new problem, and we know of several metaprogramming techniques to achieve this, some of which offer pretty good compile-times. Most of these techniques are also well documented, for example here and here. So, why write an article about this well-covered topic? Well, I recently decided to cheat and modified the compiler to see how fast we could possibly be. This article summarizes what I found.