40 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___CXX03___ALGORITHM_MINMAX_H10#define _LIBCPP___CXX03___ALGORITHM_MINMAX_H11 12#include <__cxx03/__algorithm/comp.h>13#include <__cxx03/__algorithm/minmax_element.h>14#include <__cxx03/__config>15#include <__cxx03/__functional/identity.h>16#include <__cxx03/__type_traits/is_callable.h>17#include <__cxx03/__utility/pair.h>18 19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20# pragma GCC system_header21#endif22 23_LIBCPP_BEGIN_NAMESPACE_STD24 25template <class _Tp, class _Compare>26_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI pair<const _Tp&, const _Tp&>27minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) {28 return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) : pair<const _Tp&, const _Tp&>(__a, __b);29}30 31template <class _Tp>32_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI pair<const _Tp&, const _Tp&>33minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) {34 return std::minmax(__a, __b, __less<>());35}36 37_LIBCPP_END_NAMESPACE_STD38 39#endif // _LIBCPP___CXX03___ALGORITHM_MINMAX_H40