Chapter 4.1
F.21: To return multiple “out” values, prefer returning a struct or tuple
The shape of a function signature
When we learn about functions, we learn about taking arguments, manipulating these inputs, and returning a value, an output. A function can take as many argu-ments as you like, but it can only return one thing.
This can cause problems. How do you signal an error condition? As discussed elsewhere, this problem remains without satisfactory resolution, but one historically popular approach is to take an error argument and write to that, while returning the result.
This gives us two kinds of function argument: input parameters and output parameters. The input parameters are used in the evaluation of the function, while the output ...
Get Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.