Re:C Template Library
by SurfingInVR on Tuesday December 29, 2020 @07:15PM
(#25576753)
This is interesting! Why not ANSI C, if not going for the latest C spec?
[ Parent
| on HN ]
C99 Variadic macros, for one, which allows for a nice to use `foreach` implementation. As for the latest C spec, I use a set of C compilable by C++, since most of the functional tests back-test against the STL, and hence compile with a C++ compiler
You do not need variadic macros!
#define foreach(container, variable, iterator) \
for (JOIN(container, it) iterator = JOIN(JOIN(container, it), each) (variable); \
!iterator.done; iterator.step(&iterator))
Is this less nice? I personally do not like dangling )'s [I did not have to write DOS batch scripts :D]Amazing, I can drop the variadic macro.
EDIT: Done, and thank you so much - it's so much cleaner this way
You're welcome. And you might like to see ''sys/queue.h'': https://github.com/openbsd/src/blob/master/sys/sys/queue.h
You're missing out on _Generic, _Static_assert, and restrict.
https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-...