P2187R5: std::swap_if, std::predictable

INTRODUCTION

This paper proposes new Standard Library primitives swap_if and iter_swap_if, currently used implicitly (but deeply sub-optimally) in nearly half of the Standard Library algorithms, and equally useful for users’ algorithms. Although trivial to code correctly, current shipping compilers generate markedly sub-optimal code for naïve implementations.


In addition, it proposes a means to indicate to Standard Library facilities that the results of an ordering predicate in a particular use have turned out to be predictable, so that a more appropriate variant of the algorithm may be substituted. Finally, it defines a customization point to identify types with non-trivial special members that nonetheless qualify for optimization.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2187r5.pdf

Stay in touch

arrow-white