December 2015

C++ Core Guidelines Checkers available for VS 2015 Update 1--Andrew Pardoe and Neil MacIntosh

Coding well in C++ is becoming easier:

C++ Core Guidelines Checkers available for VS 2015 Update 1

by Andrew Pardoe and Neil MacIntosh

From the article:

Back in September at CppCon 2015 Neil announced that we would be shipping new code analysis tools for C++ that would enforce some of the rules in the C++ Core Guidelines. (A video of the talk is available here: https://www.youtube.com/watch?v=rKlHvAw1z50 and slides are available on the ISOCpp GitHub repo.)

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

 

CppCast Episode 36: rr with Robert O'Callahan

Episode 36 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Robert O'Callahan from Mozilla to discuss the rr project.

CppCast Episode 36: rr with Robert O'Callahan

by Rob Irving and Jason Turner

About the interviewee:

Robert O'Callahan has a PhD in computer science at Carnegie Mellon and did academic research for a while at IBM Research, working on dynamic program analysis tools. At the same time he was contributing to Mozilla as a volunteer, until he switched gears to work full-time with Mozilla; Robert has been working on what became Firefox for over 15 years, mostly on layout and rendering in the browser engine and on related Web standards like CSS and DOM APIs. Lately he's been devoting about half of his time to rr.

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.

P0143R0: Wording for Modules -- Gabriel Dos Reis

New WG21 papers are available. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: P0143R0

Date: 2015-11-30

Wording for Modules

by Gabriel Dos Reis

Excerpt:

This documents provides formal wording for a module system for C++. This document is to be read in conjunction with document P0142R0 “A Module System for C++”. The proposed wording are with respect to WG21 Committee Draft (N4567)

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.