Articles & Books

Refactoring from single to multi purpose

Working on an old project, it came to my mind that I do this refactoring from one static path to multiple options for the 2nd time this year...

Refactoring from single to multi purpose

by Jens Weller

From the article:

For the second time this year I'm refactoring a program from a single purpose to have two or more modes of operation. Both times the start and end result is similar, just the processing is different. A classic case of using polymorphism.

The first program was a tool to process videos from speakers, find a face and export the subframe around it into a new video. The first mode was a good approach to test it, and gave results for some speakers. The second mode did a complete scan first, and then gave a smoother video for some videos. Still, both modes had to be retained...

Replacing unique_ptr with C++17's std::variant a Practical Experiment--Bartlomiej Filipek

variant shows his capabilities.

Replacing unique_ptr with C++17's std::variant a Practical Experiment

by Bartlomiej Filipek

From the article:

Some time ago I wrote about a new way to implement runtime polymorphism which is based not on virtual functions but on std::visit and std::variant. Please have a look at this new blog post where I experiment with this approach on my home project. The experiment is more practical than artificial examples.

See advantages, disadvantages and practical code issues.

Concept archetypes--Andrzej KrzemieĊ„ski

Testing custom concepts.

Concept archetypes

by Andrzej Krzemieński

From the article:

Concepts in the form added in C++20 used to be called lite. This is because they do not provide one quite important functionality: having the compiler check if the author of a constrained template is only using operations and types allowed by the constraining concept. In other words, we can say that our template only requires operations A and B to be valid, but we can still use some other operations inside and this is fine with the compiler. In this post we will show how this is problematic, even for programmers aware of the issue, and how to address it with concept archetypes...

Friendly reminder to mark your move constructors noexcept -- AndyG

AndyG warns us that if you're upgrading to Visual Studio 2017, you might be incurring some unexpected performance overhead thanks to better noexcept support.

Friendly reminder to mark your move constructors noexcept

by AndyG

From the article:

Since C++11 we have had the noexcept keyword, which is a promise that the function will not throw an exception (and if it does, go straight to std::terminate, do not pass go). noexcept is nice for two reasons:

  1. The compiler can optimize a little better because it doesn’t need to emit any code for unwinding a call stack in case of an exception, and
  2. It leads to incredible performance differences at runtime for std::vector (and other containers, too)

C++17: Polymorphic Allocators, Debug Resources and Custom Types--Bartlomiej Filipek

Better memory management.

C++17: Polymorphic Allocators, Debug Resources and Custom Types

by Bartlomiej Filipek

From the article:

In my previous article on polymorphic allocators, we discussed some basic ideas. For example, you’ve seen a pmr::vector that holds pmr::string using a monotonic resource. How about using a custom type in such a container? How to enable it? Let’s see.

Announcing Meeting C++ online!

Meeting C++ online is a series of virtual events organized by Meeting C++ for the C++ community.

Announcing Meeting C++ online!

by Jens Weller

From the article:

This year has brought a new age, and Meeting C++ will embrace this with hosting online only events in addition to the yearly conference. Its natural addition to what Meeting C++ already offers for the C++ Community. So Meeting C++ online will be a series of different virtual events organized by Meeting C++ for the C++ community.