Articles & Books

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

Progress.

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...

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

cpplinks.pngThe 5th episode of the 'most useful C++ links' is now available:

C++ Links #5

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 29th September and 5th of October.

In this week you will find two trip reports from CppCon, an article about std::any (aka modern void*), a video about std::fmt library and many more!

C++ Links - 22nd - 28th September

4th episode of the most useful C++ links smile

C++ Links #4

by Bartlomiej Filipek & Wojciech Razik

From the article:

Welcome to new C++ Links - most important and useful articles, podcasts and videos that happen between 22th and 28th of September.

This week CppCon took place - the biggest C++ conference. In today’s list, you will find the first video from there, about future of C++, you can also see a post about removing duplicate elements from associative containers and an example of really defensive programming.