Re: [PATCH 1/3] implement generic key/value map
From: Bert Wesarg <hidden>
Date: 2016-06-15 22:51:35
On Thu, Jul 14, 2011 at 20:55, Jeff King [off-list ref] wrote:
On Thu, Jul 14, 2011 at 08:54:07PM +0200, Bert Wesarg wrote:quoted
On Thu, Jul 14, 2011 at 20:52, Bert Wesarg [off-list ref] wrote:quoted
On Thu, Jul 14, 2011 at 19:51, Jeff King [off-list ref] wrote:quoted
+#define MAP_IMPLEMENT(name, ktype, vtype, cmp_fun, hash_fun) \This define should probably in the header too. Else this is completely useless.Ahh. One have to read patch 2/3, to see how to use this. Please feel free to ignore this than.Yeah, you could treat this like a C++ template and assume random bits of code will instantiate a map of whatever types they need. But this is C, and we only want to instantiate once. So I just figured to keep the static list of whatever maps git needs in the map.[ch] files.
When I wrote such macros in the past, the 'generated' functions where all static. So one could instantiate a map multiple times in different compilation units where one need to access this type of map. But I'm perfectly fine with your way, which is new to me. Bert
-Peff