Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

The C++ Type System Is Your Friend

ACCU Conference via YouTube

Overview

Explore how leveraging the C++ type system and templates can produce fast, small, safe, generic, and reusable code in this ACCU 2017 conference talk. Discover techniques for creating type-rich APIs that enhance error prevention and readability, while utilizing template techniques to develop reusable libraries for operators and their relationships with zero run-time overhead. Learn about physical types, the Whole Value pattern, and how to implement policies for constructor validation logic. Examine the benefits of domain types over primitives, compile-time range calculation, and scaling considerations for larger systems. Gain insights into templates and "concepts lite" to improve code safety and performance in C++ programming.

Syllabus

Intro
Safe, performant, reusable code
(Mostly) typeless programming
Machine-typed programming
Type-rich programming
The miracle of compilation Runtime
Physical types
Whole Value pattern
Templates to the rescue
Adding checking of values
Reuse through client libraries
Physical quantities and dimensions
Tailoring operations - library code
Tailoring operations - client code
Templates and policies
Implementing policies • Let's use a policy on overflow
Constructor validation logic • Let's use a policy to enforce that quantities are non-negative
Effect of constructor validation logic . So, what about the generated code?
Starting to define a domain type . We have now restricted both the operations and the range of allowed values
Domain types vs primitives • Business rules still exist when using primitives: they are just distributed
Compile-time range calculation
Scaling and errors • As systems get larger the number of possible combinations of types (and therefore incompatibilities) grows even faster
Templates and "concepts lite"
Concepts code - first attempt

Taught by

ACCU Conference

Reviews

Start your review of The C++ Type System Is Your Friend

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.