V Shreyas
V Shreyas

Reputation: 449

What is the return value of va_arg in empty lists?

In case of using variable arguments in cpp, what does va_arg return as the next value in case there is no next value?

Also, can this be considered as a solution for counting the elements in va_list?

Upvotes: 1

Views: 209

Answers (1)

MSalters
MSalters

Reputation: 179799

It's Undefined Behavior to do this, so you can't say anything about it. It's certainly unsuitable for counting.

Use variadic templates instead, those allow you to count arguments.

Upvotes: 3

Related Questions