How about adding shat()
macro that emulates stl's unodred_map's T& operator[]( const Key& key )
?
#1692
Replies: 1 comment 3 replies
-
So, since I don't do C++ and the request never specifies explicitly, I believe the proposal is: A function which returns a pointer to the hash table entry in a hash table, which creates one if there isn't one already. The main reason is that C++ has constructors, C doesn't. You need some mechanism to initialize the hash table slot the first time you write to it. Your suggestion just assumes it's ok if they're zero initialized, but it doesn't seem worth adding this function and ambiguity to me. C code is expected to be relatively explicit about these sorts of things. And a user can always write this function themselves if they need it frequently. |
Beta Was this translation helpful? Give feedback.
-
With STL:
Current
stb_ds.h
:Proposed
shat()
macro:Possible implementation:
Beta Was this translation helpful? Give feedback.
All reactions