Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.


Pattern-defeating quicksort is available through two calls, pdqsort and pdqsort_branchless. Both have identical guarantees, behavior and overloads as std::sort, with the exception of the C++17 parallel execution policy argument. Thus you can simply replace a call to std::sort with pdqsort, it is simply a faster implementation. It is almost always appropriate to simply call pdqsort and ignore pdqsort_branchless.

pdqsort_branchless runs significantly faster than pdqsort for comparison functions that are branchless (for an explanation why see 'The Average Case' below), such as simple integer or float comparison, and slightly slower when the comparison function contains branches. When using an arithmetic type and a default comparison function (std::less or std::greater) pdqsort automatically delegates to pdqsort_branchless. If you know that your custom comparison function is branchless and wish to make use of this speedup call pdqsort_branchless explicitly.