December 2014

Let’s play a game: Spot the bug in popular open-source projects—Andrey Karpov

[We don't often link to quiz-like sites, particularly product-specific ones, but in this case we felt that this could be of broad interest to some of our readers. -- Ed.]


The authors of the PVS-Studio analyzer invite you to test your attentiveness:

Let's play a game -- spot the bug in popular open-source projects

by Andrey Karpov

From the article:

Code analyzers never get tired and can find errors a human's eye cannot easily notice. We have picked a few code fragments with errors revealed by PVS-Studio, all the fragments taken from well-known open-source projects.

We invite you to take part in a competition against code analyzers to test your agility by trying to find the errors by yourself. You will be offered 15 randomly selected tasks. Every correct answer earns you one score if you give it within 60 seconds. The code fragments are short and 60 seconds is a fair limit.

Let's examine a couple of examples with errors for you to understand how to give the answer...

Note: This test does not currently support mobile devices. We are working on new version of tests with better mobile devices support, new problems to solve etc. However, it is not implemented yet. We offer you to subscribe on twitter to read about our new and interesting news and to read about new things in a C++ world.

The Evolving Search for Effective C++—Scott Meyers

Scott Meyers' keynote at the Meeting C++ 2014 conference. A short description can be found on 

the presenters blog.

The Evolving Search for Effective C++

by Scott Meyers

Description from the blog:

The video of my keynote address at Meeting C++ 2014 on December 5 has just been posted to the Meeting C++ Channel at YouTube. I was given a long time slot (two hours), so I addressed two rather different topics, both based on my work of the past quarter century identifying and promulgating guidelines for effective C++ programming...

biicode 2.0 is out—biicode Team

biicode, a C++ dependency manager, releases version 2.0

biicode 2.0 is out

by biicode Team

Who's biicode for?

For C/C++ developers that think a dependency manager is needed, biicode is a multiplatform tool and hosting service that allows you to build your projects easily, integrate third party code and reuse code among projects with just #includes.


Software Duct Tape: Binding the C++  Universe Together—Glennan Carnie

In case you missed it last week on Sticky Bits:

Software Duct Tape -- Binding the C++  Universe Together

by Glennan Carnie

From the article:

One of the cornerstones of object-oriented design is the concept of objects interacting by sending messages to form mechanisms – units of higher-order (or ‘emergent’) behaviour.

In order to send a message (in this case, invoke a member function) an object must have a ‘link’ to the target object. That link is formed by building in an association between the two classes as part of the type’s definition.

In this article we look at building associations between classes and forming run-time links so objects can communicate...

Lessons to learn from John Carmack and Oculus [about] the “Modern C++” approach—CoderGears Team

Fresh on CoderGears:

Lessons to learn from John Carmack and Oculus development team when using the “Modern C++” approach

by CoderGears Team

From the article:

In the previous post about Doom3, we discovered that it was developed using the “C with Classes” approach. John Carmack is the main developer and it was between 2000 and 2004, what explains why “Modern C++” approach was not adopted. And, even if “C with Classes” is not recommended, he made some good decisions to have clean code.

John Carmack is now the oculus VR CTO, Oculus VR is an American virtual reality technology company founded by Palmer Luckey and Brendan Iribe. Their first product, still in development, is the Oculus Rift, a head-mounted display for immersive virtual reality (VR).

Oculus provides an SDK which includes its source code, it’s developed using C++.  For this project the Modern C++ approach was adopted. Let’s discover some design and implementation choices of John Carmack and his team...

Quick Q: What is constexpr useful for?—StackOverflow

Quick A: When you need the constant to be available at compile time.

Today on SO:

What are 'constexpr' useful for?

I really can't find any use of it. My first idea was that I could use it to implement 'Design by Contract' without using macros like this:

struct S
    S(constexpr int i) : S(i) { static_assert( i < 9, "i must be < 9" ); }

    S(int i); //external defintion

    char *pSomeMemory;

But this wouldn't compile. I thought we could also use it to reference same-variable without the need of additional memory to be created when we want to avoid the get/setters in order to make instances to one member from users to be read-only:

class S
    int _i;

    const int & constexpr i = _i;

But none of the above actually compiled. Can someone give me some insight why this keyword was being introduced?

Using assertions—Andrzej Krzemieński

Today on Andrzej's blog:

Using assertions

by Andrzej Krzemieński

From the article:

This post is a response to my recent encounters with fellow programmers who appear to me to be missing the point of assertions and fail to appreciate their usefulness. The first post I have ever written here was on assertions, I still find it good, so there is no need to repeat it; here I will only describe how I observe people treat assertions and why I believe it is wrong.

I am reviewing the following code...

Tutorial on Tag Dispatching—Crazy Eddie

Fresh on Crazy Eddie's Crazy C++ (fortunately not entirely true...):

Tutorial on tag dispatching

by Crazy Eddie

From the article:

... There’s been some confused notions passed around recently that lead me to think there needs to be more information about probably one of the simplest, most powerful metaprogramming techniques that exist in C++: tag dispatching. The reason tag dispatching is powerful is that it leverages the language and the compiler to do work for you so that you don’t have to. It’s a technique whereby you use overload resolution rules to decide between otherwise ambiguous functions.

Concepts and tags

The first part to understand with regard to tag dispatching is the idea of “concepts”...

A Tiny Metaprogramming Library—Manu Sánchez

Manu Sánchez is proposing a little-big collaborative challenge to the C++ community. Learning how to build:

A Tiny Metaprogramming Library

by Manu Sánchez

The proposal:

I hope you like this idea. It’s not only me writing crazy meta-stuff, but everybody developing their own metaprogramming library, learning something new each week, and comparing the different approaches each one is taking. I’m the guy who writes this posts, but I can learn a lot with your Tiny Metaprogramming Libraries and your feedback.


Bring named parameters in modern C++—Marco Arena

I’m going to explore some of the classical ways to emulate named parameters in C++ as well as mention new approaches. Part of this work would not have been possible without Davide Di Gennaro's help and suggestions. An entire paragraph was written by Davide.

Bring named parameters in modern C++

by Marco Arena

From the article:

In programming, named parameters refer to a computer language’s support for function calls that clearly state the name of each parameter within the function call itself.[...]Several languages support named parameters (e.g. C#, Objective-C, …). C++ does not.[...]In this post, I’m going to explore some of the classical ways to emulate named parameters in C++ as well as mention new approaches.