Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
#pragma clang system_header

#define _EZCXX_INLINE [[__gnu__::__visibility__("hidden"), __gnu__::__always_inline__]] inline
#define _EZCXX_NODISCARD [[nodiscard]]
#define _EZCXX_NODISCARD_EXT [[nodiscard]]

#endif // _EZCXX_CONFIG
64 changes: 64 additions & 0 deletions src/libcxx/include/algorithm
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _EZCXX_ALGORITHM
#define _EZCXX_ALGORITHM

#include <__config>

// currently unused, but included in the standard
#include <initializer_list>

#pragma clang system_header

// very limited implementation of <algorithm>
// only supports std:max, std::min, and std::clamp
// these functions can be replaced when <algorithm> is properly implemented

namespace std {

template <class _Tp, class _Compare> _EZCXX_NODISCARD_EXT inline constexpr
const _Tp& max(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
return __comp(__a, __b) ? __b : __a;
}

template <class _Tp> _EZCXX_NODISCARD_EXT inline constexpr
const _Tp& max(const _Tp& __a, const _Tp& __b)
{
return (__a < __b) ? __b : __a;
}

template <class _Tp, class _Compare> _EZCXX_NODISCARD_EXT inline constexpr
const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
return __comp(__a, __b) ? __a : __b;
}

template <class _Tp> _EZCXX_NODISCARD_EXT inline constexpr
const _Tp& min(const _Tp& __a, const _Tp& __b)
{
return (__a < __b) ? __a : __b;
}

template <class _Tp, class _Compare> _EZCXX_NODISCARD_EXT inline constexpr
const _Tp& clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
{
return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;
}

template <class _Tp> _EZCXX_NODISCARD_EXT inline constexpr
const _Tp& clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
{
return (__v < __lo) ? __lo : (__hi < __v) ? __hi : __v;
}

} // namespace std

#endif // _EZCXX_ALGORITHM
8 changes: 8 additions & 0 deletions src/libcxx/include/numbers
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _EZCXX_NUMBERS
#define _EZCXX_NUMBERS

Expand Down
10 changes: 9 additions & 1 deletion src/libcxx/include/version
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _EZCXX_VERSION
#define _EZCXX_VERSION

Expand Down Expand Up @@ -39,7 +47,7 @@
// # define __cpp_lib_boyer_moore_searcher 201603L
# define __cpp_lib_byte 201603L
// # define __cpp_lib_chrono 201611L
// # define __cpp_lib_clamp 201603L
# define __cpp_lib_clamp 201603L
// # define __cpp_lib_enable_shared_from_this 201603L
// # define __cpp_lib_execution 201603L
// # define __cpp_lib_filesystem 201703L
Expand Down
Loading