3 ms·
The alternative would be to rely on void* for all data types, which was really nicely presented in Mastering Algorithms with C by Kyle Loudon, but after working
by glouwbug 6y ago
The alternative would be to rely on void* for all data types,
which was really nicely presented in Mastering Algorithms with C by Kyle Loudon, but after working through it the lack of type safety for even basic types was a huge pain.
At least with a bit of pre-processor magic, type safety and contiguous data is promised. Also, getting crafty with precompiled headers, one could dump all the expansions into a single templates.h, compile a .gch, and reap the benefits of hundreds of containered types with instantaneous compile times.
- dleslie 6y agoI went with void* in order to avoid having separate algorithms for every container.
- adrift 6y agoI'd use something like Sean Barrett's stretchy buffer [1] instead. [1] https://github.com/nothings/stb/blob/master/stretchy_buffer.h https://github.com/nothings/stb/blob/master/stretchy_buffer....