diff --git a/m-bptree.h b/m-bptree.h index 7a68f896..c89c061f 100644 --- a/m-bptree.h +++ b/m-bptree.h @@ -36,10 +36,10 @@ /* Define a B+tree of a given type, of size N. USAGE: BPTREE_DEF(name, N, type, [, oplist_of_the_type]) */ -#define BPTREE_DEF(name, N, type, oplist) \ - BPTREEI_DEF2(name, N, type, oplist, type, oplist, 0, \ - M_C(name, _t), M_C(name, _node_t), M_C(name, _pit_t), \ - M_C(name, _it_t)) +#define BPTREE_DEF(name, N, ...) \ + BPTREEI_DEF(M_IF_NARGS_EQ1(__VA_ARGS__) \ + ((name, N, __VA_ARGS__, M_GLOBAL_OPLIST_OR_DEF(__VA_ARGS__), __VA_ARGS__, M_GLOBAL_OPLIST_OR_DEF(__VA_ARGS__), 0, M_C(name, _t), M_C(name, _node_t), M_C(name, _pit_t), M_C(name, _it_t) ), \ + (name, N, __VA_ARGS__, __VA_ARGS__, 0, M_C(name, _t), M_C(name, _node_t), M_C(name, _pit_t), M_C(name, _it_t) ))) //TODO: oplist @@ -80,6 +80,9 @@ /* Max depth of any B+tree */ #define BPTREEI_MAX_STACK ((int)(CHAR_BIT*sizeof (size_t))) +// Deferred evaluation. +#define BPTREEI_DEF(arg) BPTREEI_DEF2 arg + #define BPTREEI_DEF2(name, N, key_t, key_oplist, value_t, value_oplist, isMap, tree_t, node_t, pit_t, it_t) \ \ M_IF(isMap)( \ diff --git a/tests/test-mbptree.c b/tests/test-mbptree.c index d08de26e..77b61977 100644 --- a/tests/test-mbptree.c +++ b/tests/test-mbptree.c @@ -31,7 +31,8 @@ BPTREE_DEF2(btree, 3, int, M_DEFAULT_OPLIST, int, M_DEFAULT_OPLIST) END_COVERAGE BPTREE_DEF2(btree_my, 3, my_mpz_t, MYMPZ2_OPLIST, my_mpz_t, MYMPZ2_OPLIST) -BPTREE_DEF(btree_myset, 3, my_mpz_t, MYMPZ2_OPLIST) +BPTREE_DEF(btree_intset, 13, int) +BPTREE_DEF(btree_myset, 15, my_mpz_t, MYMPZ2_OPLIST) static void test1(void) {