Blog du développeur

I'm the new assistant chair of SG 9, the study group for std::ranges!

March 8th, 2024

— by Jonathan Müller

In a week, the C++ standardization committee is meeting in Tokyo, Japan, to continue work on C++26. It will be my first meeting with an official role as assistant chair of SG 9.

Read more

Parsers vs Unicode

February 22nd, 2024

— by Arno Schödl

We think that keeping parser libraries Unicode-agnostic is the way to go.

Read more

Detecting multiple instantiations

January 24th, 2024

— by Toon Baeyens

How can a function know if it already has been instantiated before? Ideally this detection should happen during compilation. However, this is not possible in all cases. In this post we dive into stateful metaprogramming and throwing errors before main.

Read more

Enforcing that static local variables only exist once

December 27th, 2023

— by Bernardo Sulzbach

C++ static local variables offer a good solution for some pertinent engineering problems. However, with code getting increasingly more generic, it’s too easy to end up with multiple instances of what should have been a singleton. To fix that, we came up with a zero-cost, compile-time check that a static local variable is instantiated at most once in the whole program.

Read more

C++ needs undefined behavior, but maybe less

November 20th, 2023

— by Jonathan Müller

The C++ standard does not specify all behavior. Some things are up to the implementation, while other operations are completely undefined, and the compiler is free to do whatever it wants. This is essential for some optimizations but can also be dangerous. The newly proposed erroneous behavior addresses it, but it cannot be used to eliminate all undefined behavior.

Read more

By Default Different

September 28th, 2023

— by Arno Schödl

Sometimes, you need to register a name with your environment, like a named mutex to be shared across processes, a Win32 user-defined message or a file name for shared memory backing. And you must make sure that it does not clash with someone else's name - and that someone else could be you!

Read more

Compile-time sizes for range adaptors

August 29th, 2023

— by Jonathan Müller

For some ranges, like std::array<T, N>, the size is known at compile-time. Range adaptors like transform don't change the size of the underlying range, so they should conditionally provide the size at compile-time as well. How do we implement that without causing code duplication with the existing .size() member function that provides the size at runtime?

Read more

The new static constexpr std::integral_constant idiom

August 7th, 2023

— by Jonathan Müller

If your type provides a property with a compile-time known value (like the size of a std::array), consider using a static constexpr std::integral_constant member for it. This allows multiple convenient access syntaxes with only a single declaration.

Read more

Should we stop writing functions?

July 25th, 2023

— by Jonathan Müller

... and use named lambdas instead? This prevents ADL, gives you more control over overloading, and template parameters. The standard library has started using it in places, should we?

Read more

Event or no Event?

July 13th, 2023

— by Arno Schödl

We have a cross-platform UI library with widgets. UI widgets by nature serve two masters: The code using them wants to style them and prepopulate their content. The user using them wants to interact with them and modify their content. Therefore, widgets typically offer functions to modify their properties, including the content, and also events that notify about content changes. For example, an edit box may offer a SetText function and a OnTextChange event. Here is the question: If SetText modifies the text, should the OnTextChange event fire?

Read more

Constrain your user-defined conversions

July 5th, 2023

— by Jonathan Müller

By default, user-defined conversion operators allow additional standard conversions afterwards. We can and should disable that by turning it into a constrained template.

Read more

Trip report: Summer ISO C++ Meeting in Varna, Bulgaria

June 19th, 2023

— by Jonathan Müller

The ISO C++ committee met in Varna, Bulgaria last week to start in C++26. Jonathan shares his experience.

Read more

Don‘t Make a Hash of it

April 25th, 2023

— by Arno Schödl

Composing streaming hashes has its pitfalls. Treat it like serialization to avoid them.

Read more

Meaningful Exceptions

March 31st, 2023

— by Arno Schödl

There are many APIs which on error throw exceptions. Or we write wrappers that turn error codes into exceptions. Is that a good idea?

Read more

An Actually Helpful Character Type

March 5th, 2023

— by Arno Schödl

As we have seen last time, having char8_t is not terribly useful. But we discovered that another character type is actually quite useful.

Read more

char8_t Was a Bad Idea

February 20th, 2023

— by Arno Schödl

We recently pondered whether to change all our chars to C++20 char8_t and decided against it, at least for now. At the face of it, adding char8_t seems straight-forward and appealing. There is already a char16_t and char32_t for UTF-16 and UTF-32 strings, so why not have a char8_t for UTF-8 strings?

Read more

Evil Reentrance

February 6th, 2023

— by Arno Schödl

Everyone knows parallel programming is hard, and we talk about it a lot. We talk much less about which I think of as the little brother of parallel programming and also a popular source of bugs in complex systems: reentrance.

Read more

The Merits of optional<T const&>

January 23rd, 2023

Passing function parameters by const& is very common. Now, what do we do if such a parameter is optional? std::optional does not allow T to be a reference.

Read more

When Order Matters

January 10th, 2023

— by Arno Schödl

Last time, I talked about inlining of single-call functions. In fact, there are situations where even for functions called multiple times, inlining functions into a larger one is beneficial.

Read more

Always Inline Single-Call Functions

December 30th, 2022

— by Arno Schödl

Conventional coding rule wisdom says that functions can be too long and then must be broken into shorter ones. In this post we discover distinct disadvantages when it comes to reading and refactoring which we have not seen discussed elsewhere.

Read more

Poor Man's Exception

December 19th, 2022

— by Arno Schödl

Let’s say we are performing a sequence of operations. Now, let’s assume each operation can fail, and returns false if it does. And if an operation fails, we want to abort and skip all subsequent operations. This post explores an alternative to if-cascades and exceptions to implement this.

Read more

The Value of Canonical Code

December 7th, 2022

— by Arno Schödl

Often there are different ways of how to write a particular piece of code. It is a good idea to have agreement on which code to pick. At think-cell, we call this the canonical solution. In this post we discuss how to find it and why this is important.

Read more

Properties (2)

November 30th, 2022

— by Volker Schöch

Meet the concept of hidden state: We define hidden state as state (information) that is represented and maintained in a data structure, but is not discernible by the user. Everybody who designs data structures frequently meets hidden state, whether they like it or not.

Read more

Properties (1)

November 23rd, 2022

— by Volker Schöch

Let's talk about a useful data structure for fonts. For the sake of this article, let's assume that a font consists of just a font face, a size and a flag for boldness. Turns out that even this simplified view of fonts is very useful in many use cases we encounter in our software.

Read more

tc::change

November 16th, 2022

— by Arno Schödl

Welcome to this blog of our development work at think-cell. It will be mainly about programming in general and more specifically about C++. Our platforms are mainly Windows and macOS, with a bit of web development sprinkled in. We will write about anything that comes to our mind, architectural decisions, little nuggets of wisdom we found or rants about bugs in 3rd party software that leave us frustrated. I want to get started with a little utility that proved surprisingly useful for us and that has a bit more thinking behind it than is apparent at first sight.

Read more


Inscrivez-vous pour recevoir les mises à jour du blog

Ne manquez pas les nouvelles publications ! Inscrivez-vous pour recevoir une notification chaque fois que nous publions un nouvel article.

Il vous suffit de soumettre votre adresse e-mail ci-dessous. Soyez assuré(e) que votre adresse e-mail ne sera pas transmise à des tiers.

Veuillez consulter notre politique de confidentialité pour en savoir plus sur la manière dont nous protégeons vos données personnelles.

Partager