intermediate

Singleton revisited--Giuseppe Puoti

The use of Singleton is often justified by the will of being able to easily refer to a unique object from any point. Giuseppe Puoti describes an alternative:

Singleton revisited

by Giuseppe Puoti

From the article:

It happens quite often to deal with those annoying objects, used everywhere in your applications. This may be because of a poorly designed application but, sometime, it is simply an inevitable condition...

Reflections on the reflection proposals

Since the overview on the current papers for Kona, I wanted to know more about reflection...

Reflections on the reflection proposals

by Jens Weller

From the article

A few weeks ago I wrote a short overview over the most interesting papers for the current C++ Committee meeting in Kona, Hawaii. The big surprise was that there were many papers on reflection, while there already is a very detailed proposal for reflection.

With the C++ committee currently in Kona discussing lots of proposals, there will be some changes to the on going effort for reflection, but the current proposals are detailed enough to give an overview.

Generating Sequences

A virtual container.

Generating Sequences

By Anthony Williams

From the article:

I was having a discussion with my son over breakfast about C++ and Python, and he asked me if C++ had anything equivalent to Python's range() function for generating a sequence of integers. I had to tell him that no, the C++ standard library didn't supply such a function, but there were algorithms for generating sequences (std::generate and std::generate_n) into an existing container, and you could write something that would provide a "virtual" container that would supply a sequence as you iterated over it with range-for...

Who Owns Who? (Inverting the PathEngine ownership graph) -- Thomas Young

Blog post about API design for objects with dependencies and lifetime management:

Who owns who

by Thomas Young

About the article

A key take-away is that a simple reference counting strategy can be the ideal way to manage lifetimes for API objects, since, as the API designer we can choose to enforce a directed acyclic graph dependency structure.

Lambda Overdose

Do you feel the same way?

Lambda Overdose

by Arne Mertz

From the article:

Lambdas are a nice recent addition to C++. They are cool, they are hip, and they tend to be overused and misused.

Since lambda expressions came up in C++11 and got a huge boost in usability in C++14, they have been all the rage. Don’t get me wrong. Lambdas really are useful and cool and everything. But reading blog posts, the CppLang Slack channel and other sources lately has given me the impression that some people use lambdas in ways they should not be used...

Refactoring the HTML Text Editor for QWebEngine

An update on the HTML Text Editor I hacked with Qt and TinyMCE3:

Refactoring the HTML Text Editor for QWebEngine

by Jens Weller

From the article:

In the last post, I described my experience with using MSVC as a compiler in combination with QtCreator. The reason I set this up was, that with Qt 5.7 QWebkit isn't anymore supported, and the HTML TextEditor based on tinymce3 is a central part of my application. Instead of QWebkit there is now QWebEngine, based on chromium, a very fine solution...

Quick Q: why there is no data-race in the following case?

Quick A: No write is triggered so no data race occurs.

Recently on SO:

why there is no data-race in the following case?

Data races are not static properties of your code. They are properties of the actual state of the program at execution time. So while that program could be in a state where the code would produce a data race, that's not the question.

The question is, given the state of the system, will the code cause a data race? And since the program is in a state such that neither thread will write to either variable, then the code will not cause a data race.

Data races aren't about what your code might do. It's about what they will do. Just as a function that takes a pointer isn't undefined behavior just because it uses the pointer without checking for NULL. It is only UB if someone passes a pointer that really is NULL.

C++ Weekly Episode 50: Inheriting Lambdas vs Generic Lambdas—Jason Turner

Episode 50 of C++ Weekly.

Inheriting Lambdas vs Generic Lambdas

by Jason Turner

About the show:

The last episode of C++ Weekly showed why and where we might want to inherit from lambdas and create a merged lambda with the signatures of two or more other lambdas. In this episode Jason compares a merged lambda with a generic lambda and what the pros and cons might be.

Fold Expressions--Rainer Grimm

Do you know how they work?

Fold Expressions

by Rainer Grimm

From the article:

With fold expressions you can implement the from Haskell known functions foldl, foldr, foldl1 and foldr1 directly in C++. These four functions successively reduce a list to a single value...