콘텐츠로 이동

T.var

T.var: Variadic template rules

???

T.100: Use variadic templates when you need a function that takes a variable number of arguments of a variety of types

Reason

Variadic templates is the most general mechanism for that, and is both efficient and type-safe. Don't use C varargs.

Example

??? printf

Enforcement

  • Flag uses of va_arg in user code.

T.101: ??? How to pass arguments to a variadic template ???

Reason

???

Example

??? beware of move-only and reference arguments

Enforcement

???

T.102: How to process arguments to a variadic template

Reason

???

Example

??? forwarding, type checking, references

Enforcement

???

T.103: Don't use variadic templates for homogeneous argument lists

Reason

There are more precise ways of specifying a homogeneous sequence, such as an initializer_list.

Example

???

Enforcement

???