markus

About markus

Markus Klein works as a Software Engineer at Blue Yonder.

Assignment operators in C++11

Move Semantics are a game changer on how we return values and pass arguments in C++11. In this post we concern ourselves with the best way to implement an assignment (‘ =‘) operator. If rvalues and move semantics are all new for you, you might want to read Michael’s post I like to std::move it first.
Continue reading “Assignment operators in C++11” »

Expressing preconditions with invariants of parameter types

Everyone who has read Scott Meyer’s books knows: it is a good idea to make your code easy to use correctly and difficult to use incorrectly. In this light, we may be able to improve on the ifs we routinely use to check our functions’ preconditions.

The basic idea is to remove all the ifs that check for error conditions at the beginning of your function’s body by providing type parameters that already give sufficiently strong guarantees.

Continue reading “Expressing preconditions with invariants of parameter types” »