Articles & Books

The BooSTL Algorithms: Boost Algorithms That Extend the STL (1/3)--Jonathan Boccara

No need to do them yourself.

The BooSTL Algorithms: Boost Algorithms That Extend the STL (1/3)

by Jonathan Boccara

From the article:

The STL features a proud 105 algorithms, but that is by no means all the algorithms there is in C++.

There are many ways to extend the STL. One of them is to include the STL-like algorithms that are in Boost, which I like to call the BooSTL algorithms!

Trip Report: C++ Standards Meeting in Kona, February 2019--Botond Ballo

Everything you need to know.

Trip Report: C++ Standards Meeting in Kona, February 2019

by Botond Ballo

From the article:

A few weeks ago I attended a meeting of the ISO C++ Standards Committee (also known as WG21) in Kona, Hawaii. This was the first committee meeting in 2019; you can find my reports on 2018’s meetings here (November 2018, San Diego), here (June 2018, Rapperswil), and here (March 2018, Jacksonville). These reports, particularly the San Diego one, provide useful context for this post...

Quick Q: Compile-time loop optimisation

Quick A: each release of C++ allows more things to be done at compile time.

Recently on SO:

Compile-time loop optimisation

In C++14, constexpr function requirements were relaxed.

Previously, in C++11, constexpr functions could only contain typedefs, static_asserts and usings, but only a single return statement.

In C++14, it became possible to use loops in constexpr function bodies.

Because b was declared as constexpr char, it must be evaluated at compile time. The compiler then optimised out the isStringNice function, as it is not used at run time.

How do I design a class so that methods must be called in a certain order?--Raymond Chen

Simple but effective.

How do I design a class so that methods must be called in a certain order?

by Raymond Chen

From the article:

Suppose you have a class with some methods, and the methods must be called in a certain order. For example, suppose your class is for importing photos from a camera. First, you have to specify which camera you are importing from. Then you discover the pictures. Then you have to select which pictures you want to import, and set the options for how you want the download to occur. And finally, you download them...

C++ Insights - Implicit Conversions--Andreas Fertig

A good tool!

C++ Insights - Implicit Conversions

by Andreas Fertig

From the article:

This series is motivated by a brief conversation I had with Andreas. I asked him if he has some use case examples which show how C++ Insights can be helpful when teaching. I think there are many things. This article is the start of a series of five posts by Andreas which I will publish at Modernes C++ because I think C++ Insights is an invaluable tool to get a deeper insight in the C++ compiler magic. In case, you are new to C++ Insights consider this introductory article. Without further ado, Andreas post. When you follow the link near to each example, you can directly analyse the example in C++ Insight...

Quick Q: Deletion of copy-ctor & copy-assignment - public, private or protected?

Quick A: The meaning is the same for the compiler, so chooses what make sense to you.

Recently on SO:

Deletion of copy-ctor & copy-assignment - public, private or protected?

I would put them in the public section.

This is because deleting a constructor or an assignment operator is orthogonal to making them private / protected; and when these aren't deleted, they are public. Putting the deletions in one of those two sections seems to me like hinting "If I hadn't deleted them, I would have made them private/protected" - which is not a message you want to convey in your case.

Note, though, that the compiler doesn't care which section you put the deletion in.

Macro Evil in C++ Code

The C++ language opens extensive opportunities to go without macros. So let’s try to use macros as seldom as possible!

Macro Evil in C++ Code

by Andrey Karpov

From the article:

The ATL library provides such macros, as A2W, T2W and so on for string conversion. However, few people know that it is very dangerous to use these macros inside loops. Within the macro, a call to the alloca function occurs, which will repeatedly allocate memory on each loop iteration on the stack. A program makes show that it works correctly. Once a program starts to handle longer strings and the number of loop iterations increases, the stack can just end at the most unexpected moment.

Template meta-functions for detecting template instantiation--Ivan Čukić

Templates are great.

Template meta-functions for detecting template instantiation

by Ivan Čukić

From the article:

I’ve been playing around with type meta-tagging for my Voy reactive streams library (more on that some other time) and realized how useful it is to be able to check whether a given type is an instantiation of some class template, so I decided to write a short post about it...