All posts in "Expressive code"

std::less and its Modern Evolutions

Published October 29, 2019 - 0 Comments

Since C++98, the C++ standard library has provided std::less, a little component that concisely expresses that you want to use operator< to perform comparisons. std::less is a template class, conceptually equivalent to this: template<typename T> struct less { bool operator()(T const& lhs, T const& rhs) { return lhs < rhs; } }; Let’s see how std::less, as well […]

Expressive Code for State Machines in C++

Published September 24, 2019 - 0 Comments

This is a guest post from Valentin Tolmer. Valentin is a Software Engineer at Google, where he tries to improve the quality of the code around him. He was bitten by a template when he was young, and now only meta-programs. You can find some of his work on Github, in particular the ProtEnc library […]

How to Disable a Warning in C++

Published August 30, 2019 - 0 Comments

As explained in item 53 of Effective C++, you should “Pay attention to compiler warnings”. In the vast majority of cases, the compiler has a good reason to emit them, and in the vast majority of cases, they point out to an oversight in your code. But in a minority of cases, you may want […]

Extract Function: Should I Extract the Condition Too?

Published August 27, 2019 - 0 Comments

Long functions are hard to read, hard to maintain and hard to understand in their entirety. All in all, they contribute to making our developers lives more difficult. But there is one nice thing about long functions: bashing them down into smaller units to make the code more expressive. This is one of the most […]

Why Static Analysis Can Improve a Complex C++ Codebase

Published July 30, 2019 - 0 Comments

Today we have a guest post from Andrey Karpov. Andrey is a co-founder of the PVS-Studio project. He is a Microsoft MVP in the nomination ‘Developer Technologies’ and an author of a large number of articles dedicated to the code quality and error patterns, that C++ developers make. Gradually and imperceptibly we get the situation […]

What Every C++ Developer Should Know to (Correctly) Define Global Constants

Published July 23, 2019 - 0 Comments

Constant values are an everyday tool to make code more expressive, by putting names over values. For example, instead of writing 10 you can write MaxNbDisplayedLines to clarify your intentions in code, with MaxNbDisplayedLines being a constant defined as being equal to 10. Even though defining constants is such a basic tool to write clear code, their definition […]

Expressiveness, Nullable Types, and Composition (Part 2)

Published July 19, 2019 - 0 Comments

This is Part 2 of guest author Rafael Varago‘s series on composing nullable types. In this episode, Rafael presents us absent, a generic library to compose nullable types in C++. In the first part of this series, we saw how C++20’s monadic composition will help us to compose std::optional<T> in a very expressive way. Now […]

Expressiveness, Nullable Types, and Composition (Part 1)

Published July 16, 2019 - 0 Comments

This week we have a series of two articles on composing nullable types written by Rafael Varago. Rafael is a Software Engineer at eGym GmbH, he’s been working with C++, Scala, Go, build systems (e.g Modern CMake), embedded applications, and distributed systems. He enjoys Declarative Programming and Modern C++. Rafael loves learning new technologies and […]

1 6 7 8 9 10 20