All posts in "Strong types"

Calling Functions and Methods on Strong Types

Published November 7, 2017 - 7 Comments
Functions methods strong types C++

Strong types are a way to put names over data in code in order to clarify your intentions, and the more I work on it the more I realize how deep a topic that is. So far we’ve seen the following subjects in our series on strong types: Strongly typed constructors Strong types for strong interfaces […]

Making Strong Types Hashable

Published May 30, 2017 - 5 Comments

Strong types are types that are built over primitive types, and add meaning to them. My purpose today is two-fold: showing you how to write an STL-compliant hash function for custom types so that they can be used in unordered containers such as std::unordered_map, making a hash function available for strong types. For more about the motivation […]

Strong Units Conversions

Published May 26, 2017 - 0 Comments

Strong types are a way to add a meaning to objects by giving them a meaningful name, by using types. This lets the compiler, human beings, and developers understand better the intent of a piece of code. We’ve been exploring strong types on Fluent C++. I focus here on how to define strong types conversions. If you want to catch […]

Passing strong types by reference

Published March 6, 2017 - 16 Comments

On Fluent C++ we had already considered passing strong types by references, and realized that this wasn’t such a simple thing to do. To understand why, I suggest you read the problem statement in this previous post before starting this one, so that we are in line. So far the series on strong types contains […]

Strong lambdas: strong typing over generic types

Published February 20, 2017 - 5 Comments

This post is a new one in the series about strong types. I didn’t intend the series to contain more than 3 posts initially, covering the topics of strong types to make interfaces clearer and more robust. But I later encountered a need, still about strongly typing interfaces and that I shall describe in the motivation […]

Passing strong types by reference – First attempt

Published December 12, 2016 - 3 Comments

In this post in the series about strong types, we focus on the need for passing strong types by reference. This is a fairly common use case for strong types, since passing arguments by reference is so common, but I haven’t seen this aspect of strong types treated anywhere else yet. This post is part of the following series: […]

Strong types for strong interfaces

Published December 8, 2016 - 20 Comments

Strong types are a popular topic in the C++ community. In this post I want to focus specifically on how they can be used to make interfaces clearer and more robust. This post in the second one in the series on strong types: Strongly typed constructors Strong types for strong interfaces Passing strong types by reference Strong […]

Strongly typed constructors

Published December 5, 2016 - 8 Comments

This is the first post of a series on the topic of expressive types, that is, types that express what they represent, rather than how they are implemented. By carrying meaning, these types improve the readability and safety of the code. Here is the series about strong types: Strongly typed constructors Strong types for strong interfaces Passing […]