Articles & Books

HTML Text Editor - final solution

A quick post on the current - and final - solution to use TinyMCE3 with Qt:

HTML Text Editor - final solution

by Jens Weller

From the article:

In the last post about my HTML Text Editor, I mentioned that while the editor worked like it should, other things didn't. I was able to fix at least some of the driver related issues, but kept seeing random crashes. So I decided to try out a different solution, instead of going on a long and tiring debugging trip.

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.

Toggles in functions—Andrzej KrzemieĊ„ski

A bool or enum by any other name:

Toggles in functions

by Andrzej Krzemieński

From the article:

Have you ever seen a function call like this?

process(true, false);

We are processing something: this should be clear from the context. But what do these parameters mean? What is true and what is false? From the function call we will never figure it out. The code surely isn’t self explanatory.

We will have to stop, and take a look at the declaration, and it does give us a hint:
void process(bool withValidation,
             bool withNewEngine);

Apparently, the author of the function uses the two bools as toggles...

std::transform, a central algorithm—Jonathan Boccara

And why if you want transform_if you'll really appreciate ranges:

std::transform, a central algorithm

by Jonathan Boccara

From the article:

The concept of std::tranform is so useful that there is a name for it, coming from functional programming: map (unrelated to std::map). In fact, we can see it the other way round: the STL takes its root in functional programming, so it is only normal that a central concept in functonal programming gets a central role in the STL...

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...

Overload 137 is now available

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

Overload 137 is now available

From the journal:

Mean Properties
Property based testing is all the rage. Russel Winder walks us through an example of properties an arithmetic mean function should have. by Russel Winder

The Importance of Back-of-Envelope Estimates
Guestimate questions make many people grumble. Sergey Ignatchenko reminds us why they matter. by Sergey Ignatchenko

Multiprocessing and Clusters in Python
Multiprocessing is possible in Python. Silas S. Brown shows us various ways. by Silas S. Brown

doctest – the Lightest C++ Unit Testing Framewor
C++ has many unit testing frameworks. Viktor Kirilov introduces doctest. by Viktor Kirilov

Correct Integer Operations with Minimal Runtime Penalties
Results of C++ integer operations are not guaranteed to be arithmetically correct. Robert Ramey introduces a library to enforce correct behaviour. by Robert Ramey

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.

Using QtCreator together with the Visual Studio Build Tools

A first posting about working with Qt and Visual C++ in QtCreator

Using QtCreator together with the Visual Studio Build Tools

by Jens Weller

From the article:

For a while I've been using QtCreator as my IDE, mostly because its deep integration with Qt, as most of my projects are Qt related. With this, I also preferred (and still do a little) to use the MinGW builds of Qt on Windows. In the past, as GCC was a little bit better with the newer standards, today, well, never change a running system...