4 ms·
you can abuse the preprocessor to do efficient generic programming e.g: https://github.com/attractivechaos/klib/blob/master/khash.h https://github.com/attracti
by latenightcoding 5y ago
you can abuse the preprocessor to do efficient generic programming e.g:
https://github.com/attractivechaos/klib/blob/master/khash.h https://github.com/attractivechaos/klib/blob/master/khash.h
https://github.com/attractivechaos/klib/blob/master/kvec.h https://github.com/attractivechaos/klib/blob/master/kvec.h
FWIW writing a generic vector like that ^^^ is going to be faster than almost any std::vector implementation you can find. And that is just one way to do it, there are other tricks.
- nynx 5y agoGood luck writing a data structure more complex than a vector, like a b* tree, with that approach.
- donkeybeer 5y agoHow would writing a B*-tree be any harder? The actual logic of a B*-tree would be equally hard in any language. The macroized template part is easy.