Metalang99 1.13.5
Full-blown preprocessor metaprogramming
Loading...
Searching...
No Matches
variadics.h File Reference

Variadic arguments: x, y, z. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ML99_variadicsCount(...)
 Computes a count of its arguments.
#define ML99_variadicsIsSingle(...)
 Tells if it received only one argument or not.
#define ML99_variadicsGet(i)
 Expands to a metafunction extracting the i -indexed argument.
#define ML99_variadicsTail(...)
 Extracts the tail of its arguments.
#define ML99_variadicsForEach(f, ...)
 Applies f to each argument.
#define ML99_variadicsForEachI(f, ...)
 Applies f to each argument with an index.
#define ML99_OVERLOAD(f, ...)
 Overloads f on a number of arguments.
#define ML99_VARIADICS_COUNT(...)
#define ML99_VARIADICS_IS_SINGLE(...)
#define ML99_VARIADICS_GET(i)
#define ML99_VARIADICS_TAIL(...)

Detailed Description

Variadic arguments: x, y, z.

Note
Variadics are more time and space-efficient than lists, but export less functionality; if a needed function is missed, invoking ML99_list and then manipulating with the resulting Cons-list might be helpful.

Macro Definition Documentation

◆ ML99_OVERLOAD

#define ML99_OVERLOAD ( f,
... )
Value:
ML99_PRIV_CAT(f, ML99_PRIV_VARIADICS_COUNT(__VA_ARGS__))(__VA_ARGS__)

Overloads f on a number of arguments.

This function counts the number of provided arguments, appends it to f and calls the resulting macro identifier with provided arguments.

At most 63 variadic arguments are acceptable.

Examples

#define X(...) ML99_OVERLOAD(X_, __VA_ARGS__)
#define X_1(a) Billie & a
#define X_2(a, b) Jean & a & b
// Billie & 4
X(4)
// Jean & 5 & 6
X(5, 6)
Variadic arguments: x, y, z.
Note
f need not be postfixed with _IMPL. It is literally invoked as ML99_CAT(f, ML99_VARIADICS_COUNT(...))(...).

◆ ML99_VARIADICS_COUNT

#define ML99_VARIADICS_COUNT ( ...)
Value:
ML99_PRIV_VARIADICS_COUNT(__VA_ARGS__)

◆ ML99_VARIADICS_GET

#define ML99_VARIADICS_GET ( i)
Value:
ML99_PRIV_CAT(ML99_PRIV_VARIADICS_GET_, i)

◆ ML99_VARIADICS_IS_SINGLE

#define ML99_VARIADICS_IS_SINGLE ( ...)
Value:
ML99_PRIV_NOT(ML99_PRIV_CONTAINS_COMMA(__VA_ARGS__))

◆ ML99_VARIADICS_TAIL

#define ML99_VARIADICS_TAIL ( ...)
Value:
ML99_PRIV_TAIL(__VA_ARGS__)

◆ ML99_variadicsCount

#define ML99_variadicsCount ( ...)
Value:
#define ML99_call(op,...)
Invokes a metafunction with arguments.
Definition lang.h:33
#define ML99_variadicsCount(...)
Computes a count of its arguments.
Definition variadics.h:35

Computes a count of its arguments.

At most 63 arguments are acceptable.

Examples

// 3
// 1
#define v(...)
A value that is pasted as-is; no evaluation occurs on provided arguments.
Definition lang.h:145

◆ ML99_variadicsForEach

#define ML99_variadicsForEach ( f,
... )
Value:
#define ML99_variadicsForEach(f,...)
Applies f to each argument.
Definition variadics.h:103

Applies f to each argument.

The result is ML99_appl(f, x1) ... ML99_appl(f, xN).

Examples

#define F_IMPL(x) v(@x)
#define F_ARITY 1
// @x @y @z
ML99_variadicsForEach(v(F), v(x, y, z))

◆ ML99_variadicsForEachI

#define ML99_variadicsForEachI ( f,
... )
Value:
#define ML99_variadicsForEachI(f,...)
Applies f to each argument with an index.
Definition variadics.h:120

Applies f to each argument with an index.

The result is ML99_appl2(f, x1, 0) ... ML99_appl2(f, xN, N - 1).

#define F_IMPL(x, i) v(@x##i)
#define F_ARITY 2
// @x0 @y1 @z2
ML99_variadicsForEachI(v(F), v(x, y, z))

◆ ML99_variadicsGet

#define ML99_variadicsGet ( i)
Value:
ML99_PRIV_CAT(ML99_PRIV_variadicsGet_, i)

Expands to a metafunction extracting the i -indexed argument.

i can range from 0 to 7, inclusively.

Examples

// 2
ML99_variadicsGet(1)(v(1, 2, 3))
#define ML99_variadicsGet(i)
Expands to a metafunction extracting the i -indexed argument.
Definition variadics.h:68

◆ ML99_variadicsIsSingle

#define ML99_variadicsIsSingle ( ...)
Value:
#define ML99_variadicsIsSingle(...)
Tells if it received only one argument or not.
Definition variadics.h:52

Tells if it received only one argument or not.

Examples

◆ ML99_variadicsTail

#define ML99_variadicsTail ( ...)
Value:
#define ML99_variadicsTail(...)
Extracts the tail of its arguments.
Definition variadics.h:84

Extracts the tail of its arguments.

At least two arguments must be specified.

Examples

// 2, 3