A step-by-step exploration of implementing a compile-time quicksort algorithm using C++11 variadic templates. Starting from a basic typed list structure, the post builds up helper templates for iteration (foreach), concatenation (concat), filtering (filter), predicate binding (bind), and predicate negation (neg), then assembles them into a fully functional q_sort template that sorts integer lists entirely at compile time. Each building block is demonstrated with small test programs showing correct output.

9m read timeFrom playfulprogramming.com
Post cover image
Table of contents
Exploring variadic templates Copy link Link copied!Setup Copy link Link copied!Quick-sorting Copy link Link copied!

Sort: