Update 'README.md'
This commit is contained in:
parent
849db18d4e
commit
51a0d4834e
39
README.md
39
README.md
@ -1,5 +1,36 @@
|
|||||||
Based on https://stackoverflow.com/questions/11761703/overloading-macro-on-number-of-arguments
|
|
||||||
https://stackoverflow.com/questions/1872220/is-it-possible-to-iterate-over-arguments-in-variadic-macros
|
## AuroraForEach
|
||||||
|
|
||||||
Implements a `AU_FOR_EACH_n` X-style macro that accepts a macro parameter where 'N' is the input parameters of the macro
|
Implements a `AU_FOR_EACH_n` X-style macro that accepts a macro parameter where 'N' is the input parameters of the macro
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```C
|
||||||
|
#define HELLO_WORLD(n) n
|
||||||
|
#define COUNT_TO_9 AU_FOR_EACH(HELLO_WORLD, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||||
|
|
||||||
|
const char *kCountTo9 = AU_STRINGIFY(COUNT_TO_9); // generic what macro
|
||||||
|
assert(strcmp(kCountTo9, "1 2 3 4 5 6 7 8 9") == 0);
|
||||||
|
```
|
||||||
|
|
||||||
|
```C
|
||||||
|
#define HELLO_WORLD(n) , n
|
||||||
|
#define HELLO_WORLD_FIRST(n) 0, n
|
||||||
|
#define COUNT_TO_9 AU_FOR_EACH_FIRST(HELLO_WORLD_FIRST, HELLO_WORLD, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||||
|
|
||||||
|
const char *kCountTo9 = AU_STRINGIFY(COUNT_TO_9); // generic what macro
|
||||||
|
assert(strcmp(kCountTo9, "0, 1, 2, 3, 4, 5, 6, 7, 8, 9") == 0);
|
||||||
|
```
|
||||||
|
|
||||||
|
*Note, simple tests akin to the above examples may fail due to whitespace padding.*
|
||||||
|
|
||||||
|
## License
|
||||||
|
Public Domain or Unlicense
|
||||||
|
|
||||||
|
|
||||||
|
## Credit
|
||||||
|
|
||||||
|
Based on
|
||||||
|
* https://stackoverflow.com/questions/11761703/overloading-macro-on-number-of-arguments
|
||||||
|
* https://stackoverflow.com/questions/1872220/is-it-possible-to-iterate-over-arguments-in-variadic-macros
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user