|
GMP 0.3.0
Generative Metaprogramming library for C++
|
Preprocessor-based code-generation utilities, tuple helpers, and platform/compiler macros. More...
Macros | |
| #define | GMP_EXPAND(...) |
| Force the full expansion of macro arguments. | |
| #define | GMP_IDENTITY(x) |
| Identity macro that returns its argument unchanged, forcing expansion. | |
| #define | GMP_STRINGIFY(x) |
| Convert a macro argument to a string literal. | |
| #define | GMP_CONCAT(lhs, rhs) |
| Concatenates two tokens after expanding them. | |
| #define | GMP_GET_VARARGS(...) |
| Get the number of variable arguments. | |
| #define | GMP_SIZE_OF_VAARGS(...) |
| Get the size of variable arguments. | |
| #define | GMP_IS_EMPTY(...) |
| Check if variable arguments are empty. | |
| #define | GMP_HAS_COMMA(...) |
| Check if the variable argument list contains a comma. | |
| #define | GMP_OPT_COMMA(...) |
| Optional comma based on argument emptiness. | |
| #define | GMP_OVERLOAD_INVOKE(call, ...) |
| Call an overloaded macro based on the special version. | |
| #define | GMP_GET_N(idx, ...) |
| Get the N-th parameter from the variable argument list. | |
| #define | GMP_GET_FIRST_N(n, ...) |
Get the first n arguments from a variadic argument list. | |
| #define | GMP_REMOVE_PARENS(tup) |
| Remove parentheses from a tuple/parameter list. | |
| #define | GMP_GET_TUPLE(idx, tup) |
| Get the nth element from a tuple/parameter list. | |
| #define | GMP_IS_TUPLE(symbol) |
| Tests whether a preprocessor argument is a non-empty tuple. | |
| #define | GMP_TUPLE_APPEND(tup, x) |
| Append an element to the end of a tuple. | |
| #define | GMP_TUPLE_PREPEND(tup, x) |
| Prepend an element to the beginning of a tuple. | |
| #define | GMP_TUPLE_CONCAT(tup_a, tup_b) |
| Concatenate two tuples into a single tuple. | |
| #define | GMP_TUPLE_SIZE(tup) |
| Calculate the number of elements in a tuple. | |
| #define | GMP_TUPLE_EMPTY(tup) |
| Check if a tuple is empty. | |
| #define | GMP_TUPLE_SKIP(count, tup) |
| Skip the first 'count' elements from a tuple and return the remaining elements. | |
| #define | GMP_TUPLE_TAKE(count, tup) |
| Take the first 'count' elements from a tuple. | |
| #define | GMP_FOR_EACH(call, ...) |
| Call a macro for each argument provided. | |
| #define | GMP_FOR_EACH_INDEPENDENT(call, ...) |
| Executes a macro call on each argument independently, supporting nested iteration. | |
| #define | GMP_WHILE(pred, op, args) |
| Repeatedly apply an operation while a predicate remains true. | |
| #define | GMP_CMP(x, y) |
| Compare two numbers by simultaneous decrementing, return final state. | |
| #define | GMP_INC(value) |
| Increment a value by 1. | |
| #define | GMP_DEC(value) |
| Decrement a value by 1. | |
| #define | GMP_NOT(value) |
| Macro to perform logical NOT operation on a value. | |
| #define | GMP_AND(a, b) |
| Macro to perform logical AND operation between two values. | |
| #define | GMP_OR(a, b) |
| Logical OR operation for two boolean values. | |
| #define | GMP_XOR(a, b) |
| Logical XOR (exclusive OR) operation for two boolean values. | |
| #define | GMP_IMPLIES(p, q) |
| Logical implication: p ⇒ q ≡ ¬p ∨ q. | |
| #define | GMP_BOOL(value) |
| Macro to convert a value to a boolean representation. | |
| #define | GMP_MAX(a, b) |
| Returns the maximum of two integer values. | |
| #define | GMP_MIN(a, b) |
| Returns the minimum of two integer values. | |
| #define | GMP_MINMAX(a, b) |
| Returns a tuple containing the minimum and maximum of two values in order. | |
| #define | GMP_MAXMIN(a, b) |
| Returns a tuple containing the maximum and minimum of two values in order. | |
| #define | GMP_SWAP(a, b) |
| Swaps the positions of two values. | |
| #define | GMP_ADD(a, b) |
| Computes the sum of two integer values using iterative addition. | |
| #define | GMP_SUB(a, b) |
| Computes the difference between two integer values (a - b). | |
| #define | GMP_IF_THEN_ELSE(cond, then_expr, else_expr) |
| Conditional selection macro that evaluates to one of two expressions based on a condition. | |
| #define | GMP_IF(cond, expr) |
| Conditional macro expansion based on boolean condition. | |
| #define | GMP_MAX_INDEX |
| Maximum depth allowed for macro nesting. | |
| #define | GMP_CHECK_INDEX(index) |
| Macro to check if an index is within a specified range. | |
| #define | GMP_CHECK_INDEX_BOOL(index) |
| Macro to check if an index is within a specified range. | |
| #define | GMP_MAKE_INDEX_SEQUENCE(index) |
| Generates a comma-separated index sequence up to a given index. | |
| #define | GMP_EQUAL_INT(i, j) |
| Macro to compare two integer values for equality. | |
| #define | GMP_EQUAL_INT_INDEPENDENT(i, j) |
Compare two integer literal macros without relying on GMP_CMP. | |
| #define | GMP_LESS_INT(i, j) |
| Check if i < j by analyzing comparison result state. | |
| #define | GMP_LESS_EQUAL_INT(i, j) |
| Test if i ≤ j (i is less than or equal to j). | |
| #define | GMP_GREATER_INT(i, j) |
| Check if i > j by analyzing comparison result state. | |
| #define | GMP_GREATER_EQUAL_INT(i, j) |
| Test if i ≥ j (i is greater than or equal to j). | |
| #define | GMP_SUB_INT(i, j) |
| Integer subtraction (i - j) | |
| #define | GMP_EMPTY(...) |
| Macro that expands to nothing. | |
| #define | GMP_DEFER(id) |
| Macro to defer the expansion of another macro. | |
| #define | GMP_EVAL(...) |
| Repeatedly rescan macro output to force deeper recursive expansion. | |
| #define | GMP_EVAL_1(...) |
| #define | GMP_EVAL_2(...) |
| #define | GMP_EVAL_3(...) |
| #define | GMP_EVAL_4(...) |
| #define | GMP_EVAL_5(...) |
| #define | GMP_EVAL_6(...) |
| #define | GMP_RANGE(begin, end) |
| Macro to generate a sequence of numbers from begin to end. | |
| #define | GMP_REPEAT(call, count, ...) |
| Macro to repeat a function call a specified number of times. | |
| #define | GMP_GENERATE_NAMESPACES_BEGIN(...) |
| Generate nested namespaces. | |
| #define | GMP_GENERATE_NAMESPACES_END(...) |
| #define | GMP_CONCATS(x, y, ...) |
| Concatenate multiple tokens into a single token. | |
| #define | GMP_REMOVE_TRAILING_COMMA(...) |
| Removes trailing comma from variadic macro arguments. | |
| #define | GMP_IDENTIFIERS |
| Expand to a comma-separated sequence of placeholder identifiers. | |
| #define | GMP_CPP_STD98 |
Numeric __cplusplus value corresponding to C++98. | |
| #define | GMP_CPP_STD11 |
Numeric __cplusplus value corresponding to C++11. | |
| #define | GMP_CPP_STD14 |
Numeric __cplusplus value corresponding to C++14. | |
| #define | GMP_CPP_STD17 |
Numeric __cplusplus value corresponding to C++17. | |
| #define | GMP_CPP_STD20 |
Numeric __cplusplus value corresponding to C++20. | |
| #define | GMP_CPP_STD23 |
Numeric __cplusplus value corresponding to C++23. | |
| #define | GMP_CPP_STD26 |
Numeric __cplusplus value reserved for C++26 support checks. | |
| #define | GMP_CPP_AT_LEAST(version) |
| Check if current C++ standard is greater than or equal to the specified version. | |
| #define | GMP_CPP_EXACTLY(version) |
| Check if current C++ standard is exactly the specified version. | |
| #define | GMP_CPP_NEWER_THAN(version) |
| Check if current C++ standard is newer than the specified version. | |
| #define | GMP_CPP_OLDER_THAN(version) |
| Check if current C++ standard is older than the specified version. | |
| #define | GMP_INLINE |
Expand to inline when inline variables are supported, otherwise expand to nothing. | |
Platform Detection | |
Compile-time operating system detection macros. These macros expose the detected target platform as boolean constants and provide a human-readable platform name. | |
| #define | GMP_PLATFORM_WINDOWS |
Evaluate to 1 when compiling for Windows, otherwise 0. | |
| #define | GMP_PLATFORM_LINUX |
Evaluate to 1 when compiling for Linux, otherwise 0. | |
| #define | GMP_PLATFORM_MAC |
Evaluate to 1 when compiling for macOS, otherwise 0. | |
| #define | GMP_PLATFORM_IOS |
Evaluate to 1 when compiling for iOS, otherwise 0. | |
| #define | GMP_PLATFORM_ANDROID |
Evaluate to 1 when compiling for Android, otherwise 0. | |
| #define | GMP_PLATFORM_NAME |
| Expand to a string literal describing the detected target platform. | |
Compiler Detection | |
Compile-time compiler detection macros. These macros identify the active compiler and expose a numeric version and descriptive compiler name. | |
| #define | GMP_COMPILER_MSVC |
Evaluate to 1 when compiling with MSVC, otherwise 0. | |
| #define | GMP_COMPILER_GCC |
Evaluate to 1 when compiling with GCC, otherwise 0. | |
| #define | GMP_COMPILER_CLANG |
Evaluate to 1 when compiling with Clang, otherwise 0. | |
| #define | GMP_COMPILER_NAME |
| Expand to a string literal describing the detected compiler. | |
| #define | GMP_COMPILER_VERSION |
| Expand to a compiler-specific numeric version value. | |
Build Configuration Detection | |
Detect whether the current build is a debug or release build. | |
| #define | GMP_BUILD_RELEASE |
Evaluate to 1 for release builds, otherwise 0. | |
| #define | GMP_BUILD_DEBUG |
Evaluate to 1 for debug builds, otherwise 0. | |
| #define | GMP_BUILD_TYPE |
| Expand to a string literal describing the active build configuration. | |
Architecture Detection | |
Detect the target processor architecture at compile time. | |
| #define | GMP_ARCH_X64 |
Evaluate to 1 when targeting x64, otherwise 0. | |
| #define | GMP_ARCH_ARM64 |
Evaluate to 1 when targeting ARM64, otherwise 0. | |
| #define | GMP_ARCH_X86 |
Evaluate to 1 when targeting x86, otherwise 0. | |
| #define | GMP_ARCH_NAME |
| Expand to a string literal describing the detected architecture. | |
Preprocessor Capabilities | |
Describe the supported preprocessor mode and argument limits. | |
| #define | GMP_MAX_MACRO_ARGS |
| Maximum supported variadic macro arity for the active preprocessor mode. | |
| #define | GMP_PREPROCESSOR_TYPE |
| Expand to a string literal describing the detected preprocessor mode. | |
| #define | GMP_STANDARD_PREPROCESSOR |
Evaluate to 1 when the compiler provides a standard-conforming preprocessor. | |
| #define GMP_ADD | ( | a, | |
| b | |||
| ) |
This macro implements addition by repeatedly incrementing the smaller value while decrementing the larger value.
| a | First integer value |
| b | Second integer value |
| #define GMP_AND | ( | a, | |
| b | |||
| ) |
This macro uses overload invocation to perform a logical AND operation. It relies on specific macro definitions for each combination of values.
| a | The first operand (0 or 1). |
| b | The second operand (0 or 1). |
| #define GMP_ARCH_ARM64 |
Definition at line 314 of file platform.hpp.
| #define GMP_ARCH_NAME |
Definition at line 316 of file platform.hpp.
| #define GMP_ARCH_X64 |
Definition at line 313 of file platform.hpp.
| #define GMP_ARCH_X86 |
Definition at line 315 of file platform.hpp.
| #define GMP_BOOL | ( | value | ) |
| #define GMP_BUILD_DEBUG |
Definition at line 270 of file platform.hpp.
| #define GMP_BUILD_RELEASE |
Definition at line 271 of file platform.hpp.
| #define GMP_BUILD_TYPE |
Definition at line 272 of file platform.hpp.
| #define GMP_CHECK_INDEX | ( | index | ) |
This macro checks if the given index is within a specified range defined by GMP_MAX_INDEX. If the index exceeds GMP_MAX_INDEX, an error is generated; otherwise, it performs no action.
| index | The index to check. |
| #define GMP_CHECK_INDEX_BOOL | ( | index | ) |
This macro checks if the given index is within a specified range defined by GMP_MAX_INDEX. If the index exceeds GMP_MAX_INDEX, an error is generated; otherwise, it performs no action.
| index | The index to check. |
| #define GMP_CMP | ( | x, | |
| y | |||
| ) |
This macro compares two numbers x and y by repeatedly decrementing both values until at least one reaches zero. It returns the final state (x_final, y_final) which indicates the comparison result by their values:
Process examples: GMP_CMP(2, 3) → expands through: (2, 3) → (1, 2) → (0, 1) // returns (0, 1) GMP_CMP(3, 2) → expands through:
(3, 2) → (2, 1) → (1, 0) // returns (1, 0) GMP_CMP(2, 2) → expands through: (2, 2) → (1, 1) → (0, 0) // returns (0, 0)
Result interpretation:
| x | First number to compare (non-negative) |
| y | Second number to compare (non-negative) |
| #define GMP_COMPILER_CLANG |
Definition at line 207 of file platform.hpp.
| #define GMP_COMPILER_GCC |
Definition at line 206 of file platform.hpp.
| #define GMP_COMPILER_MSVC |
Definition at line 205 of file platform.hpp.
| #define GMP_COMPILER_NAME |
Definition at line 208 of file platform.hpp.
| #define GMP_COMPILER_VERSION |
Definition at line 209 of file platform.hpp.
| #define GMP_CONCAT | ( | lhs, | |
| rhs | |||
| ) |
This macro concatenates two tokens lhs and rhs after expanding them.
| lhs | First token. |
| rhs | Second token. |
| #define GMP_CONCATS | ( | x, | |
| y, | |||
| ... | |||
| ) |
This macro concatenates all provided tokens into a single token. It accepts two or more arguments and can handle an arbitrary number of tokens (subject to compiler limits).
The macro works by recursively concatenating tokens in pairs:
| x | First token to concatenate |
| y | Second token to concatenate |
| ... | Additional tokens to concatenate (optional) |
| #define GMP_CPP_AT_LEAST | ( | version | ) |
This macro checks if the current C++ standard meets or exceeds the given version.
Example: GMP_CPP_AT_LEAST(17) // true if C++17 or newer GMP_CPP_AT_LEAST(20) // true if C++20 or newer
| version | The C++ standard version year (98, 11, 14, 17, 20, 23, 26) |
| #define GMP_CPP_EXACTLY | ( | version | ) |
This macro checks if the current C++ standard exactly matches the given version.
Example: GMP_CPP_EXACTLY(17) // true only for C++17
| version | The C++ standard version year |
| #define GMP_CPP_NEWER_THAN | ( | version | ) |
This macro checks if the current C++ standard is strictly newer than the given version.
Example: GMP_CPP_NEWER_THAN(17) // true for C++20, C++23, etc.
| version | The C++ standard version year |
| #define GMP_CPP_OLDER_THAN | ( | version | ) |
This macro checks if the current C++ standard is strictly older than the given version.
Example: GMP_CPP_OLDER_THAN(17) // true for C++14, C++11, etc.
| version | The C++ standard version year |
| #define GMP_DEC | ( | value | ) |
| #define GMP_DEFER | ( | id | ) |
This macro is used to defer the expansion of the given macro id by inserting an additional layer of indirection. This can be useful in certain macro programming scenarios where immediate expansion of a macro needs to be prevented.
| id | The macro to be deferred. |
| #define GMP_EMPTY | ( | ... | ) |
| #define GMP_EQUAL_INT | ( | i, | |
| j | |||
| ) |
This macro compares two integer values, i and j, and returns 1 if they are equal, and 0 if they are not. The maximum values for i and j should not exceed GMP_MAX_INDEX.
| i | The first integer value to compare. |
| j | The second integer value to compare. |
| #define GMP_EQUAL_INT_INDEPENDENT | ( | i, | |
| j | |||
| ) |
| #define GMP_EVAL | ( | ... | ) |
| #define GMP_EXPAND | ( | ... | ) |
This macro forces the complete expansion of its arguments. It is commonly used as an intermediate step to ensure that macro arguments are fully evaluated before being passed to other macros. Unlike simple argument substitution, this macro guarantees that nested macros are expanded to their final form.
| ... | The macro argument(s) to be expanded. |
| #define GMP_FOR_EACH | ( | call, | |
| ... | |||
| ) |
This macro allows for the invocation of a given macro on each argument in a list of arguments. It expands to a series of calls to the provided macro, one for each argument.
Example usage:
| call | The macro to be called for each argument. |
| ... | The list of arguments to be passed to the macro. |
| #define GMP_FOR_EACH_INDEPENDENT | ( | call, | |
| ... | |||
| ) |
This macro applies a given macro to each argument in the variadic list, similar to GMP_FOR_EACH but designed specifically to support nested macro iteration scenarios.
Unlike GMP_FOR_EACH, this macro can be nested with GMP_FOR_EACH to enable multi-level iteration, as regular GMP_FOR_EACH cannot be recursively called due to macro expansion limitations.
| call | The macro to apply to each element (must be a macro that takes one argument) |
| ... | Variable number of arguments to process |
| #define GMP_GENERATE_NAMESPACES_BEGIN | ( | ... | ) |
These macros create a series of nested namespaces from a list of namespace names.
Example: GMP_GENERATE_NAMESPACES_BEGIN(outer, inner, detail) GMP_GENERATE_NAMESPACES_END(outer, inner, detail)
Expands to: namespace outer { namespace inner { namespace detail { } } }
| ... | Variable list of namespace names to create nested hierarchy |
| #define GMP_GET_FIRST_N | ( | n, | |
| ... | |||
| ) |
| #define GMP_GET_N | ( | idx, | |
| ... | |||
| ) |
| idx | Zero-based index of the parameter to retrieve |
| ... | Variable argument list |
| #define GMP_GET_TUPLE | ( | idx, | |
| tup | |||
| ) |
This macro extracts the element at the specified index from a parenthesized tuple or parameter list. The tuple is first converted to a parameter sequence by removing parentheses, then the nth element is selected.
Example: GMP_GET_TUPLE(0, (int, float, char)) // Expands to: int GMP_GET_TUPLE(1, (42, "hello", 3.14)) // Expands to: "hello"
| idx | Zero-based index of the element to retrieve |
| tup | Parenthesized tuple containing the elements |
| #define GMP_GET_VARARGS | ( | ... | ) |
| #define GMP_GREATER_EQUAL_INT | ( | i, | |
| j | |||
| ) |
Returns 1 if i is greater than or equal to j, 0 otherwise. Implements: i ≥ j ≡ (i > j) ∨ (i == j)
| i | First integer |
| j | Second integer |
| #define GMP_GREATER_INT | ( | i, | |
| j | |||
| ) |
This macro checks if the first number is greater than the second by analyzing the final state (i_final, j_final) from the comparison process.
Mathematical logic: i > j ⇔ (i_final > 0) && (j_final == 0)
| i | First number to compare |
| j | Second number to compare |
| #define GMP_HAS_COMMA | ( | ... | ) |
| #define GMP_IDENTIFIERS |
| #define GMP_IDENTITY | ( | x | ) |
This macro serves as the identity function for macros - it returns its argument exactly as provided. It forces the full expansion of its argument, similar to GMP_EXPAND, but with a different name that can help avoid macro recursion issues in certain contexts.
| x | The value to return unchanged. |
| #define GMP_IF | ( | cond, | |
| expr | |||
| ) |
This macro expands to expr if cond evaluates to true (non-zero), otherwise expands to nothing (empty expansion).
| cond | Boolean condition (0 = false, non-zero = true) |
| expr | Expression to expand if condition is true |
| #define GMP_IF_THEN_ELSE | ( | cond, | |
| then_expr, | |||
| else_expr | |||
| ) |
This macro provides a functional-style if-then-else construct that can be used in preprocessor contexts. It selects between then_expr and else_expr based on the boolean value of cond.
| cond | Condition value (0 for false, any other value for true) |
| then_expr | Expression to evaluate if cond is true (non-zero) |
| else_expr | Expression to evaluate if cond is false (zero) |
| #define GMP_INC | ( | value | ) |
| #define GMP_IS_EMPTY | ( | ... | ) |
This macro checks if the variable arguments are empty by expanding and evaluating the arguments in various forms. It uses helper macros to perform the actual checks.
| ... | Variable argument list |
| #define GMP_IS_TUPLE | ( | symbol | ) |
| #define GMP_LESS_EQUAL_INT | ( | i, | |
| j | |||
| ) |
Returns 1 if i is less than or equal to j, 0 otherwise. Implements: i ≤ j ≡ (i < j) ∨ (i == j)
| i | First integer |
| j | Second integer |
| #define GMP_LESS_INT | ( | i, | |
| j | |||
| ) |
This macro checks if the first number is less than the second by analyzing the final state (i_final, j_final) from the comparison process.
Mathematical logic: i < j ⇔ (i_final == 0) && (j_final > 0)
| i | First number to compare |
| j | Second number to compare |
| #define GMP_MAKE_INDEX_SEQUENCE | ( | index | ) |
This macro uses overload invocation and recursive macro expansion to generate a comma-separated sequence of indices from 0 up to the specified index.
| index | The maximum index value to include in the sequence. |
| #define GMP_MAX | ( | a, | |
| b | |||
| ) |
This macro compares two integers a and b and returns the larger value.
| a | First integer value |
| b | Second integer value |
| #define GMP_MAX_INDEX |
| #define GMP_MAX_MACRO_ARGS |
Definition at line 342 of file platform.hpp.
| #define GMP_MAXMIN | ( | a, | |
| b | |||
| ) |
This macro returns a tuple (max, min) where the first element is the larger value and the second element is the smaller value.
| a | First integer value |
| b | Second integer value |
| #define GMP_MIN | ( | a, | |
| b | |||
| ) |
This macro compares two integers a and b and returns the smaller value.
| a | First integer value |
| b | Second integer value |
| #define GMP_MINMAX | ( | a, | |
| b | |||
| ) |
This macro returns a tuple (min, max) where the first element is the smaller value and the second element is the larger value.
| a | First integer value |
| b | Second integer value |
| #define GMP_NOT | ( | value | ) |
| #define GMP_OPT_COMMA | ( | ... | ) |
| #define GMP_OR | ( | a, | |
| b | |||
| ) |
This macro computes the logical OR of two boolean values a and b. Both arguments are treated as boolean values (0 = false, non-zero = true).
Truth table:
| a | First boolean value (0 or non-zero) |
| b | Second boolean value (0 or non-zero) |
| #define GMP_OVERLOAD_INVOKE | ( | call, | |
| ... | |||
| ) |
This macro allows for the invocation of different versions of a macro depending on the version provided. It works by concatenating the base call name with the version argument, and then invoking the appropriate overloaded macro.
Example usage:
| call | The base macro to be called. |
| ... | The arguments to be passed to the macro. The arguments determine which overloaded version of the macro is invoked. |
| #define GMP_PLATFORM_ANDROID |
Definition at line 89 of file platform.hpp.
| #define GMP_PLATFORM_IOS |
Definition at line 88 of file platform.hpp.
| #define GMP_PLATFORM_LINUX |
Definition at line 86 of file platform.hpp.
| #define GMP_PLATFORM_MAC |
Definition at line 87 of file platform.hpp.
| #define GMP_PLATFORM_NAME |
Definition at line 90 of file platform.hpp.
| #define GMP_PLATFORM_WINDOWS |
Definition at line 85 of file platform.hpp.
| #define GMP_PREPROCESSOR_TYPE |
Definition at line 343 of file platform.hpp.
| #define GMP_RANGE | ( | begin, | |
| end | |||
| ) |
This macro generates a sequence of numbers starting from begin and ending at end. The value of end should not exceed GMP_MAX_INT.
| begin | The starting number of the sequence. |
| end | The ending number of the sequence. Must be less than or equal to GMP_MAX_INT. |
| #define GMP_REMOVE_PARENS | ( | tup | ) |
This macro is used to remove the parentheses surrounding a tuple or parameter list, converting it into a comma-separated sequence of arguments. Primarily used in variadic macros to process parenthesized argument groups.
Example: GMP_REMOVE_PARENS((int, float, char)) // Expands to: int, float, char GMP_REMOVE_PARENS((42, "hello", 3.14)) // Expands to: 42, "hello", 3.14
| #define GMP_REMOVE_TRAILING_COMMA | ( | ... | ) |
This macro eliminates the trailing comma that may appear in variadic arguments, particularly useful when dealing with empty argument lists or conditional macro expansions.
Example usage:
| ... | Variadic arguments (may include a trailing comma) |
| #define GMP_REPEAT | ( | call, | |
| count, | |||
| ... | |||
| ) |
This macro executes the function call call repeatedly for count iterations. The arguments for the function call are provided by VA_ARGS.
| call | The function or macro to be called in each iteration. |
| count | The number of times the function call should be executed. |
| ... | Additional arguments passed to each invocation of call. |
| #define GMP_SIZE_OF_VAARGS | ( | ... | ) |
| ... | Variable argument list |
| #define GMP_STANDARD_PREPROCESSOR |
Definition at line 344 of file platform.hpp.
| #define GMP_STRINGIFY | ( | x | ) |
This macro converts its argument x into a string literal. Unlike directly using the # operator, this macro ensures that x is fully expanded before being stringified. This is important when x is itself a macro that needs to be expanded.
| x | The value to convert to a string. |
#. | #define GMP_SUB | ( | a, | |
| b | |||
| ) |
This macro implements subtraction with support for negative results. If a >= b, returns a - b. If a < b, returns -(b - a).
| a | First integer value (minuend) |
| b | Second integer value (subtrahend) |
| #define GMP_SUB_INT | ( | i, | |
| j | |||
| ) |
Returns the result of subtracting j from i. Result can be negative, but input parameters must be non-negative.
Example: GMP_SUB_INT(9, 14) → -5 GMP_SUB_INT(23, 14) → 9 GMP_SUB_INT(8, 8) → 0
| i | Minuend (non-negative integer) |
| j | Subtrahend (non-negative integer) |
| #define GMP_SWAP | ( | a, | |
| b | |||
| ) |
This macro simply returns its arguments in reversed order. It can be used as a building block for more complex operations.
| a | First value |
| b | Second value |
| #define GMP_TUPLE_APPEND | ( | tup, | |
| x | |||
| ) |
This macro creates a new tuple by adding the element x to the end of the input tuple tup. It handles both empty and non-empty tuples correctly.
| tup | The input tuple (may be empty) |
| x | The element to append to the tuple |
| #define GMP_TUPLE_CONCAT | ( | tup_a, | |
| tup_b | |||
| ) |
This macro combines two tuples tup_a and tup_b into a new tuple that contains all elements from tup_a followed by all elements from tup_b. The macro efficiently handles edge cases where one or both tuples are empty.
| tup_a | The first tuple (elements will appear first in the result) |
| tup_b | The second tuple (elements will appear after tup_a's elements) |
| #define GMP_TUPLE_EMPTY | ( | tup | ) |
This macro determines whether a tuple has zero elements.
| tup | The tuple enclosed in parentheses, e.g., () |
| #define GMP_TUPLE_PREPEND | ( | tup, | |
| x | |||
| ) |
This macro creates a new tuple by adding the element x to the beginning of the input tuple tup. It handles both empty and non-empty tuples correctly.
| tup | The input tuple (may be empty) |
| x | The element to prepend to the tuple |
| #define GMP_TUPLE_SIZE | ( | tup | ) |
This macro calculates the size (number of elements) of a tuple.
| tup | The tuple enclosed in parentheses, e.g., (a, b, c) |
| #define GMP_TUPLE_SKIP | ( | count, | |
| tup | |||
| ) |
This macro creates a new tuple by removing the first 'count' elements from the input tuple. It uses GMP_WHILE to iteratively process the tuple elements, building up the result by appending elements that should not be skipped.
The algorithm works as follows:
| count | Number of elements to skip from the beginning (0-based) |
| tup | Input tuple enclosed in parentheses |
| #define GMP_TUPLE_TAKE | ( | count, | |
| tup | |||
| ) |
This macro creates a new tuple containing the first 'count' elements from the input tuple tup. If 'count' exceeds the tuple size, the entire tuple is returned as a fallback behavior.
| count | Number of elements to take from the beginning (non-negative) |
| tup | Input tuple |
| #define GMP_WHILE | ( | pred, | |
| op, | |||
| args | |||
| ) |
| #define GMP_XOR | ( | a, | |
| b | |||
| ) |
This macro computes the logical XOR of two boolean values a and b. XOR returns true (1) if exactly one of the inputs is true, false (0) otherwise.
Truth table:
| a | First boolean value (0 or non-zero) |
| b | Second boolean value (0 or non-zero) |