Articles & Books

Demystifying constexpr-Edouard from quasardb

Compilation time computations are good!

Demystifying constexpr

by Edouard from quasardb

From the article:

C++ 11 and C++ 14 came with a lot of new features. People tend to focus on lambdas and rvalue references, but today I’d like to talk about constexpr.

In this post we'll only talk about constant expressions as in C++ 14. There is absolutely no point to restrict yourself to C++ 11 in 2016. C++ 14 is really C++ 11 Service Pack 1, so if you missed the update, go straight to C++ 14!

Leaky Lambdas -- Adi Shavit

There is a whole host of powerful closure critters that can squeeze into a captureless lambda.

Leaky Lambdas

by Adi Shavit

From the article:

It turns out that even captureless lambdas (which are e.g. convertible to function pointers) can see, hear, sniff and use certain things outside their own scope in their enclosing closure!

Lambda Magic ✨ -- Adi Shavit

Are C++ lambdas magical?

Lambda Magic ✨

by Adi Shavit

From the article:

 

"Like fairies, captureless lambdas are pure and magical creatures.
Unlike fairies, captureless lambdas can be converted to function pointers."

6 Tips to supercharge C++11 vector performance--Deb Haldar

Discussion on how we can efficiently use std::vector<T> container.

6 Tips to supercharge C++11 vector performance

by Deb Haldar

From the article:

Vector is like the swiss army knife of C++ STL containers. In the words of Bjarne Stroutsoup – “By default, use Vector when you need a container”. For mere mortals like us, we take this as gospel and just run with it. However, Vector is just a tool and like any tool, it can be used both effectively or ineffectively.

In this article we’ll look at 6 ways to optimize usage of vectors. We’ll look at both efficient and inefficient ways to perform the most common programming tasks using vectors, measure the performance gain we obtain by using vectors efficiently and try to understand why we’re getting the performance gain.

Help me sort out the meaning of "{}" as a constructor argument--Scott Meyers

Discussion on "Distinguish between () and {} when creating objects".

Help me sort out the meaning of "{}" as a constructor argument

by Scott Meyers 

From the article:

My experiments showed that one factor affecting whether "{{}}" as an argument list yields a zero-length std::initializer_list<T> was whether T had a default constructor, so I threw together some test code involving three classes, two of which could not be default-constructed. I then used both "({})" (note the outer parentheses) and "{{}}" as argument lists to a constructor taking a std::initializer_list for a template class imaginatively named X. When the constructor runs, it displays the number of elements in its std::initializer_list parameter.

When type inference fails -- Krzysztof Ostrowski

C++11 re-introduces auto keyword that enables basic type inference. Using auto not only improves code readability.

When type inference fails

by Krzysztof Ostrowski

From the article:

Use of type inference puts impact on what is possible to be done with certain value, i.e. on its interface or concept it models, rather than on its concrete type. Unfortunately, auto does type inference locally, thus is not such powerful as we might expect. Here follows some examples of auto-inference failures.

Infographics: Operation Costs in CPU Clock Cycles--“No Bugs” Hare

A very interesting article about the cost of our basic operations.

Infographics: Operation Costs in CPU Clock Cycles

by “No Bugs” Hare

From the article:

Whenever we need to optimise the code, we should profile it, plain and simple. However, sometimes it makes sense just to know ballpark numbers for relative costs of some popular operations, so you won’t do grossly inefficient things from the very beginning (and hopefully won’t need to profile the program later �� )...

Terminators--Adi Shavit

Do you know how a program ends?

Terminators

by Adi Shavit

From the article:

A GraphViz diagram that shows both normal and unexpected program termination flows in C++.

There are multiple ways a C++ program may terminate. These include both normal and unexpected termination.
This GraphViz diagram shows the program termination flows as defined by the standard...