![]() |
ATLAS Offline Software
|
Return the minimum or maximum element from a transformed range. More...
#include <ranges>#include <utility>#include <cstdlib>Go to the source code of this file.
Namespaces | |
| namespace | CxxUtils |
Functions | |
| template<class RANGE, class FUNC> | |
| auto | CxxUtils::min_transformed_element (RANGE &&r, FUNC &&f) |
| Find the minimum transformed element in a range. | |
| template<class RANGE, class FUNC> | |
| auto | CxxUtils::max_transformed_element (RANGE &&r, FUNC &&f) |
| Find the maximum transformed element in a range. | |
Return the minimum or maximum element from a transformed range.
These are like std::ranges::min_element and std::ranges::max_element, except that we apply a transform to the input range first. An example would be to take a range of vectors and find the one closest to some other vector. Why not just use std::ranges::min_element along with std::ranges::transform? First, it's a bit awkward without the enumerate/zip views from C++23. But more importantly, it's hard to avoid having the transform evaluated multiple times per element. This way, the transform is evaluated exactly once per element.
Definition in file minmax_transformed_element.h.