Book Image

Type-Safe Interfaces with Modern C++ [Video]

By : Vittorio Romeo
5 (2)
Book Image

Type-Safe Interfaces with Modern C++ [Video]

5 (2)
By: Vittorio Romeo

Overview of this book

In this course we’ll learn how to write correct, safe, and performant code by making use of C++’s type system. Firstly, we’ll learn about the Standard Library’s “algebraic data types” and how they can increase safety, performance, and readability of your application/library. We’ll then look at function interfaces. As an example, writing a function that takes a string in such a way that it performs optimally with both std::string and const char* seems like a daunting task. It gets even more tricky with functions taking other functions as input. Is it possible to generalize these issues and provide the “perfect” interface?
Table of Contents (4 chapters)
Chapter 4
Function Parameters and Ownership
Content Locked
Section 4
std::string_view in Interfaces
Understand when and why to use `std::string_view` as part of function interfaces, and the performance benefits it brings. - `string_view`: intention of “observing” - Retain strings passed to functions - Performance comparison with `std::string`