Possible to rename/alias the well-known CC types? (like vec, list, map, omap etc) #16
-
|
Just discovered CC and am delighted with the approach and the attention paid here also to non-code things (readme, articles). I'm interested in whether type renames are possible. Not just because I usually typedef aliases that begin with an uppercase letter, but also because: whenever I'm in a codebase that has mathematical vector types (as in Vec2, Vec3, Vec4, as in 2d/3d gfx), I'm always minorly irked by languages/libs that choose to name dynamically-allocated-resizable-contiguous-homogenous lists "vectors". Of course C++ stdlib is another perp here. So I might just be inclined to "rename"/alias CC's None too critical but just curious anyway.. given whatever macro magic occurs I'm pretty sure I won't even have to try a naive |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Glad you're enjoying the library!
Right, But you can always define your own macro aliases for CC macros, e.g.
I do plan on reconsidering some of the macro names that CC uses, as discussed here. However, that's at least two versions away (the upcoming version will mostly just add dynamic strings and won't include any breaking API changes). And although I share your sentiment regarding "vector", I'm reluctant to change that name because it's probably the most familiar name for that type of container for C programmers (because of the C++ standard library). |
Beta Was this translation helpful? Give feedback.
Glad you're enjoying the library!
Right,
typedefwill only work with a complete CC type (i.e. including the key/element type/s) becausecc_vec,cc_list, and so on are macros that generate a type based on their arguments. So you can, for example, dotypedef cc_vec( int ) IntList;but nottypedef cc_vec List;. Of course, if you're typedefing every container and key/element type combination, you would probably be better off just using a library based around manually instantiated pseudo-templates (I like STC in particular).But you can always…