|
1 | 1 | // -*- C++ -*- |
2 | | -//===----------------------------------------------------------------------===// |
3 | | -// |
4 | | -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
5 | | -// See https://llvm.org/LICENSE.txt for license information. |
6 | | -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 | | -// |
8 | | -//===----------------------------------------------------------------------===// |
9 | | - |
10 | 2 | #ifndef _EZCXX_ALGORITHM |
11 | 3 | #define _EZCXX_ALGORITHM |
12 | 4 |
|
13 | | -#include <__config> |
14 | | - |
15 | | -// currently unused, but included in the standard |
| 5 | +#include <__eastl_config> |
16 | 6 | #include <initializer_list> |
| 7 | +#include <EASTL/algorithm.h> |
| 8 | +#include <EASTL/heap.h> |
| 9 | +#include <EASTL/sort.h> |
17 | 10 |
|
18 | 11 | #pragma clang system_header |
19 | 12 |
|
20 | | -// very limited implementation of <algorithm> |
21 | | -// only supports std:max, std::min, and std::clamp |
22 | | -// these functions can be replaced when <algorithm> is properly implemented |
23 | | - |
24 | | -namespace std { |
25 | | - |
26 | | -template <class _Tp, class _Compare> _EZCXX_NODISCARD_EXT inline constexpr |
27 | | -const _Tp& max(const _Tp& __a, const _Tp& __b, _Compare __comp) |
28 | | -{ |
29 | | - return __comp(__a, __b) ? __b : __a; |
30 | | -} |
31 | | - |
32 | | -template <class _Tp> _EZCXX_NODISCARD_EXT inline constexpr |
33 | | -const _Tp& max(const _Tp& __a, const _Tp& __b) |
34 | | -{ |
35 | | - return (__a < __b) ? __b : __a; |
36 | | -} |
37 | | - |
38 | | -template <class _Tp, class _Compare> _EZCXX_NODISCARD_EXT inline constexpr |
39 | | -const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) |
40 | | -{ |
41 | | - return __comp(__a, __b) ? __a : __b; |
42 | | -} |
43 | | - |
44 | | -template <class _Tp> _EZCXX_NODISCARD_EXT inline constexpr |
45 | | -const _Tp& min(const _Tp& __a, const _Tp& __b) |
46 | | -{ |
47 | | - return (__a < __b) ? __a : __b; |
48 | | -} |
49 | | - |
50 | | -template <class _Tp, class _Compare> _EZCXX_NODISCARD_EXT inline constexpr |
51 | | -const _Tp& clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp) |
52 | | -{ |
53 | | - return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v; |
54 | | -} |
55 | | - |
56 | | -template <class _Tp> _EZCXX_NODISCARD_EXT inline constexpr |
57 | | -const _Tp& clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi) |
58 | | -{ |
59 | | - return (__v < __lo) ? __lo : (__hi < __v) ? __hi : __v; |
60 | | -} |
61 | | - |
62 | | -} // namespace std |
63 | | - |
64 | 13 | #endif // _EZCXX_ALGORITHM |
0 commit comments