Articles & Books

How to Define Comparison Operators by Default in C++--Jonathan Boccara

Do you know?

How to Define Comparison Operators by Default in C++

by Jonathan Boccara

From the article:

Implementing comparison operators in C++ is easier said than done.

Indeed, for most types, if we could talk to the compiler we would say something like: “to order them, use a lexicographical order on their members”.

But when it comes to writing the corresponding code, things get more complicated.

However, a classical technique using std::tuple makes the code much more concise for comparison operators, and it should be used by default. (At least before C++20, as C++20 made comparison operators even easier to write).

Let’s see the technique involving std::tuple and then how the comparison operators situation evolves with C++20...

C++20 modules with GCC11--Niall Cooling

Will you start using them?

C++20 modules with GCC11

by Niall Cooling

From the article:

One of the headline changes of the C++20 standard is the inclusion of modules. Modules promise to significantly change the structure of C++ codebases and possibly signal headers’ ultimate demise (but probably not in my lifetime). It also opens the door to potentially have a unified build system and package manager, similar to Rust’s Cargo package manager; though I imaging standardising a unified build system would be one bloody battle.

Stricter Expression Evaluation Order in C++17--Bartlomiej Filipek

Do you know the rules?

Stricter Expression Evaluation Order in C++17

by Bartlomiej Filipek

From the article:

C++ has many dark corners and many caveats that can cause you to scratch your head in confusion. One of the issues we had until C++17 was the evaluation order of expressions. In this blog post, I’ll show you the new rules that we got in C++17 that made this complicated term much simpler and practical.

Here are the main points for today:

  • What’s the case with make_unique vs unique_ptr<T>(new T) in a function call.
  • What are the new rules for C++17?
  • Are all bugs fixed and now well defined?

Let’s go.

Bringing back the Meeting C++ employer listing

Relaunching another part of Meeting C++ recruiting: the employer listing.

Bringing back the Meeting C++ employer listing

by Jens Weller

From the article

Meeting C++ brings back the listing of C++ employers to its website as part of Meeting C++ recruiting. The companies will be visible in the listing it self, but also have their logos displayed in the job section next to every job advert posted to Meeting C++! Additionally, the companies are also listed in the CV/resume sharing form of Meeting C++.

Moving a project to C++ named Modules--Cameron DaCamara

If you can, start using them!

Moving a project to C++ named Modules

by Cameron DaCamara

From the article:

There is a lot of hype (and perhaps restraint) to using modules in projects. The general blocker tends to be build support, but even with good build support there is a distinct lack of useful resources for practices around moving projects to using named modules (not just header units). In this blog we will take a small project I created, analyze its components, draft up a plan for modularizing it, and execute that plan...

How to Parallelise CSV Reader - C++17 in Practice--Bartlomiej Filipek

Would do it the same way?

How to Parallelise CSV Reader - C++17 in Practice

by Bartlomiej Filipek

Friom the article:

At C++Stories (and in my C++17 book) you can find several articles on Parallel Algorithms introduced in C++17. The examples included in those posts were usually relatively straightforward. How about writing something larger?

In this text, you’ll see how to build a tool that works on CSV files, parses lines into sales records and then performs calculations on the data.

You’ll see how easy it is to add parallel execution to selected algorithms and have a performance improvement across the whole application (for example 4.5x on 6 cores, including file loading). In the end, we’ll discuss problems that we found along the way and possible future enhancements.

Here’s the plan:

  • How to build an application that loads CSV files
  • How to efficiently use parallel algorithms
  • How to use std::filesystem library to gather required files
  • How to use other C++17 library features like std::optional, conversion routines - std::from_chars and string_view
  • Where to add [[nodiscard]] and improve code readability

Let’s go...

Template Instantiation--Rainer Grimm

The series continue.

Template Instantiation

by Rainer Grimm

From the article:

Template instantiation is the creation of a concrete function or a concrete class out of a function template or class template. The creation of template instantiation can be implicit (compiler-generated) or explicit (user-provided)...

Adding a book section to Meeting C++

Meeting C++ has now its own C++ book section:

Adding a book section to Meeting C++

by Jens Weller

From the article:

The section offers a listing of current C++ books, currently 14 books by various authors such as Bjarne Stroustrup or Rainer Grimm! More books will be listed in the future, as not all authors had yet time to list their books. July/August is a holiday month after all, though that might give you the time to read a book!