Last time we discussed how to use concepts with functions and this time we are going to see how to use concepts with classes. I know it’s not what I promised at the end of the previous article, but I realized that I simply forgot about this episode.
Welcome back to the series on C++ concepts. In the previous article we discussed what are the motivations behind concepts, why we need them. Today we are going to focus on how to use existing concepts. There are a couple of different ways.
As you might know, I’m writing a book, its working title is “The Seniority Trap”. From time to time, I’ll post some parts of it, before it gets released. If you are interested in the updates, please subscribe to my personal blog and let’s connect on Twitter!
The idea of concepts is one of the major new features added to C++20. Concepts are an extension for templates. They can be used to perform compile-time validation of template arguments through boolean predicates. They can also be used to perform function dispatch based on properties of types.
I was looking for some books for these months taking into consideration that I should improve my architecture and design skills. So I recently read Emergent Design and now Refactoring for Software Design Smells. I don’t remember where I saw it recommended, but when I started to browse the book (I use O’Reilly), I saw it was recommended by the ACM fellow, Grady Booch. The person who authored Object-Oriented Analysis and Design With Applications and who said that code should read like well-written prose. It seemed to be a good recommendation.
Was it worth to read the book? Let’s find it out together.