Blog de desarrolladores
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
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
Regístrese para recibir actualizaciones del blog
¡No se pierdas las nuevas publicaciones! Regístrese para recibir una notificación cada vez que publiquemos un nuevo artículo.
Simplemente envíe su dirección de correo electrónico a continuación. Le garantizamos que no se reenviará su dirección de correo electrónico a ningún tercero.
Consulte nuestra política de privacidad, donde indicamos cómo protegemos sus datos personales.