P99

◆ P99_GENERIC_SIZE

#define P99_GENERIC_SIZE (   UI,
  ... 
)

Similar to P99_GENERIC but the choice is not according to the type of the expression UI but to its unsigned value.

Parameters
UImust be a compile time integer expression that is cast to size_t and that must not be of value 0.
Remarks
UI is only evaluated at compile time
a = P99_GENERIC_SIZE(sizeof(a),
func_fallback,
(1, func1),
(2, func2),
(4, func4),
(8, func8))
((void*)&a);

In this example one of the functions func1, ..., func8 is chosen according to the size of a. This function is then called with the address of a. In case the size of a is not appropriate, a function func_fallback is used.

Warning
The range of allowed values for UI is platform dependent. The only known fixed guarantee is UINT16_MAX, but the result of a sizeof operator should always work.
See also
P99_GENERIC

Definition at line 761 of file p99_generic.h.

P99_GENERIC_SIZE
#define P99_GENERIC_SIZE(UI,...)
Similar to P99_GENERIC but the choice is not according to the type of the expression UI but to its un...
Definition: p99_generic.h:761