Articles & Books

Overload 147 is now available

ACCU’s Overload journal of October 2018 is out. It contains the following C++ related articles.

Overload 147 is now available

From the journal:

Are we nearly there yet?
Deciding if you are making progress can be a challenge. Frances Buontempo considers various metrics and their effects. by Frances Buontempo

How to Write a Programming Language: Part 3, The Evaluator
We’ve parsed our tokens: now we need turn them into values. Andy Balaam continues writing a programming language with the evaluator. by Andy Balaam

P1063 vs Coroutines TS: Consensus on High-Level Semantics
Dmytro Ivanchykhin, Sergey Ignatchenko and Maxim Blashchuk argue that we need coroutines TS now to improve-based-on-experience later. by Dmytro Ivanchykhin, Sergey Ignatchenko and Maxim Blashchuk

Implementing the Spaceship Operator for Optional
Comparison operators can get complicated. Barry Revzin explores how the new operator <=> helps. by Barry Revzin

Compile-time Data Structures in C++17: Part 2, Map of Types
Compile time type selection allows static polymorphsim. Bronek Kozicki details an implementation of a compile time map. by Bronek Kozicki

PMR (Polymorphic Memory Resources) fully described—Nico Josuttis

PMR (polymorphic memory resources) are now fully described in:

C++17 - The Complete Guide

by Nico Josuttis

About the article:

This includes:

  • How to use standard memory resources
  • How to define own memory resources (such as a sophisticated new tracker)
  • How to provide PMR support for own types

With this, using a map or unordered_map with elements located close to each other is really easy now.

And if you have to avoid heap memory allocation, this chapter is a must.



How to Use Class Template Argument Deduction—Stephan T. Lavavej


How to Use Class Template Argument Deduction

by Stephan T. Lavavej

From the article:

Class Template Argument Deduction (CTAD) is a C++17 Core Language feature that reduces code verbosity. C++17’s Standard Library also supports CTAD, so after upgrading your toolset, you can take advantage of this new feature when using STL types like std::pair and std::vector. Class templates in other libraries and your own code will partially benefit from CTAD automatically, but sometimes they’ll need a bit of new code (deduction guides) to fully benefit. Fortunately, both using CTAD and providing deduction guides is pretty easy, despite template metaprogramming’s fearsome reputation!

Word Counting in C++: Implementing a Simple Word Counter—Jonathan Boccara

Useful to learn.

Word Counting in C++: Implementing a Simple Word Counter

by Jonathan Boccara

From the article:

Word counts can reveal information about your code, or make an unknown piece of code more expressive to your eyes.

There are online tools to count words in generic text, but most of those I’ve come across are designed around counting words in text and SEO (Search Engine Optimization). Since analysing source code is not the same thing as analysing the text of a blog post, let’s design a tool fit for our needs of counting words in code. This way, we will be able to make it evolve when we discover new tasks to try with our word counter.

Another reason to write our own word counter is that it will let us practice interface design, and also STL algorithms, which are useful to master for coding in C++.

For this first version of our word counter, the objective will be to put together a working prototype. Then we will improve it over future posts, by adding features and by refining its implementation...

C++ Links #6—Bartlomiej Filipek and Wojciech Razik

The next episode of the 'most useful C++ links' is now available:

C++ Links #6

by Bartlomiej Filipek and Wojciech Razik

From the article:

Welcome to new C++ Links - most important and useful articles, podcasts and videos that happen between 6th and 12th of October.

Today you will find a link to Core Guidelines rules about Concepts, a long article about C++17 class template deduction and a video that shows how inline keyword is taken into account by the compiler. At the end, you will also find a bonus!

std::any: How, when, and why—Casey Carter

Do you use it?

std::any: How, when, and why

by Casey Carter

From the article:

C++17 adds several new “vocabulary types” – types intended to be used in the interfaces between components from different sources – to the standard library. MSVC has been shipping implementations of std::optional, std::any, and std::variantsince the Visual Studio 2017 release, but we haven’t provided any guidelines on how and when these vocabulary types should be used. This article on std::any is the second of a series that examines each of the vocabulary types in turn...

“auto to stick” and Changing Your Style—Jonathan Boccara

What do you think?

“auto to stick” and Changing Your Style

by Jonathan Boccara

From the article:

While performing a code review on a refactoring project, I stumbled upon a change that took a line of code from this state:

Widget myWidget{42};

to that:

auto myWidget = Widget{42};

Well, in the actual case the type wasn’t called Widget and the initialization value wasn’t exactly 42. But that’s the gist of it...