Articles & Books

Guaranteed Copy Elision -- Jonas Devlieghere

Guaranteed Copy Elision deserves some attention!

Guaranteed Copy Elision

by Jonas Devlieghere

From the article:

The new C++17 standard brings many exciting new features. A smaller, more subtle improvement it brings is guaranteed copy elision. The keyword is guaranteed, as copy elision itself has always been part of the standard. Although it might not be a change as radical as, say, structured bindings, I'm very happy to see it made it into the standard.

IIFE for Complex Initialization - Bartlomiej Filipek

Try using IIFE to do a complex initialization of a const variable.

<img alt="IFFE for complex initialization" data-cke-saved-src="https://1.bp.blogspot.com/-9WW-Z66fu78/WB-KKBbQ7SI/AAAAAAAACwI/JhwPEgx4L9sF18ypVHBUJSPSY-X4n7DXACLcB/s1600/iife.png" src="https://1.bp.blogspot.com/-9WW-Z66fu78/WB-KKBbQ7SI/AAAAAAAACwI/JhwPEgx4L9sF18ypVHBUJSPSY-X4n7DXACLcB/s1600/iife.png" 523px;="" height:="" 140px;"="" style="float: right; height: 62px; width: 230px;">

 

IIFE for Complex Initialization

by Bartlomiej Filipek

From the article:

How do you initialize your variables, especially the const ones? What do you do when the code for the initialization is complicated? Do you move it to other method or just write inside the current scope?

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.