Implementing policies • Let's use a policy on overflow
17
Constructor validation logic • Let's use a policy to enforce that quantities are non-negative
18
Effect of constructor validation logic . So, what about the generated code?
19
Starting to define a domain type . We have now restricted both the operations and the range of allowed values
20
Domain types vs primitives • Business rules still exist when using primitives: they are just distributed
21
Compile-time range calculation
22
Scaling and errors • As systems get larger the number of possible combinations of types (and therefore incompatibilities) grows even faster
23
Templates and "concepts lite"
24
Concepts code - first attempt
Description:
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.