(no title)
lor_louis | 7 months ago
struct Vec {
void *data;
size_t len;
size_t cap;
size_t sizeof_ty;
}
I then use a macro to define a new type IntVec {
struct Vec inner;
int ty[0];
}
Using the zero sized filed I can do typeof(*ty) to get some type safety back.All of the methods are implemented on the base Vec type and have a small wrapper which casts/assets the type of the things you are trying to push.
No comments yet.