February 2015

CppCon 2014 Elevate Your Code to Modern C++11 with Automated Tooling--Peter Sommerlad

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Elevate Your Code to Modern C++11 with Automated Tooling

by Peter Sommerlad

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

This talk will motivate and demonstrate how to transform your existing C++ code into more modern style and better quality. A key to that is refactoring the code into better shape. While manual refactoring can be tedious and error prone the author demonstrates automated refactoring that was created by his students and assistants and himself over the last nine years on the basis of Eclipse CDT. The tooling works with all compilers, because it is independent of one.

For example, we will show how to eliminate unnecessary macros or replace them by type-safe C++11/14 alternative code automatically. Or, to replace pointers, plain arrays and manual memory management by references, smart pointers, std::string, std::array, or std::vector automatically. Also other transformations, such as introducing a template parameter to reduce a coupling to a single concrete type are demonstrated. All with the goal to modernize and hopefully simplify your C++ code. Even if you are not deeply interested in modernizing your code base, some helpful tooling, such as toggling function definitions into a single place, to change their signature, can be of great help. On the other hand, many of the proposed improvements can also be applied with your favorite code editor only more tediously.

Stroustrup named 2015 Fellow by the Computer History Museum -- Rachel Rose

We don't link to all awards, but this is a notable one:

Stroustrup receives 2015 Computer History Museum award

by Rachel Rose

From the post:

The Computer History Museum Fellow Awards honor exceptional men and women whose ideas have changed the world. The fellowship is a lifetime award for individuals who have made major contributions to the computer industry. The list of fellows is a veritable Who's Who of the computer industry...

“This recognizes C++’s place in computing history and also honors the many people who helped make it one of the most successful programming languages ever and the many who used C++ to build awe-inspiring systems,” Stroustrup said of the award.

Convenient Constructs For Stepping Through a Range of Values -- Mikhail Semenov

A timely article, as there has been an extensive flurry of discussion within the committee over the past weekend about defaults for the ranged for:

Convenient Constructs For Stepping Through a Range of Values

by Mikhail Semenov

From the article:

In this article, the following loops are proposed:

for (auto x : step(start, count, step-width)) { ... }

for (auto x : step(count)) {...}

for (auto x : step_backward(count)) {...}

for (auto x : step_to(start, finish, step-width)) {...}

for (auto x : step_until(start, finish, step-width)) {...}

They are based on the C++11 for-range loop. In order to write such loops, the appropriate functions step, step_backward, step_to and step_until have to be implemented.  The article shows their implementation, discusses advantages of such loops and includes the benchmark results.

C++Now 2015 Student/Volunteer Program Accepting Applications

You are a student? Look at this:

C++Now 2015 Student/Volunteer Program Accepting Applications

From the website:

The C++Now Student/Volunteer program was started in 2013 in an effort to encourage student involvement in the C++Now conference and the C++ community. Each year, the conference helps a small group of young programmers attend the conference. In exchange, the students help the C++Now staff in running the conference. Volunteers assist with various on-site tasks, such as recording sessions, escorting keynote speakers and setting up the conference picnic. They are able to attend most sessions. Volunteers receive a waiver of their registration fees and stipends for travel-related expenses may be provided.

CppCon 2014 Type Deduction and Why You Care--Scott Meyers

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Type Deduction and Why You Care

by Scott Meyers

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

C++98 had template type deduction, and it worked so intuitively, there was little need to understand what took place under the covers. C++11 extends type deduction to include universal references, applies it to auto variables and lambda expressions, then throws in a special auto-only deduction rule. C++14 pushes the boundary further, adding two forms of function return type deduction (auto and decltype(auto)) for arbitrary functions and offering auto parameters for lambdas. The result is that what could be treated as a black box in C++98 has become a topic that practicing C++ developers really need to understand. This talk will give you the information you need to do that.

Null Pointer Dereferencing Causes Undefined Behavior

I have unintentionally raised a large debate recently concerning the question if it is legal in C/C++ to use the &P->m_foo expression with P being a null pointer. The programmers' community divided into two camps. The first claimed with confidence that it wasn't legal while the others were as sure saying that it was. Both parties gave various arguments and links, and it occurred to me at some point that I had to make things clear.

Null Pointer Dereferencing Causes Undefined Behavior

by Andrey Karpov

From the article:

This code is incorrect in both C and C++ when the podhd pointer equals 0. If the pointer equals 0, undefined behavior occurs.

 

Cppcheck

I wish to introduce the CppCheck tool to the beginner programmers. Cppcheck is a static analyzer for C and C++ code. It is open-source, free, cross-platform and easy-to-use.

Cppcheck

by Andrey Karpov

From the article:

One of the basic advantages of the Cppcheck analyzer is that it is easy-to-use. It is good to teach and study the static analysis methodology: for instance, you install Cppcheck on a Windows system and get a GUI interface allowing you to immediately start checking your projects.

JSON Voorhees - Killer JSON for C++--Travis Gockel

Yet another JSON library for C++:

JSON Voorhees, GitHub link

by Travis Gockel

From the article:

JSON Voorhees is a JSON library written for the C++ programmer who wants to be productive in this modern world. What does that mean? There are a ton of JSON libraries floating around touting how they are "modern" C++ and so on. But who really cares? JSON Voorhees puts the focus more on the resulting C++ than any "modern" feature set. This means the library does not skip on string encoding details like having full support for UTF-8. Are there "modern" features? Sure, but this library is not meant to be a gallery of them – a good API should get out of your way and let you work. It is hosted on GitHub and sports an Apache License, so use it anywhere you need...

Iterators++, Part 2 -- Eric Niebler

Eric Niebler goes deeper into Iterator details in his new blog post

 

Iterators++, Pat 2

by Eric Niebler

From the article:

This is the third in a series about proxy iterators, the limitations of the existing STL iterator concept hierarchy, and what could be done about it. In the first post I explained what proxy iterators are (an iterator like vector<bool>‘s that, when dereferenced, returns a proxy object rather than a real reference) and three specific difficulties they cause in today’s STL:

  1. What, if anything, can we say in general about the relationship between an iterator’s value type and its reference type?
  2. How do we constrain higher-order algorithms like for_each and find_if that take functions that operate on a sequence’s elements?
  3. How do we implement algorithms that must swap and move elements around, like sort and reverse?