Chapter 2: General STL Features
This chapter is a general potpourri of STL features and techniques. These are mostly new features introduced over the past few years, which may not yet be widely used. These are useful techniques that will improve the simplicity and readability of your code.
In this chapter we will cover the following recipes:
- Use the new
span
class to make your C-arrays safer - Use structured binding to return multiple values
- Initialize variables within
if
andswitch
statements - Use template argument deduction for simplicity and clarity
- Use
if constexpr
to simplify compile-time decisions