Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Type agnosticism, data structures and C

Name: Anonymous 2011-09-16 6:07

/prog/, I've been working on a C library with basic data structures and useful functions, and have implemented things like doubly-linked lists and vectors and so on. Now I'm working on Unicode-based string support. Here's my issue.

I've implemented type agnosticism on the vector type using void pointers (not preprocessor macros), so I want to use the vector type to represent a string. Each Unicode codepoint is an int32_t. Of course, I don't want to have to allocate four bytes on the heap for each codepoint, then point to that from each vector element; that's utterly stupid. On the other hand, doing typecasts to shove an integer in the void * type is kludgy and works very poorly, often requiring double explicit casts; once to expand/shrink the type's size, then once more to explicitly cast to a pointer or back.

How can I solve my issues and use my vector type for strings?

Name: Anonymous 2011-09-16 7:21

>>16
Nope. This is a C library.
Then enjoy your AIDS.

I mean, it is fucking ridiculous, isn't it? You have found one of the cases that perfectly illustrate why C++ is hands down better than C. Or, rather, the case found you. Yet through a miracle of cognitive alchemy you manage to warp your vision of the situation to completely turn it inside-out, so that you can respond to the only possible sane advice with a quietly smug "this is a C library". Mind boggles.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List