Metalang99 1.13.3
Full-blown preprocessor metaprogramming
|
Tuples: (x, y, z)
.
More...
Go to the source code of this file.
Macros | |
#define | ML99_tuple(...) ML99_call(ML99_tuple, __VA_ARGS__) |
Transforms a sequence of arguments into (...) . More... | |
#define | ML99_tupleEval(...) ML99_call(ML99_tupleEval, __VA_ARGS__) |
Transforms a sequence of arguments into (v(...)) . More... | |
#define | ML99_untuple(x) ML99_call(ML99_untuple, x) |
Untuples the tuple x , leaving the result unevaluated. More... | |
#define | ML99_untupleChecked(x) ML99_call(ML99_untupleChecked, x) |
The same as ML99_untuple. More... | |
#define | ML99_untupleEval(x) ML99_call(ML99_untupleEval, x) |
Untuples the tuple x and evaluates the result. More... | |
#define | ML99_isTuple(x) ML99_call(ML99_isTuple, x) |
Tests whether x is inside parentheses or not. More... | |
#define | ML99_isUntuple(x) ML99_call(ML99_isUntuple, x) |
The inverse of ML99_isTuple. More... | |
#define | ML99_tupleCount(x) ML99_call(ML99_tupleCount, x) |
Computes the count of items in the tuple x . More... | |
#define | ML99_tupleIsSingle(x) ML99_call(ML99_tupleIsSingle, x) |
Tells if the tuple x contains only one item or not. More... | |
#define | ML99_tupleGet(i) ML99_PRIV_CAT(ML99_PRIV_tupleGet_, i) |
Expands to a metafunction extracting the i -indexed element of a tuple. More... | |
#define | ML99_tupleTail(x) ML99_call(ML99_tupleTail, x) |
Extracts the tuple's tail. More... | |
#define | ML99_tupleAppend(x, ...) ML99_call(ML99_tupleAppend, x, __VA_ARGS__) |
Appends provided variadic arguments to the tuple x . More... | |
#define | ML99_tuplePrepend(x, ...) ML99_call(ML99_tuplePrepend, x, __VA_ARGS__) |
Prepends provided variadic arguments to the tuple x . More... | |
#define | ML99_tupleForEach(f, x) ML99_call(ML99_tupleForEach, f, x) |
A shortcut for ML99_variadicsForEach(f, ML99_untuple(x)) . | |
#define | ML99_tupleForEachI(f, x) ML99_call(ML99_tupleForEachI, f, x) |
A shortcut for ML99_variadicsForEachI(f, ML99_untuple(x)) . | |
#define | ML99_assertIsTuple(x) ML99_call(ML99_assertIsTuple, x) |
Emits a fatal error if x is not a tuple, otherwise results in emptiness. More... | |
#define | ML99_TUPLE(...) (__VA_ARGS__) |
#define | ML99_UNTUPLE(x) ML99_PRIV_EXPAND x |
#define | ML99_IS_TUPLE(x) ML99_PRIV_IS_TUPLE(x) |
#define | ML99_IS_UNTUPLE(x) ML99_PRIV_IS_UNTUPLE(x) |
#define | ML99_TUPLE_COUNT(x) ML99_VARIADICS_COUNT(ML99_UNTUPLE(x)) |
#define | ML99_TUPLE_IS_SINGLE(x) ML99_VARIADICS_IS_SINGLE(ML99_UNTUPLE(x)) |
#define | ML99_TUPLE_GET(i) ML99_PRIV_CAT(ML99_PRIV_TUPLE_GET_, i) |
#define | ML99_TUPLE_TAIL(x) ML99_VARIADICS_TAIL(ML99_UNTUPLE(x)) |
#define | ML99_TUPLE_APPEND(x, ...) (ML99_UNTUPLE(x), __VA_ARGS__) |
#define | ML99_TUPLE_PREPEND(x, ...) (__VA_ARGS__, ML99_UNTUPLE(x)) |
Tuples: (x, y, z)
.
A tuple is represented as (x1, ..., xN)
. Tuples are a convenient way to deal with product types. For example:
#define ML99_assertIsTuple | ( | x | ) | ML99_call(ML99_assertIsTuple, x) |
Emits a fatal error if x
is not a tuple, otherwise results in emptiness.
#define ML99_isTuple | ( | x | ) | ML99_call(ML99_isTuple, x) |
Tests whether x
is inside parentheses or not.
The preconditions are the same as of ML99_isUntuple.
#define ML99_isUntuple | ( | x | ) | ML99_call(ML99_isUntuple, x) |
The inverse of ML99_isTuple.
x
must be either of these forms:
(...)
(reported as non-untupled)(...) (...) ...
(reported as untupled)(...)
(reported as untupled)For example (respectively):
(~, ~, ~)
(non-untupled)(~, ~, ~) (~, ~, ~)
or (~, ~, ~) (~, ~, ~) abc
(untupled)123
or 123 (~, ~, ~)
(untupled)#define ML99_tuple | ( | ... | ) | ML99_call(ML99_tuple, __VA_ARGS__) |
Transforms a sequence of arguments into (...)
.
#define ML99_tupleAppend | ( | x, | |
... | |||
) | ML99_call(ML99_tupleAppend, x, __VA_ARGS__) |
Appends provided variadic arguments to the tuple x
.
#define ML99_tupleCount | ( | x | ) | ML99_call(ML99_tupleCount, x) |
Computes the count of items in the tuple x
.
At most 63 items can be contained in x
.
#define ML99_tupleEval | ( | ... | ) | ML99_call(ML99_tupleEval, __VA_ARGS__) |
Transforms a sequence of arguments into (v(...))
.
#define ML99_tupleGet | ( | i | ) | ML99_PRIV_CAT(ML99_PRIV_tupleGet_, i) |
Expands to a metafunction extracting the i
-indexed element of a tuple.
i
can range from 0 to 7, inclusively.
#define ML99_tupleIsSingle | ( | x | ) | ML99_call(ML99_tupleIsSingle, x) |
Tells if the tuple x
contains only one item or not.
#define ML99_tuplePrepend | ( | x, | |
... | |||
) | ML99_call(ML99_tuplePrepend, x, __VA_ARGS__) |
Prepends provided variadic arguments to the tuple x
.
#define ML99_tupleTail | ( | x | ) | ML99_call(ML99_tupleTail, x) |
Extracts the tuple's tail.
x
must contain at least two elements.
#define ML99_untuple | ( | x | ) | ML99_call(ML99_untuple, x) |
Untuples the tuple x
, leaving the result unevaluated.
If x
is not a tuple, it emits a fatal error.
#define ML99_untupleChecked | ( | x | ) | ML99_call(ML99_untupleChecked, x) |
The same as ML99_untuple.
#define ML99_untupleEval | ( | x | ) | ML99_call(ML99_untupleEval, x) |
Untuples the tuple x
and evaluates the result.