Practice mode C++

In a variadic template declared as template <typename… Args> void log(Args… args), what does sizeof…(Args) give?

Correct answer D. The number of template arguments in the pack

Explanation

sizeof... is a special operator that yields the number of elements in a parameter pack as a compile-time constant of type std::size_t. It has nothing to do with byte sizes, which ordinary sizeof measures. For log(1, 2.0, "x") it gives 3, which is useful for static checks or for sizing arrays built from the pack.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.