How to make generics in C
summary
A header-only C library generates type-specialized sorts by using token-pasting macros to create uniquely named functions from a user-provided type and compare, avoiding runtime function-pointer calls and enabling compiler inlining. It ships as a single-header distribution to sidestep C packaging, implements many algorithms (bubble, quick, merge, TimSort, etc.), includes tests, and reports up to 10× speedup on simple structures; the code is used in some upstream projects and is actively maintained on GitHub.
AI-written summary · about
chapters (20)
- 0:00Intro
- 2:25Sorting algorithms
- 3:45Simple sorting algorithms
- 5:20Example
- 8:40Visual example
- 9:15Analysis
- 18:30Interview question
- 19:10Implementation details
- 23:02Generics
- 26:56Macros
- 28:33Tobias
- 29:24Daenerys
- 30:24Do Engineers
- 30:39Sort
- 32:04Open Source
- 34:29Compare
- 36:10Quicksort
- 37:20Debugging
- 38:38Invention
- 39:40Resizable
related talks
59mStrongly Typed Containers
50mType safe C++? LOL!
01h 16mPolymorphism, Cohesion, and Coupling in C++
01h 23mAlex Stepanov, Generic Programming in Cpp, and the STL
01h 06mModern C and What We Can Learn From It
01h 13mType safe C++ – LOL! :-)
01h 28mProgramming in Modern C with a Sneak Peek into C23
12mExtreme Type Safety with Opaque Typedefs
