Simplest Strong Typing instead of Language Proposal ( P0109 ) - Peter Sommerlad - [CppNow 2021]

preview_player
Показать описание
#Boost #Cpp #CppNow
CppNow Twitter: @CppNow
------
Safer and simpler C++ is the goal of many things I am doing. C++ has a rich and strong type system, except for the holes inherited from C. In this talk we will learn how to circumvent those holes and define useful types for stuff where otherwise we would have used plain ints, doubles, or strings. It demonstrates the simplest strong type mechanism of C++ that also works in C, but also a framework that was designed to make it even simpler to define strong types than what was proposed in P0109 as a language extension. We will also look at the perils of using size_t for capacity, indexing and size of containers and how strong types would have prevented some of their constructor usability issues. This leads to the duality of types used for a 1d vector space with a corresponding affine space that might share internal representation but not the corresponding operations, such as representing number of elements versus the distance between elements in an array.

------
Peter Sommerlad
Better Software

Peter Sommerlad was director of IFS Institute for Software at FHO/HSR Rapperswil, Switzerland. Peter is co-author of the books POSA Vol.1 and Security Patterns and contributed to "97 things every programmer should know". His goal is to make software simpler and safer by Decremental Development: Refactoring software down to 10% its size with better architecture, testability and quality and functionality. To reach that goal his team and students created the C++ IDE Cevelop. Peter is a member of MISRA-C++, Hillside, ACM, IEEE Computer Society, SI, ACCU, and the ISO C++ standardization committee.
------

May 1, 2022 - May 6, 2022 - Aspen, Colorado
-------------------------
---

*--*

---
Рекомендации по теме
Комментарии
Автор

This was a great talk. The presenter did not just promote his library, he explained how it works and how to apply these techniques to your code design. I hope that there are going to be more talks like this.

aleksandarnikolic
Автор

You can't constrain the mix-in parameter ahead of time, but you can _validate_ it after the fact. Put static_assert after the class body or inside one of the members. You'll get a clear error if you pass in an unsuitable type. The concept constraint would allow overloading, but we don't need that feature: we just want an error if you use the wrong type.

JohnDlugosz
Автор

One manual spaceship might cover both the less than and greater than code. Though it doesn't seem to define the == and != unless it's default.

Sebanisu
Автор

Great talk itself, but I don't think that at the end solution is "simple" in any means.

mapron