How do variadic templates, parameter-pack expansion, and fold expressions work, including for an empty pack?
Show answer and explanation
A variadic template declares a type or value parameter pack, and a pack expansion repeats a pattern once for every element. A fold expression reduces a pack with a binary operator as a unary left or right fold, or as a binary fold with an explicit initial value. An empty unary fold is intrinsically valid only for logical AND, logical OR, and comma with their specified identities; other operators need a non-empty pack or a binary fold whose initializer supplies the base case. Evaluation order still follows the chosen operator, not the visual expansion alone.
A variadic template declares a type or value parameter pack, and a pack expansion repeats a pattern once for every element. A fold expression reduces a pack with a binary operator as a unary left or right fold, or as a binary fold with an explicit initial value. An empty unary fold is intrinsically valid only for logical AND, logical OR, and comma with their specified identities; other operators need a non-empty pack or a binary fold whose initializer supplies the base case. Evaluation order still follows the chosen operator, not the visual expansion alone.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.