Articles & Books

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.

The BooSTL Algorithms: Boost Algorithms That Extend the STL (3/3)--Jonathan Boccara

The final article.

The BooSTL Algorithms: Boost Algorithms That Extend the STL (3/3)

by Jonathan Boccara

From the article:

The BooSTL algorithms are what we can call the Boost algorithms which are in the same spirit as those of the STL. They encapsulate operations on collections, and being able to use them allows to write (or re-write) more expressive code. To cover all their contents, we split up the articles of the BooSTL into three parts:

  • the BooSTL algorithms on sorting and partitioning,
  • the BooSTL algorithms on searching,
  • the other BooSTL algorithms.

So here we go to cover the rest of the BooSTL algorithms which are not in sorting, partitioning nor searching.

Quick Q: C++ template typedef

Quick A: Use the normal template declaration.

Recently on SO:

C++ template typedef

C++11 added alias declarations, which are generalization of typedef, allowing templates:

template <size_t N>
using Vector = Matrix<N, 1>;

The type Vector<3> is equivalent to Matrix<3, 1>.

The BooSTL Algorithms: Boost Algorithms That Extend the STL (2/3)--Jonathan Boccara

The series continues.

The BooSTL Algorithms: Boost Algorithms That Extend the STL (2/3)

by Jonathan Boccara

From the article:

One good way to extend our knowledge beyond the STL is to learn the Boost STL-like algorithms. I like to call them the BooSTL algorithms. To cover all the contents in this algorithms library, we have chunked up the story into three parts:

  • the BooSTL algorithms on sorting and partitioning,
  • the BooSTL algorithms on searching,
  • the other BooSTL algorithms.

After seeing the BooSTL algorithms on sorting and partitioning, we are now going to focus on BooSTL algorithms on searching...