Usage of `void()` in a comma-separated list?

The void() prevents an overloaded operator, from being called (where one of the parameters is of the type SomeClass<T>), as such an overload can’t have a parameter of type void.

You will most often see this used in templates, and is used in variadic pack expansions:

// C++11/14:
int unpack[] = {0, (do_something(pack), void(), 0)...};
// C++17 (fold expression):
(void(do_something(pack)), ...);

Where an overloaded operator, could ruin the sequencing guarantees of the language.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)