ranges::max
ranges::max (두 값 중 큰 값 — ranges)
두 값(또는 범위) 중 더 큰 값을 반환하는 ranges 버전 알고리즘이에요. <algorithm> 헤더에 있어요.
출처: cppreference
본문
std::ranges::max는 두 값 중 큰 값을 반환해요.
namespace std::ranges {
template< class T, class Comp = ranges::less, class Proj = std::identity >
constexpr const T& max( const T& a, const T& b, Comp comp = {}, Proj proj = {} );
}
comp(기본less)로,proj(투영)를 적용해 비교해요.- 반환 값: 큰 값의 참조. 같으면 첫 인자
a. - 초기화자 목록 버전(
max(std::initializer_list<T>))도 있어요.
int x = std::ranges::max(3, 7); // 7
int y = std::ranges::max({3, 9, 5}); // 9
std::max의 ranges/제약 버전이에요. 비교기와 투영을 지원해요.