In the previous article on strong types, we set out to find how to use strong types for safe indexing in collections. More precisely, if we have two vectors with two indices to access them, how can we use strong types to make sure we use the right index for the right vector, and that […]
Strong types make code safer and more expressive by using the type system to identify individual objects. For example, to instantiate a class Rectangle with a certain width and height, we could write this: Rectangle myRectangle{4, 5}; But then it isn’t clear for a reader of the code which of the two parameters is the […]
Do we need a special strong type library for collections? Or can we strongly type collections like we do for any object? If you’re joining us right now and haven’t read the previous articles on strong types, long story short, a strong type is a type used instead of another one in order to add […]
Guest writer Vincent Zalzal talks to us about lightweight strong types. Vincent is a software developer working in the computer vision industry for the last 12 years. He appreciates all the levels of complexity involved in software development, from how to optimize memory cache accesses to devising algorithms and heuristics to solve complex applications, all […]
A couple of weeks ago I had the opportunity to speak at Meeting C++, in Berlin. This talk has come out on Youtube recently, and I’d like to share it with you. This presentation sums up the fundamental aspects of strong typing in C++ as I see it. I hope you enjoy it! Of course, […]
What’s in a function’s interface? In most languages, a function’s interface has 3 main parts: the function’s name: it indicates what the function does, the function’s parameters: they show what the function takes as input to do its job, the function’s return type: it indicates the output of the function. ReturnType functionName(ParameterType1 parameterName1, ParameterType2 parameterName2); […]
Both strong types and optionals are useful tools to make our interfaces more expressive. Could they be used in synergy to make one benefit from each other? The contents of this post are at an experimental stage. They are laid out here to expose a problem and a possible solution, and as a basis for […]
Strong typing consists in creating a new type that stands for another type and adds meaning through its name. What would it look like to apply this idea to template interfaces? Disclaimer: What you’ll see in this post is experimental, and it’d be great to have your feedback on it at the end. Strong types for […]
Strong types and implicit conversions, doesn’t this sound like incompatible features ? It can be argued that they are compatible, in fact. We saw why it could be useful to inherit from the underlying type’s features, and if the underlying type is implicitly convertible to something then you might want to inherit that feature too […]
We’ve seen how strong types helped clarifying function interfaces by being explicit about what input parameters the function expected. Now let’s examine how strong types help clarifying functions that return several outputs. We’ll start by describing the various ways to return several outputs from a function in C++, and then see how strong types offer an […]