The C template library

Texture templateC of course doesn’t have generics or templates like C++ does, but I came across Gustav Lou’s C Template library this morning. It provides C equivalents to the following C++ template libraries. Each is done as a header file that you include.

deq.h -> std::deque
lst.h -> std::list
pqu.h -> std::priority_queue
que.h -> std::queue
set.h -> std::set
stk.h -> std::stack
str.h -> std::string
vec.h -> std::vector
 

The page on GitHub shows how to use libraries with an example of vector. The string equivalent library str.h would be an interesting one to see just how much of C++ string is supported.  C would still never be my language of choice for anything text heavy but if this is better than strcpy, strcat etc. I’ll happily use it.  Likewise list and vector. From memory C++ std::array is just a wrapper around the C standard array!

(Visited 25 times, 1 visits today)