diff options
-rw-r--r-- | include/conts/conts.h | 10 | ||||
-rw-r--r-- | include/conts/map.h | 2 | ||||
-rw-r--r-- | include/conts/sptree.h | 2 | ||||
-rw-r--r-- | include/conts/vec.h | 2 |
4 files changed, 7 insertions, 9 deletions
diff --git a/include/conts/conts.h b/include/conts/conts.h index d175d30..fb0094b 100644 --- a/include/conts/conts.h +++ b/include/conts/conts.h @@ -7,16 +7,8 @@ #define CONTAINER_OF(ptr, type, member) \ (type *)((char *)(ptr) - offsetof(type, member)) -#if __STDC_VERSION__ >= 202311UL -# define CONTS_AUTO auto -#elif defined(__GNUC__) -# define CONTS_AUTO __auto_type -#else -# warning "iteration won't work with this compiler" -#endif - #define foreach(name, i, s)\ - for (CONTS_AUTO i = CONTS_JOIN(name, begin)(s);\ + for (CONTS_JOIN(name, iter) i = CONTS_JOIN(name, begin)(s);\ !CONTS_JOIN(name, end)(s, i);\ i = CONTS_JOIN(name, next)(i)) #endif /* CONTS_H */ diff --git a/include/conts/map.h b/include/conts/map.h index 6be0694..db1e386 100644 --- a/include/conts/map.h +++ b/include/conts/map.h @@ -63,6 +63,8 @@ struct MAP_TUPLE { MAP_TYPE data; }; +typedef struct MAP_TUPLE *MAP(iter); + struct MAP_NODE { struct MAP_BUCKET *bucket; size_t hash; diff --git a/include/conts/sptree.h b/include/conts/sptree.h index 0e2c7b1..8c74604 100644 --- a/include/conts/sptree.h +++ b/include/conts/sptree.h @@ -45,6 +45,8 @@ struct SPROOT { struct SPNODE *root; }; +typedef SPTREE_TYPE *SPTREE(iter); + static inline struct SPROOT SPTREE(create)() { return (struct SPROOT){.n = 0, .root = NULL}; diff --git a/include/conts/vec.h b/include/conts/vec.h index 19fd18f..c08fd49 100644 --- a/include/conts/vec.h +++ b/include/conts/vec.h @@ -22,6 +22,8 @@ struct VEC_STRUCT { VEC_TYPE *buf; }; +typedef VEC_TYPE *VEC(iter); + static inline struct VEC_STRUCT VEC(create)(size_t reserve) { if (reserve == 0) |