Aurora ForEach Implements various AU_FOR_EACH_n X-style macros that accept a macro of N parameters
Go to file
2022-02-05 05:44:12 +00:00
Include [*] depollute AU_ macro prefix space 2022-02-05 05:44:12 +00:00
.gitignore Add Aurora build file and .gitignore 2021-10-24 12:51:01 +01:00
Aurora.json I'm blind; typo in the build file 2021-10-28 23:48:15 +01:00
forEach.js [*] depollute AU_ macro prefix space 2022-02-05 05:44:12 +00:00
LICENSE.txt Initial Commit 2021-10-05 21:14:54 +01:00
README.md Update 'README.md' 2021-10-28 20:53:29 +00:00

AuroraForEach

Implements a AU_FOR_EACH_n X-style macro that accepts a macro parameter where 'N' is the input parameters of the macro

Example

#define HELLO_WORLD(that, n)  that n
#define COUNT_TO_9      AU_FOR_EACH_THAT(HELLO_WORLD, int, 1, 2, 3, 4, 5, 6, 7, 8, 9)
     
const char *kCountTo9 = AU_STRINGIFY(COUNT_TO_9); // generic what macro
assert(strcmp(kCountTo9, "int 1 int 2 int 3 int 4 int 5 int 6 int 7 int 8 int 9") == 0);
#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);
#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.

Users

License

Public Domain or Unlicense

Credit

Based on