xvi Contents in Detail
Declaration Statements ............................................. 213
Functions ................................................ 213
Namespaces ............................................. 216
Type Aliasing ............................................. 220
Structured Bindings ......................................... 222
Attributes ................................................ 223
Selection Statements ............................................... 225
if Statements.............................................. 225
switch Statements .......................................... 229
Iteration Statements ............................................... 230
while Loops .............................................. 230
do-while Loops ............................................ 231
for Loops ................................................ 232
Ranged-Based for Loops...................................... 234
Jump Statements.................................................. 238
break Statements........................................... 238
continue Statements......................................... 239
goto Statements ........................................... 239
Summary ...................................................... 241
9
FUNCTIONS 243
Function Declarations .............................................. 244
Prefix Modifiers............................................ 244
Suffix Modifiers............................................ 245
auto Return Types................................................. 247
auto and Function Templates ......................................... 248
Overload Resolution ............................................... 249
Variadic Functions ................................................ 250
Variadic Templates................................................ 251
Programming with Parameter Packs.............................. 252
Revisiting the sum Function .................................... 252
Fold Expressions ........................................... 253
Function Pointers ................................................. 254
Declaring a Function Pointer................................... 254
Type Aliases and Function Pointers .............................. 255
The Function-Call Operator .......................................... 255
A Counting Example .............................................. 256
Lambda Expressions ............................................... 258
Usage .................................................. 258
Lambda Parameters and Bodies ................................ 259
Default Arguments.......................................... 260
Generic Lambdas .......................................... 261
Lambda Return Types........................................ 262
Lambda Captures .......................................... 262
constexpr Lambda Expressions ................................. 268
std::function..................................................... 269
Declaring a Function ........................................ 269
An Extended Example ....................................... 270