boostorg / boostorg/algorithm

variadic min/max/minmax

Ouverte
#119 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C++
Étoiles
131
Forks
117
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

Hello,
for min/max/minmax with multiple parameters there are only functions per std::initializer_list:
https://en.cppreference.com/w/cpp/algorithm/min
https://en.cppreference.com/w/cpp/algorithm/max
https://en.cppreference.com/w/cpp/algorithm/minmax
The parameters are always passed by value and not by reference and the result is also a value. This is a problem with types like std::array, std::string, etc.

Since the compare class cannot be the last function parameter in a variadic implementation (as in the std implementations) another position must be found, possibilities:
- first function parameter: 2 implementations would be needed each, once with compare class and once without. I don't find that useful.
- first template parameter: only one implementation is needed with default template parameter(s).

A simple variadic implementation could look like this:
[minmax_variadic.hpp.txt](https://github.com/boostorg/algorithm/files/11857077/minmax_variadic.hpp.txt)

minmax needs 2 compare classes (each for min and max) - this is more flexible.

thx
Gero

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.