Articles & Books

C++ status at the end of 2015, a user's view -- Bartlomiej Filipek

A lot has happened in C++ in 2015! As we close out the year, here's a retrospective from an experienced C++ developer:

C++ status at the end of 2015

by Bartlomiej Filipek

From the article:

Maybe I’ll be boring with this note, but again I need to write that this was another good year for C++! Here’s a bunch of facts:

  • Visual Studio 2015 was released with great support for C++14/17 and even more experimental features.
  • Long-awaited GCC 5.0 was released at the beginning of the year.
  • C++ gained a huge boost is popularity around July, 3rd stable place in the Tiobe Ranking.
  • At CppCon 2015 there were some really important announcements made.
  • C++17 seems to be just around the corner!

See my full report below...

Both keynotes from Meeting C++ 2015 are now online!

See Chandler Carruth and Lars Knoll giving the keynotes at Meeting C++ this year:

Both Keynotes from Meeting C++ 2015 are online!

by Jens Weller

From the article:

Great news: Since yesterday, both of the keynotes from this years Meeting C++ conference are on youtube! Both keynote speakers chose to speak on a specific topic, and delivered very well. There is also a playlist for Meeting C++ 2015.

Fun with folds--Nick Athanasiou

Everything is in the title:

Fun with folds

by Nick Athanasiou

From the article:

A fold is a higher order function (a function that has one or more function parameters and/or returns a function) that is recursively applied over a data structure...

Overload 130 is now available

ACCU’s Overload journal of December 2015 is out. It contains the following C++ related articles.

Overload 130 / PDF

From the journal

Type Mosaicing with Consultables and Delegates

If several classes need to work together lots of boilerplate code is often needed. Nicolas Bouillot introduces type mosaicing to avoid this.

The Universality and Expressiveness of std::accumulate

Folding is a highly generic operation available through std::accumulate. Paul Keir goes beyond reduction, with the help of C++14’s polymorphic lambdas.
QM Bites – The two sides of Boolean Parameters
Boolean parameters are tempting but make life difficult. Matthew Wilson advises us to avoid them (almost) all the time.
Identify your Errors better with char[]
Error codes still get used instead of exceptions. Patrick Martin and Dietmar Kühl consider how to use char arrays for better information.
CPU Clocks and Clock Interrupts, and Their Effects on Schedulers
Instructions to sleep for a second almost never result in precisely one second’s sleep. Bob Schmidt walks us through the mechanics of why.
 

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;
}