I must say that while I've used the RB-tree 'provide a partial toolbox' in
my own code, it felt ugly, more like an indictment of the language I was
working in than anything else. I couldn't help but think that if C had a
half-decent macro expansion facility, like Lisp, or guaranteed function
cloning and cross-module inlining (Ada provides some of that), all this
nonsense would be unnecessary. You could either provide a search macro
that expanded into code that did the search, incorporating your comparator
into the code itself rather than calling it, or the compiler could detect
the frequent use of some comparator, clone the search function, and inline
the comparator into the clone (and possibly the clone into its caller).
So this is really a workaround for C being such an expressively
impoverished language, IMHO.