Articles & Books

How to Iterate Through Directories in C++

Do you know how to iterate through directories in modern C++? How to work with std::filesystem to solve this task?

How to Iterate Through Directories in C++

by Bartlomiej Filipek

From the article:

How would you implement a function that searches for files with a given extension? For example, finding all text files? or *.cpp files? To code that solution you need a way to iterate through directories. Is that possible in C++ out of the box using the standard library? Let’s see some techniques and new elements that C++17 added.

ACCU - Trip Report--Ori Ben-Shir

Another one.

ACCU - Trip Report

by Ori Ben-Shir

From the article:

I was attending this year ACCU conference, and I am very eager to share my impression of the conference. ACCU is an annual conference located in the lovely city of Bristol. The conference is mostly dedicated to C++ developer. While C++ developers are in mind, the conference is not limited to C++ material, and it includes talks for various topics and even some other programming languages. Yes, there was a Rust talk and even a workshop this year.
It was the first time I have attended a big conference. And I must admit it was a great pleasure! I’m in love with the concept of technical talks. I find it to be the most effective learning method for me. The opportunity to meet a lot of tech enthusiastic is both fun and enriching. Wrapping it all with a vacation for such a lovely city such as Bristol is immensely satisfying. If you have the opportunity, I encourage you to attend this conference next year. I also think the organizers did a great job. I genuinely like the extra social session. The pub quiz, for instance, was perfect, though some of the code samples from it were as far from perfect as possible.

I have a lot to say about the content itself. I tend to believe I have more to say than you want to read. So let’s focus on some of the talks I think are more relevant...

ACCU 2019 trip report--Mathieu Ropert

Learn about what happened.

ACCU 2019 trip report

by Mathieu Ropert

From the article:

This year’s edition of ACCU was held from April 10th to April 13th, in Bristol as always. I arrived a day earlier from Paris after a short stop in France which was supposed to offer some supply of good weather and trips to a few winemakers in preparation for the harsh conditions of Great Britain.

From the start things went awry as I could only spare half an hour for a visit to a winemaker in Vouvray who turned out to be quite forgettable, not to mention the weather that was only barely keeping it up together. Still I didn’t immediately notice that something was off, having spent the pasts months enduring the cold winter of Sweden. It took a second flight from Paris to Bristol to realize it: spring is there (although a couple of Bristol locals apologized for the weather being unexpectedly non-terrible)...

Quick Q: Does the default constructor initialize built-in types?

Quick A: No.

Recently on SO:

Does the default constructor initialize built-in types?

Implicitly defined (by the compiler) default constructor of a class does not initialize members of built-in types.

However, you have to keep in mind that in some cases the initialization of a instance of the class can be performed by other means. Not by default constructor, nor by constructor at all...

Quick Q: Reusing a moved container?

Quick A: clear() to make sure and use it as normal.

Recently on SO:

Reusing a moved container?

From section 17.3.26 of the spec "valid but unspecified state":

an object state that is not specified except that the object’s invariants are met and operations on the object behave as specified for its type [ Example: If an object x of type std::vector<int> is in a valid but unspecified state, x.empty() can be called unconditionally, and x.front() can be called only if x.empty() returns false. —end example ]

Therefore, the object is live. You can perform any operation that does not require a precondition (unless you verify the precondition first).

clear, for example, has no preconditions. And it will return the object to a known state. So just clear it and use it as normal.

Report from the February 2019 ISO C++ meeting (Core Language working group)--Jason Merrill

Short and sweet.

Report from the February 2019 ISO C++ meeting (Core Language working group)

by Jason Merrill

From the article:

The February 2019 ISO C++ meeting was held in Kailua-Kona, Hawaii. As usual, Red Hat sent three developers to the meeting: I attended in the Core Language working group, Jonathan Wakely in Library, and Thomas Rodgers in SG1 (parallelism and concurrency). The meeting went smoothly, although there was significant uncertainty at the beginning where we would end up. In the end, Modules and Coroutines were accepted into the C++20 draft, so now we have our work cut out for us nailing down the remaining loose corners. Here ar highlights from the meeting...

The Day I Fell in Love with Fuzzing--Chris Wellons

Do you know about it?

The Day I Fell in Love with Fuzzing

by Chris Wellons

From the article:

In 2007 I wrote a pair of modding tools, binitools, for a space trading and combat simulation game named Freelancer. The game stores its non-art assets in the format of “binary INI” files, or “BINI” files. The motivation for the binary format over traditional INI files was probably performance: it’s faster to load and read these files than it is to parse arbitrary text in INI format...

How to Emulate the Spaceship Operator Before C++20 with CRTP--Henrik Sjöström

To wait until the real thing.

How to Emulate the Spaceship Operator Before C++20 with CRTP

by Henrik Sjöström

From the article:

Making a class comparable is usually something of a chore. In C++20 we’ll get the “three-way comparison operator” or informally spaceship operator <=>. It will allow the compiler to create comparison operators when we want a simple lexicographical comparison and when we have a more complex comparison we only need to implement a single operator to be able to do all comparisons...

Overload 150 is now available

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

Overload 150 is now available

From the journal:

This means war!.
Careless use of language can upset people. Frances Buontempo asks what we can do to make the developer experience better.

NullableAttribute and C# 8.
C# 8 will bring many new features. Jon Skeet investigates the metadata representation of Nullable Reference Types.

lvalues, rvalues, glvalues, prvalues, xvalues, help!.
C++11 introduced new value categories. Anders Schau Knatten explains his way of thinking about them.

Modern SAT solvers: fast, neat and underused (part 1 of N).
SAT solvers can quickly find solutions to Boolean Logic problems. Martin Hořeňovský demonstrates how this can be used to solve arbitrary Sudoku puzzles.

The Duality….
Genetic algorithms can find solutions that other algorithms might miss. Anders Modén discusses their use in conjunction with back-propagation for finding better solutions.

Blockchain-Structured Programming.
Coins are a wedge-shaped piece used for some purpose. Teedy Deigh shares her angle on the technology underpinning crypto-currencies.