c/language/generic

Provides a way to choose one of several expressions at compile time, based on a type of a controlling expression

Syntax
where is a comma-separated list of associations, each of which has the syntax

where

No two s in the may specify. There may be only one association that uses the keyword. If is not used and none of the s are compatible with the type of the controlling expression, the program will not compile.

Explanation
First, the type of undergoes. The conversion is performed in type domain only: it discards the top-level cvr-qualifiers and atomicity and applies array-to-pointer/function-to-pointer transformations to the type of the controlling expression, without initiating any side-effects or calculating any values.

The type after conversion is compared with s from the list of associations.

If the type is with the  of one of the associations, then the type, value, and  of the generic selection are the type, value, and value category of the   that appears after the colon for that.

If none of the s are compatible with the type of the, and the association is provided, then the type, value, and value category of the generic selection are the type, value, and value category of the expression after the  label.

Keywords
,