intermediate

The C++ highlights and more of GCC 5.1

The release of GCC 5.1 is a highlight, here is an overview on the most important new things:

The C++ highlights of GCC 5.1 and more

by Jens Weller

From the article:

Just recently, GCC 5.0 has been released as GCC5.1, the not only the newest version of GCC, but also bumping up the version number from 4 to 5. This release is a major milestone for GCC, but also for C++, as it brings full C++14 support, but yet not C++11(std=c++11) as the new default...

Coupling and Cohesion -- Paul Watt

coupling-lego.PNGA solid and entertaining treatment with good C++ examples:

Coupling and Cohesion

by Paul Watt

From the middle of the article:

... To further clarify this statement, not all code should be reused.

Why Not?

Because the majority of software that is written is designed to fulfill a very specific purpose. The challenge is to find the balance point between generic reusable building blocks, and a tool or application that meets a need. Generic software components are very valuable, however, they are almost useless by themselves...

And gems like this:

... For every statement of code that you write or use, you should ask the question: Does this add value or risk?

CppCon 2014 Exception-Safe Code, Part IIIā€”Jon Kalb

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:

Exception-Safe Code, Part III

by Jon Kalb

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Are you 100% confident that your code is exception-safe?

Safe usage of exceptions is a non-trivial problem that the industry has struggled with for the better part of two decades. If you have fear, uncertainty, or doubt about exception safety or just want to see the best practices for using exceptions in C++ and/or C++11/14, this session is for you. We’ll start with “What is the problem we are trying to solve?” and discuss alternatives, acknowledge the challenges associated with exception usage, and cover some well-meaning but misguided attempts at safety. I will then present a set of guidelines that are the basis for safe exception usage and solid implementation techniques, including how to transition from an exception-unsafe legacy code base.

When we are finished you will know how to produce code that is easier to write, easier to understand, faster, and 100% robust in the face of exceptions.

CppCon 2014 Exception-Safe Code, Part II--Jon Kalb

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:

Exception-Safe Code, Part II

by Jon Kalb

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Are you 100% confident that your code is exception-safe?

Safe usage of exceptions is a non-trivial problem that the industry has struggled with for the better part of two decades. If you have fear, uncertainty, or doubt about exception safety or just want to see the best practices for using exceptions in C++ and/or C++11/14, this session is for you. We'll start with "What is the problem we are trying to solve?" and discuss alternatives, acknowledge the challenges associated with exception usage, and cover some well-meaning but misguided attempts at safety. I will then present a set of guidelines that are the basis for safe exception usage and solid implementation techniques, including how to transition from an exception-unsafe legacy code base.

When we are finished you will know how to produce code that is easier to write, easier to understand, faster, and 100% robust in the face of exceptions.

Don't blame initializer_list prematurely -- Marco Arena

A post on three common pitfalls regarding initializer_list...or not? 

Don't blame initializer_list prematurely

by Marco Arena

From the article:

“Cannot convert initializer list argument to ‘int*'”. People started trying to figure out why initializer_list was not covertible to int[]. [...] A gentleman spotted the following in the dark corners of the codebase:

vector<YahtzeeGame> games;
games.push_back(make_tuple(5, 6, 2));
games.push_back(make_tuple(5, 6, 3));
games.push_back(make_tuple(5, 6, 4));
// other stuff

Excited about C++11, he tried to refactor:

vector<YahtzeeGame> games = { {5, 6, 2}, {5, 6, 3}, {5, 6, 4} };
And does it compile? ...

Making Boost.Signals2 More OOP-Friendly -- Pavel Frolov

This article shows how modern C++ features, notably variadic templates and perfect forwarding, can be used to implement a generic variant of observer pattern without the help of either macros or proprietary compiler extensions.

Making Boost.Signals2 More OOP-Friendly

by Pavel Frolov

From the article:

The observer design pattern is by far the most popular and widely known among behavioural patterns. Unfortunately, unlike other mainstream languages out there, the C++ standard library doesn’t provide out of the box observer implementation. Luckily, Boost contains Signals2, a signal/slot library which can serve as a basis for an observer. Using Signals2 as it is, however, is not so convenient in object-oriented program due to the need of manually coded register and notify class methods for each of signal/slot pairs. This article suggests an observable mixin which attempts to solve the outlined problem.

CppCon 2014 Exception-Safe Code, Part I--Jon Kalb

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:

Exception-Safe Code, Part I

by Jon Kalb

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Are you 100% confident that your code is exception-safe?

Safe usage of exceptions is a non-trivial problem that the industry has struggled with for the better part of two decades. If you have fear, uncertainty, or doubt about exception safety or just want to see the best practices for using exceptions in C++ and/or C++11/14, this session is for you. We'll start with "What is the problem we are trying to solve?" and discuss alternatives, acknowledge the challenges associated with exception usage, and cover some well-meaning but misguided attempts at safety. I will then present a set of guidelines that are the basis for safe exception usage and solid implementation techniques, including how to transition from an exception-unsafe legacy code base.

When we are finished you will know how to produce code that is easier to write, easier to understand, faster, and 100% robust in the face of exceptions.

CppCon 2014 0xBADC0DE--Jens Weller

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:

0xBADC0DE

by Jens Weller

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

My motivation for this talk is my own expierence as a freelancer and trainer. I have seen a lot of good and bad code in different places. As a freelancer I often had to deal with different, unknown and often large codebases. This talk tries not only to show examples of bad code, but also to analyze why it exists in the first place, and how to deal with it or fix it. I'll visit anti-patterns, but this talk is not about anti-patterns, as that would only spotlight one of the many problems.

CppCon 2014 Quick Game Development with C++11 / C++14--Vittorio Romeo

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:

Quick Game Development with C++11 / C++14

by Vittorio Romeo

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Modern C++ has made game development a much more pleasurable experience. Features such as smart pointers and variadic templates are invaluable in speeding up the development process and in making the code cleaner and more robust. New easy-to-use multimedia libraries such as SFML, SDL and Cinder make dealing with graphics, sounds and input very easy, and work well with modern code principles. This talk guides the audience through the creation of an Arkanoid/Breakout clone in under 200 lines of code, using C++11/C++14 features and idioms. Chronologically sequential code segments, compiled and executed one by one, will show the attendees how a game is created from scratch, slowly becoming a playable product, step by step. The end result will be a small game, completely written in modern C++ code. Topics covered will range from basic graphics programming to entity management and collision detection/response.

Lock-Free Data Structures. The Evolution of a Stack -- Max Khiszinsky

Max Khiszinsky describes in his recent blog article different approaches to develop concurrent containers.

Lock-Free Data Structures. The Evolution of a Stack

by Max Khiszinsky

From the article

Describing the known algorithms would be quite boring, as there would be a lot of [pseudo-]code, plenty of details that are important but quite specific. After all, you can always find them in the references I provide in articles. What I wanted was to tell you an interesting story about exciting things. I wanted to show the development of approaches to designing concurrent containers.