C++ provides a really advanced type system. A prime example of its application is std::chrono: It uses the type system to create different types for different units and prevent programmer errors.
But the same principle can be applied to your everyday code - this talk is going to show you how. I’ll present simple techniques to leverage the C++ type system to detect and prevent possible bugs at compile-time. We’ll start with the bare minimum - minimize implicit conversions, and then quickly go to more advanced things like using types to express preconditions or general guidelines about type-safe class design.
This talk is in part based on ideas and concepts implemented in my type_safe library.
- March 22, 2017: std::string_view accepting temporaries: good idea or horrible pitfall?
- March 16, 2017: Implementation Challenge flag_set: Type-safe, hard to misuse bitmask
- January 20, 2017: Implementing function_view is harder than you might think
- January 09, 2017: How to handle errors in constructors without exceptions?
- December 28, 2016: My take on variant
- October 26, 2016: void foo(T& out) - How to fix output parameters
- October 19, 2016: Tutorial: Emulating strong/opaque typedefs in C++
- October 11, 2016: Type safe - Zero overhead utilities for more type safety
- September 27, 2016: Prevent precondition errors with the C++ type system
- August 24, 2016: Move semantics and default constructors - Rule of Six?
- July 23, 2016: Move safety - know what can be done in the moved-from state