xref: /freebsd/contrib/llvm-project/libcxx/include/__cxx03/__algorithm/max.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef _LIBCPP___CXX03___ALGORITHM_MAX_H
10 #define _LIBCPP___CXX03___ALGORITHM_MAX_H
11 
12 #include <__cxx03/__algorithm/comp.h>
13 #include <__cxx03/__algorithm/comp_ref_type.h>
14 #include <__cxx03/__algorithm/max_element.h>
15 #include <__cxx03/__config>
16 
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 #  pragma GCC system_header
19 #endif
20 
21 _LIBCPP_PUSH_MACROS
22 #include <__cxx03/__undef_macros>
23 
24 _LIBCPP_BEGIN_NAMESPACE_STD
25 
26 template <class _Tp, class _Compare>
27 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI const _Tp&
max(_LIBCPP_LIFETIMEBOUND const _Tp & __a,_LIBCPP_LIFETIMEBOUND const _Tp & __b,_Compare __comp)28 max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) {
29   return __comp(__a, __b) ? __b : __a;
30 }
31 
32 template <class _Tp>
33 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI const _Tp&
max(_LIBCPP_LIFETIMEBOUND const _Tp & __a,_LIBCPP_LIFETIMEBOUND const _Tp & __b)34 max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) {
35   return std::max(__a, __b, __less<>());
36 }
37 
38 _LIBCPP_END_NAMESPACE_STD
39 
40 _LIBCPP_POP_MACROS
41 
42 #endif // _LIBCPP___CXX03___ALGORITHM_MAX_H
43