Intermediate C++
Q80 / 100

What is fold expression in C++17?

Correct! Well done.

Incorrect.

The correct answer is B) A compile-time reduction of a parameter pack using a binary operator: (args + ...) or (... + args)

B

Correct Answer

A compile-time reduction of a parameter pack using a binary operator: (args + ...) or (... + args)

Explanation

template<typename... Ts> auto sum(Ts... args) { return (args + ...); } uses a right fold. (... + args) is a left fold. Eliminates recursive template specializations.

Progress
80/100