mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
update libcxx, libcxxabi, libunwind, and tsan to llvm 13 rc1
This commit is contained in:
parent
1b8f0d8b56
commit
92b69215e6
51
lib/libcxx/include/__algorithm/adjacent_find.h
vendored
Normal file
51
lib/libcxx/include/__algorithm/adjacent_find.h
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_ADJACENT_FIND_H
|
||||
#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
|
||||
if (__first != __last) {
|
||||
_ForwardIterator __i = __first;
|
||||
while (++__i != __last) {
|
||||
if (__pred(*__first, *__i))
|
||||
return __first;
|
||||
__first = __i;
|
||||
}
|
||||
}
|
||||
return __last;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type __v;
|
||||
return _VSTD::adjacent_find(__first, __last, __equal_to<__v>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H
|
||||
37
lib/libcxx/include/__algorithm/all_of.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/all_of.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_ALL_OF_H
|
||||
#define _LIBCPP___ALGORITHM_ALL_OF_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _Predicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
|
||||
for (; __first != __last; ++__first)
|
||||
if (!__pred(*__first))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_ALL_OF_H
|
||||
37
lib/libcxx/include/__algorithm/any_of.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/any_of.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_ANY_OF_H
|
||||
#define _LIBCPP___ALGORITHM_ANY_OF_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _Predicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
|
||||
for (; __first != __last; ++__first)
|
||||
if (__pred(*__first))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_ANY_OF_H
|
||||
61
lib/libcxx/include/__algorithm/binary_search.h
vendored
Normal file
61
lib/libcxx/include/__algorithm/binary_search.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_BINARY_SEARCH_H
|
||||
#define _LIBCPP___ALGORITHM_BINARY_SEARCH_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/lower_bound.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _ForwardIterator, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
|
||||
{
|
||||
__first = _VSTD::__lower_bound<_Compare>(__first, __last, __value_, __comp);
|
||||
return __first != __last && !__comp(__value_, *__first);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__binary_search<_Comp_ref>(__first, __last, __value_, __comp);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
|
||||
{
|
||||
return _VSTD::binary_search(__first, __last, __value_,
|
||||
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
|
||||
}
|
||||
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_BINARY_SEARCH_H
|
||||
52
lib/libcxx/include/__algorithm/clamp.h
vendored
Normal file
52
lib/libcxx/include/__algorithm/clamp.h
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_CLAMP_H
|
||||
#define _LIBCPP___ALGORITHM_CLAMP_H
|
||||
|
||||
#include <__config>
|
||||
#include <__debug>
|
||||
#include <__algorithm/comp.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
// clamp
|
||||
template<class _Tp, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
const _Tp&
|
||||
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
|
||||
{
|
||||
_LIBCPP_ASSERT(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
|
||||
return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;
|
||||
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
const _Tp&
|
||||
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
|
||||
{
|
||||
return _VSTD::clamp(__v, __lo, __hi, __less<_Tp>());
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_CLAMP_H
|
||||
97
lib/libcxx/include/__algorithm/comp.h
vendored
Normal file
97
lib/libcxx/include/__algorithm/comp.h
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_COMP_H
|
||||
#define _LIBCPP___ALGORITHM_COMP_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// I'd like to replace these with _VSTD::equal_to<void>, but can't because:
|
||||
// * That only works with C++14 and later, and
|
||||
// * We haven't included <functional> here.
|
||||
template <class _T1, class _T2 = _T1>
|
||||
struct __equal_to
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;}
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __equal_to<_T1, _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __equal_to<const _T1, _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __equal_to<_T1, const _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
|
||||
};
|
||||
|
||||
template <class _T1, class _T2 = _T1>
|
||||
struct __less
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __less<_T1, _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __less<const _T1, _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __less<_T1, const _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_COMP_H
|
||||
87
lib/libcxx/include/__algorithm/comp_ref_type.h
vendored
Normal file
87
lib/libcxx/include/__algorithm/comp_ref_type.h
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
|
||||
#define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
|
||||
|
||||
#include <__config>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifdef _LIBCPP_DEBUG
|
||||
|
||||
template <class _Compare>
|
||||
struct __debug_less
|
||||
{
|
||||
_Compare &__comp_;
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
__debug_less(_Compare& __c) : __comp_(__c) {}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool operator()(const _Tp& __x, const _Up& __y)
|
||||
{
|
||||
bool __r = __comp_(__x, __y);
|
||||
if (__r)
|
||||
__do_compare_assert(0, __y, __x);
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool operator()(_Tp& __x, _Up& __y)
|
||||
{
|
||||
bool __r = __comp_(__x, __y);
|
||||
if (__r)
|
||||
__do_compare_assert(0, __y, __x);
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <class _LHS, class _RHS>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
decltype((void)declval<_Compare&>()(
|
||||
declval<_LHS &>(), declval<_RHS &>()))
|
||||
__do_compare_assert(int, _LHS & __l, _RHS & __r) {
|
||||
_LIBCPP_ASSERT(!__comp_(__l, __r),
|
||||
"Comparator does not induce a strict weak ordering");
|
||||
}
|
||||
|
||||
template <class _LHS, class _RHS>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __do_compare_assert(long, _LHS &, _RHS &) {}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_DEBUG
|
||||
|
||||
template <class _Comp>
|
||||
struct __comp_ref_type {
|
||||
// Pass the comparator by lvalue reference. Or in debug mode, using a
|
||||
// debugging wrapper that stores a reference.
|
||||
#ifndef _LIBCPP_DEBUG
|
||||
typedef typename add_lvalue_reference<_Comp>::type type;
|
||||
#else
|
||||
typedef __debug_less<_Comp> type;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
|
||||
82
lib/libcxx/include/__algorithm/copy.h
vendored
Normal file
82
lib/libcxx/include/__algorithm/copy.h
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_COPY_H
|
||||
#define _LIBCPP___ALGORITHM_COPY_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/unwrap_iter.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// copy
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
__copy_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
*__result = *__first;
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
return _VSTD::__copy_constexpr(__first, __last, __result);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
is_same<typename remove_const<_Tp>::type, _Up>::value &&
|
||||
is_trivially_copy_assignable<_Up>::value,
|
||||
_Up*
|
||||
>::type
|
||||
__copy(_Tp* __first, _Tp* __last, _Up* __result)
|
||||
{
|
||||
const size_t __n = static_cast<size_t>(__last - __first);
|
||||
if (__n > 0)
|
||||
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
|
||||
return __result + __n;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
if (__libcpp_is_constant_evaluated()) {
|
||||
return _VSTD::__copy_constexpr(__first, __last, __result);
|
||||
} else {
|
||||
return _VSTD::__rewrap_iter(__result,
|
||||
_VSTD::__copy(_VSTD::__unwrap_iter(__first),
|
||||
_VSTD::__unwrap_iter(__last),
|
||||
_VSTD::__unwrap_iter(__result)));
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_COPY_H
|
||||
84
lib/libcxx/include/__algorithm/copy_backward.h
vendored
Normal file
84
lib/libcxx/include/__algorithm/copy_backward.h
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_COPY_BACKWARD_H
|
||||
#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/unwrap_iter.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _BidirectionalIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
__copy_backward_constexpr(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
|
||||
{
|
||||
while (__first != __last)
|
||||
*--__result = *--__last;
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
|
||||
{
|
||||
return _VSTD::__copy_backward_constexpr(__first, __last, __result);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
is_same<typename remove_const<_Tp>::type, _Up>::value &&
|
||||
is_trivially_copy_assignable<_Up>::value,
|
||||
_Up*
|
||||
>::type
|
||||
__copy_backward(_Tp* __first, _Tp* __last, _Up* __result)
|
||||
{
|
||||
const size_t __n = static_cast<size_t>(__last - __first);
|
||||
if (__n > 0)
|
||||
{
|
||||
__result -= __n;
|
||||
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator1, class _BidirectionalIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_BidirectionalIterator2
|
||||
copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
|
||||
_BidirectionalIterator2 __result)
|
||||
{
|
||||
if (__libcpp_is_constant_evaluated()) {
|
||||
return _VSTD::__copy_backward_constexpr(__first, __last, __result);
|
||||
} else {
|
||||
return _VSTD::__rewrap_iter(__result,
|
||||
_VSTD::__copy_backward(_VSTD::__unwrap_iter(__first),
|
||||
_VSTD::__unwrap_iter(__last),
|
||||
_VSTD::__unwrap_iter(__result)));
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_COPY_BACKWARD_H
|
||||
48
lib/libcxx/include/__algorithm/copy_if.h
vendored
Normal file
48
lib/libcxx/include/__algorithm/copy_if.h
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_COPY_IF_H
|
||||
#define _LIBCPP___ALGORITHM_COPY_IF_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/unwrap_iter.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template<class _InputIterator, class _OutputIterator, class _Predicate>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
copy_if(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Predicate __pred)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
{
|
||||
if (__pred(*__first))
|
||||
{
|
||||
*__result = *__first;
|
||||
++__result;
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_COPY_IF_H
|
||||
72
lib/libcxx/include/__algorithm/copy_n.h
vendored
Normal file
72
lib/libcxx/include/__algorithm/copy_n.h
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_COPY_N_H
|
||||
#define _LIBCPP___ALGORITHM_COPY_N_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/copy.h>
|
||||
#include <__algorithm/unwrap_iter.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template<class _InputIterator, class _Size, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
typename enable_if
|
||||
<
|
||||
__is_cpp17_input_iterator<_InputIterator>::value &&
|
||||
!__is_cpp17_random_access_iterator<_InputIterator>::value,
|
||||
_OutputIterator
|
||||
>::type
|
||||
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
|
||||
{
|
||||
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
|
||||
_IntegralSize __n = __orig_n;
|
||||
if (__n > 0)
|
||||
{
|
||||
*__result = *__first;
|
||||
++__result;
|
||||
for (--__n; __n > 0; --__n)
|
||||
{
|
||||
++__first;
|
||||
*__result = *__first;
|
||||
++__result;
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template<class _InputIterator, class _Size, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
typename enable_if
|
||||
<
|
||||
__is_cpp17_random_access_iterator<_InputIterator>::value,
|
||||
_OutputIterator
|
||||
>::type
|
||||
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
|
||||
{
|
||||
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
|
||||
_IntegralSize __n = __orig_n;
|
||||
return _VSTD::copy(__first, __first + __n, __result);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_COPY_N_H
|
||||
40
lib/libcxx/include/__algorithm/count.h
vendored
Normal file
40
lib/libcxx/include/__algorithm/count.h
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_COUNT_H
|
||||
#define _LIBCPP___ALGORITHM_COUNT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
typename iterator_traits<_InputIterator>::difference_type
|
||||
count(_InputIterator __first, _InputIterator __last, const _Tp& __value_) {
|
||||
typename iterator_traits<_InputIterator>::difference_type __r(0);
|
||||
for (; __first != __last; ++__first)
|
||||
if (*__first == __value_)
|
||||
++__r;
|
||||
return __r;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_COUNT_H
|
||||
40
lib/libcxx/include/__algorithm/count_if.h
vendored
Normal file
40
lib/libcxx/include/__algorithm/count_if.h
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_COUNT_IF_H
|
||||
#define _LIBCPP___ALGORITHM_COUNT_IF_H
|
||||
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _Predicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
typename iterator_traits<_InputIterator>::difference_type
|
||||
count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
|
||||
typename iterator_traits<_InputIterator>::difference_type __r(0);
|
||||
for (; __first != __last; ++__first)
|
||||
if (__pred(*__first))
|
||||
++__r;
|
||||
return __r;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_COUNT_IF_H
|
||||
90
lib/libcxx/include/__algorithm/equal.h
vendored
Normal file
90
lib/libcxx/include/__algorithm/equal.h
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_EQUAL_H
|
||||
#define _LIBCPP___ALGORITHM_EQUAL_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <iterator> // FIXME: replace with <__iterator/distance.h> when it lands
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
|
||||
for (; __first1 != __last1; ++__first1, (void)++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
|
||||
typedef typename iterator_traits<_InputIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_InputIterator2>::value_type __v2;
|
||||
return _VSTD::equal(__first1, __last1, __first2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
__equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
|
||||
_BinaryPredicate __pred, input_iterator_tag, input_iterator_tag) {
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
return false;
|
||||
return __first1 == __last1 && __first2 == __last2;
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
|
||||
_RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag,
|
||||
random_access_iterator_tag) {
|
||||
if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
|
||||
return false;
|
||||
return _VSTD::equal<_RandomAccessIterator1, _RandomAccessIterator2,
|
||||
typename add_lvalue_reference<_BinaryPredicate>::type>(__first1, __last1, __first2, __pred);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
|
||||
_BinaryPredicate __pred) {
|
||||
return _VSTD::__equal<typename add_lvalue_reference<_BinaryPredicate>::type>(
|
||||
__first1, __last1, __first2, __last2, __pred, typename iterator_traits<_InputIterator1>::iterator_category(),
|
||||
typename iterator_traits<_InputIterator2>::iterator_category());
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
|
||||
typedef typename iterator_traits<_InputIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_InputIterator2>::value_type __v2;
|
||||
return _VSTD::__equal(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(),
|
||||
typename iterator_traits<_InputIterator1>::iterator_category(),
|
||||
typename iterator_traits<_InputIterator2>::iterator_category());
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_EQUAL_H
|
||||
87
lib/libcxx/include/__algorithm/equal_range.h
vendored
Normal file
87
lib/libcxx/include/__algorithm/equal_range.h
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_EQUAL_RANGE_H
|
||||
#define _LIBCPP___ALGORITHM_EQUAL_RANGE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/half_positive.h>
|
||||
#include <__algorithm/lower_bound.h>
|
||||
#include <__algorithm/upper_bound.h>
|
||||
#include <iterator>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _ForwardIterator, class _Tp>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
|
||||
__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
|
||||
difference_type __len = _VSTD::distance(__first, __last);
|
||||
while (__len != 0)
|
||||
{
|
||||
difference_type __l2 = _VSTD::__half_positive(__len);
|
||||
_ForwardIterator __m = __first;
|
||||
_VSTD::advance(__m, __l2);
|
||||
if (__comp(*__m, __value_))
|
||||
{
|
||||
__first = ++__m;
|
||||
__len -= __l2 + 1;
|
||||
}
|
||||
else if (__comp(__value_, *__m))
|
||||
{
|
||||
__last = __m;
|
||||
__len = __l2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ForwardIterator __mp1 = __m;
|
||||
return pair<_ForwardIterator, _ForwardIterator>
|
||||
(
|
||||
_VSTD::__lower_bound<_Compare>(__first, __m, __value_, __comp),
|
||||
_VSTD::__upper_bound<_Compare>(++__mp1, __last, __value_, __comp)
|
||||
);
|
||||
}
|
||||
}
|
||||
return pair<_ForwardIterator, _ForwardIterator>(__first, __first);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
pair<_ForwardIterator, _ForwardIterator>
|
||||
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value_, __comp);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
pair<_ForwardIterator, _ForwardIterator>
|
||||
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
|
||||
{
|
||||
return _VSTD::equal_range(__first, __last, __value_,
|
||||
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_EQUAL_RANGE_H
|
||||
55
lib/libcxx/include/__algorithm/fill.h
vendored
Normal file
55
lib/libcxx/include/__algorithm/fill.h
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_FILL_H
|
||||
#define _LIBCPP___ALGORITHM_FILL_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/fill_n.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
*__first = __value_;
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag)
|
||||
{
|
||||
_VSTD::fill_n(__first, __last - __first, __value_);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
|
||||
{
|
||||
_VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_FILL_H
|
||||
47
lib/libcxx/include/__algorithm/fill_n.h
vendored
Normal file
47
lib/libcxx/include/__algorithm/fill_n.h
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_FILL_N_H
|
||||
#define _LIBCPP___ALGORITHM_FILL_N_H
|
||||
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _OutputIterator, class _Size, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
|
||||
{
|
||||
for (; __n > 0; ++__first, (void) --__n)
|
||||
*__first = __value_;
|
||||
return __first;
|
||||
}
|
||||
|
||||
template <class _OutputIterator, class _Size, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
|
||||
{
|
||||
return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_FILL_N_H
|
||||
37
lib/libcxx/include/__algorithm/find.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/find.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_FIND_H
|
||||
#define _LIBCPP___ALGORITHM_FIND_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
|
||||
find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) {
|
||||
for (; __first != __last; ++__first)
|
||||
if (*__first == __value_)
|
||||
break;
|
||||
return __first;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_FIND_H
|
||||
154
lib/libcxx/include/__algorithm/find_end.h
vendored
Normal file
154
lib/libcxx/include/__algorithm/find_end.h
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_FIND_END_OF_H
|
||||
#define _LIBCPP___ALGORITHM_FIND_END_OF_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
|
||||
_BinaryPredicate __pred, forward_iterator_tag,
|
||||
forward_iterator_tag) {
|
||||
// modeled after search algorithm
|
||||
_ForwardIterator1 __r = __last1; // __last1 is the "default" answer
|
||||
if (__first2 == __last2)
|
||||
return __r;
|
||||
while (true) {
|
||||
while (true) {
|
||||
if (__first1 == __last1) // if source exhausted return last correct answer
|
||||
return __r; // (or __last1 if never found)
|
||||
if (__pred(*__first1, *__first2))
|
||||
break;
|
||||
++__first1;
|
||||
}
|
||||
// *__first1 matches *__first2, now match elements after here
|
||||
_ForwardIterator1 __m1 = __first1;
|
||||
_ForwardIterator2 __m2 = __first2;
|
||||
while (true) {
|
||||
if (++__m2 == __last2) { // Pattern exhaused, record answer and search for another one
|
||||
__r = __first1;
|
||||
++__first1;
|
||||
break;
|
||||
}
|
||||
if (++__m1 == __last1) // Source exhausted, return last answer
|
||||
return __r;
|
||||
if (!__pred(*__m1, *__m2)) // mismatch, restart with a new __first
|
||||
{
|
||||
++__first1;
|
||||
break;
|
||||
} // else there is a match, check next elements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _BidirectionalIterator1, class _BidirectionalIterator2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1 __find_end(
|
||||
_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2,
|
||||
_BidirectionalIterator2 __last2, _BinaryPredicate __pred, bidirectional_iterator_tag, bidirectional_iterator_tag) {
|
||||
// modeled after search algorithm (in reverse)
|
||||
if (__first2 == __last2)
|
||||
return __last1; // Everything matches an empty sequence
|
||||
_BidirectionalIterator1 __l1 = __last1;
|
||||
_BidirectionalIterator2 __l2 = __last2;
|
||||
--__l2;
|
||||
while (true) {
|
||||
// Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks
|
||||
while (true) {
|
||||
if (__first1 == __l1) // return __last1 if no element matches *__first2
|
||||
return __last1;
|
||||
if (__pred(*--__l1, *__l2))
|
||||
break;
|
||||
}
|
||||
// *__l1 matches *__l2, now match elements before here
|
||||
_BidirectionalIterator1 __m1 = __l1;
|
||||
_BidirectionalIterator2 __m2 = __l2;
|
||||
while (true) {
|
||||
if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern)
|
||||
return __m1;
|
||||
if (__m1 == __first1) // Otherwise if source exhaused, pattern not found
|
||||
return __last1;
|
||||
if (!__pred(*--__m1, *--__m2)) // if there is a mismatch, restart with a new __l1
|
||||
{
|
||||
break;
|
||||
} // else there is a match, check next elements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end(
|
||||
_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
|
||||
_RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) {
|
||||
// Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
|
||||
typename iterator_traits<_RandomAccessIterator2>::difference_type __len2 = __last2 - __first2;
|
||||
if (__len2 == 0)
|
||||
return __last1;
|
||||
typename iterator_traits<_RandomAccessIterator1>::difference_type __len1 = __last1 - __first1;
|
||||
if (__len1 < __len2)
|
||||
return __last1;
|
||||
const _RandomAccessIterator1 __s = __first1 + (__len2 - 1); // End of pattern match can't go before here
|
||||
_RandomAccessIterator1 __l1 = __last1;
|
||||
_RandomAccessIterator2 __l2 = __last2;
|
||||
--__l2;
|
||||
while (true) {
|
||||
while (true) {
|
||||
if (__s == __l1)
|
||||
return __last1;
|
||||
if (__pred(*--__l1, *__l2))
|
||||
break;
|
||||
}
|
||||
_RandomAccessIterator1 __m1 = __l1;
|
||||
_RandomAccessIterator2 __m2 = __l2;
|
||||
while (true) {
|
||||
if (__m2 == __first2)
|
||||
return __m1;
|
||||
// no need to check range on __m1 because __s guarantees we have enough source
|
||||
if (!__pred(*--__m1, *--__m2)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
|
||||
find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2,
|
||||
_BinaryPredicate __pred) {
|
||||
return _VSTD::__find_end<typename add_lvalue_reference<_BinaryPredicate>::type>(
|
||||
__first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(),
|
||||
typename iterator_traits<_ForwardIterator2>::iterator_category());
|
||||
}
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
|
||||
find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
|
||||
typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
|
||||
return _VSTD::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_FIND_END_OF_H
|
||||
57
lib/libcxx/include/__algorithm/find_first_of.h
vendored
Normal file
57
lib/libcxx/include/__algorithm/find_first_of.h
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_FIND_FIRST_OF_H
|
||||
#define _LIBCPP___ALGORITHM_FIND_FIRST_OF_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1,
|
||||
_ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2,
|
||||
_ForwardIterator2 __last2, _BinaryPredicate __pred) {
|
||||
for (; __first1 != __last1; ++__first1)
|
||||
for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
|
||||
if (__pred(*__first1, *__j))
|
||||
return __first1;
|
||||
return __last1;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
|
||||
find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
|
||||
_ForwardIterator2 __last2, _BinaryPredicate __pred) {
|
||||
return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 find_first_of(
|
||||
_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
|
||||
typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
|
||||
return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_FIND_FIRST_OF_H
|
||||
37
lib/libcxx/include/__algorithm/find_if.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/find_if.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_FIND_IF_H
|
||||
#define _LIBCPP___ALGORITHM_FIND_IF_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _Predicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
|
||||
find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
|
||||
for (; __first != __last; ++__first)
|
||||
if (__pred(*__first))
|
||||
break;
|
||||
return __first;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_FIND_IF_H
|
||||
37
lib/libcxx/include/__algorithm/find_if_not.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/find_if_not.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_FIND_IF_NOT_H
|
||||
#define _LIBCPP___ALGORITHM_FIND_IF_NOT_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _Predicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
|
||||
find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
|
||||
for (; __first != __last; ++__first)
|
||||
if (!__pred(*__first))
|
||||
break;
|
||||
return __first;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_FIND_IF_NOT_H
|
||||
37
lib/libcxx/include/__algorithm/for_each.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/for_each.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_FOR_EACH_H
|
||||
#define _LIBCPP___ALGORITHM_FOR_EACH_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _Function>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Function for_each(_InputIterator __first,
|
||||
_InputIterator __last,
|
||||
_Function __f) {
|
||||
for (; __first != __last; ++__first)
|
||||
__f(*__first);
|
||||
return __f;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_FOR_EACH_H
|
||||
47
lib/libcxx/include/__algorithm/for_each_n.h
vendored
Normal file
47
lib/libcxx/include/__algorithm/for_each_n.h
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_FOR_EACH_N_H
|
||||
#define _LIBCPP___ALGORITHM_FOR_EACH_N_H
|
||||
|
||||
#include <__config>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
template <class _InputIterator, class _Size, class _Function>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator for_each_n(_InputIterator __first,
|
||||
_Size __orig_n,
|
||||
_Function __f) {
|
||||
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
|
||||
_IntegralSize __n = __orig_n;
|
||||
while (__n > 0) {
|
||||
__f(*__first);
|
||||
++__first;
|
||||
--__n;
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_FOR_EACH_N_H
|
||||
36
lib/libcxx/include/__algorithm/generate.h
vendored
Normal file
36
lib/libcxx/include/__algorithm/generate.h
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_GENERATE_H
|
||||
#define _LIBCPP___ALGORITHM_GENERATE_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _Generator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
*__first = __gen();
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_GENERATE_H
|
||||
40
lib/libcxx/include/__algorithm/generate_n.h
vendored
Normal file
40
lib/libcxx/include/__algorithm/generate_n.h
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_GENERATE_N_H
|
||||
#define _LIBCPP___ALGORITHM_GENERATE_N_H
|
||||
|
||||
#include <__config>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _OutputIterator, class _Size, class _Generator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
|
||||
{
|
||||
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
|
||||
_IntegralSize __n = __orig_n;
|
||||
for (; __n > 0; ++__first, (void) --__n)
|
||||
*__first = __gen();
|
||||
return __first;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_GENERATE_N_H
|
||||
54
lib/libcxx/include/__algorithm/half_positive.h
vendored
Normal file
54
lib/libcxx/include/__algorithm/half_positive.h
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_HALF_POSITIVE_H
|
||||
#define _LIBCPP___ALGORITHM_HALF_POSITIVE_H
|
||||
|
||||
#include <__config>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// Perform division by two quickly for positive integers (llvm.org/PR39129)
|
||||
|
||||
template <typename _Integral>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
typename enable_if
|
||||
<
|
||||
is_integral<_Integral>::value,
|
||||
_Integral
|
||||
>::type
|
||||
__half_positive(_Integral __value)
|
||||
{
|
||||
return static_cast<_Integral>(static_cast<typename make_unsigned<_Integral>::type>(__value) / 2);
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
typename enable_if
|
||||
<
|
||||
!is_integral<_Tp>::value,
|
||||
_Tp
|
||||
>::type
|
||||
__half_positive(_Tp __value)
|
||||
{
|
||||
return __value / 2;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_HALF_POSITIVE_H
|
||||
67
lib/libcxx/include/__algorithm/includes.h
vendored
Normal file
67
lib/libcxx/include/__algorithm/includes.h
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_INCLUDES_H
|
||||
#define _LIBCPP___ALGORITHM_INCLUDES_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _InputIterator1, class _InputIterator2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
__includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
|
||||
_Compare __comp)
|
||||
{
|
||||
for (; __first2 != __last2; ++__first1)
|
||||
{
|
||||
if (__first1 == __last1 || __comp(*__first2, *__first1))
|
||||
return false;
|
||||
if (!__comp(*__first1, *__first2))
|
||||
++__first2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
|
||||
_Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2)
|
||||
{
|
||||
return _VSTD::includes(__first1, __last1, __first2, __last2,
|
||||
__less<typename iterator_traits<_InputIterator1>::value_type,
|
||||
typename iterator_traits<_InputIterator2>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_INCLUDES_H
|
||||
231
lib/libcxx/include/__algorithm/inplace_merge.h
vendored
Normal file
231
lib/libcxx/include/__algorithm/inplace_merge.h
vendored
Normal file
@ -0,0 +1,231 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_INPLACE_MERGE_H
|
||||
#define _LIBCPP___ALGORITHM_INPLACE_MERGE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/lower_bound.h>
|
||||
#include <__algorithm/min.h>
|
||||
#include <__algorithm/move.h>
|
||||
#include <__algorithm/rotate.h>
|
||||
#include <__algorithm/upper_bound.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/swap.h>
|
||||
#include <memory>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Predicate>
|
||||
class __invert // invert the sense of a comparison
|
||||
{
|
||||
private:
|
||||
_Predicate __p_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY __invert() {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __invert(_Predicate __p) : __p_(__p) {}
|
||||
|
||||
template <class _T1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _T1& __x) {return !__p_(__x);}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);}
|
||||
};
|
||||
|
||||
template <class _Compare, class _InputIterator1, class _InputIterator2,
|
||||
class _OutputIterator>
|
||||
void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2,
|
||||
_OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
for (; __first1 != __last1; ++__result)
|
||||
{
|
||||
if (__first2 == __last2)
|
||||
{
|
||||
_VSTD::move(__first1, __last1, __result);
|
||||
return;
|
||||
}
|
||||
|
||||
if (__comp(*__first2, *__first1))
|
||||
{
|
||||
*__result = _VSTD::move(*__first2);
|
||||
++__first2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*__result = _VSTD::move(*__first1);
|
||||
++__first1;
|
||||
}
|
||||
}
|
||||
// __first2 through __last2 are already in the right spot.
|
||||
}
|
||||
|
||||
template <class _Compare, class _BidirectionalIterator>
|
||||
void
|
||||
__buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
|
||||
_Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
|
||||
typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
|
||||
typename iterator_traits<_BidirectionalIterator>::value_type* __buff)
|
||||
{
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
|
||||
__destruct_n __d(0);
|
||||
unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
|
||||
if (__len1 <= __len2)
|
||||
{
|
||||
value_type* __p = __buff;
|
||||
for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
|
||||
::new ((void*)__p) value_type(_VSTD::move(*__i));
|
||||
_VSTD::__half_inplace_merge<_Compare>(__buff, __p, __middle, __last, __first, __comp);
|
||||
}
|
||||
else
|
||||
{
|
||||
value_type* __p = __buff;
|
||||
for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
|
||||
::new ((void*)__p) value_type(_VSTD::move(*__i));
|
||||
typedef reverse_iterator<_BidirectionalIterator> _RBi;
|
||||
typedef reverse_iterator<value_type*> _Rv;
|
||||
typedef __invert<_Compare> _Inverted;
|
||||
_VSTD::__half_inplace_merge<_Inverted>(_Rv(__p), _Rv(__buff),
|
||||
_RBi(__middle), _RBi(__first),
|
||||
_RBi(__last), _Inverted(__comp));
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Compare, class _BidirectionalIterator>
|
||||
void
|
||||
__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
|
||||
_Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
|
||||
typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
|
||||
typename iterator_traits<_BidirectionalIterator>::value_type* __buff, ptrdiff_t __buff_size)
|
||||
{
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
|
||||
while (true)
|
||||
{
|
||||
// if __middle == __last, we're done
|
||||
if (__len2 == 0)
|
||||
return;
|
||||
if (__len1 <= __buff_size || __len2 <= __buff_size)
|
||||
return _VSTD::__buffered_inplace_merge<_Compare>
|
||||
(__first, __middle, __last, __comp, __len1, __len2, __buff);
|
||||
// shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
|
||||
for (; true; ++__first, (void) --__len1)
|
||||
{
|
||||
if (__len1 == 0)
|
||||
return;
|
||||
if (__comp(*__middle, *__first))
|
||||
break;
|
||||
}
|
||||
// __first < __middle < __last
|
||||
// *__first > *__middle
|
||||
// partition [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) such that
|
||||
// all elements in:
|
||||
// [__first, __m1) <= [__middle, __m2)
|
||||
// [__middle, __m2) < [__m1, __middle)
|
||||
// [__m1, __middle) <= [__m2, __last)
|
||||
// and __m1 or __m2 is in the middle of its range
|
||||
_BidirectionalIterator __m1; // "median" of [__first, __middle)
|
||||
_BidirectionalIterator __m2; // "median" of [__middle, __last)
|
||||
difference_type __len11; // distance(__first, __m1)
|
||||
difference_type __len21; // distance(__middle, __m2)
|
||||
// binary search smaller range
|
||||
if (__len1 < __len2)
|
||||
{ // __len >= 1, __len2 >= 2
|
||||
__len21 = __len2 / 2;
|
||||
__m2 = __middle;
|
||||
_VSTD::advance(__m2, __len21);
|
||||
__m1 = _VSTD::__upper_bound<_Compare>(__first, __middle, *__m2, __comp);
|
||||
__len11 = _VSTD::distance(__first, __m1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__len1 == 1)
|
||||
{ // __len1 >= __len2 && __len2 > 0, therefore __len2 == 1
|
||||
// It is known *__first > *__middle
|
||||
swap(*__first, *__middle);
|
||||
return;
|
||||
}
|
||||
// __len1 >= 2, __len2 >= 1
|
||||
__len11 = __len1 / 2;
|
||||
__m1 = __first;
|
||||
_VSTD::advance(__m1, __len11);
|
||||
__m2 = _VSTD::__lower_bound<_Compare>(__middle, __last, *__m1, __comp);
|
||||
__len21 = _VSTD::distance(__middle, __m2);
|
||||
}
|
||||
difference_type __len12 = __len1 - __len11; // distance(__m1, __middle)
|
||||
difference_type __len22 = __len2 - __len21; // distance(__m2, __last)
|
||||
// [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last)
|
||||
// swap middle two partitions
|
||||
__middle = _VSTD::rotate(__m1, __middle, __m2);
|
||||
// __len12 and __len21 now have swapped meanings
|
||||
// merge smaller range with recursive call and larger with tail recursion elimination
|
||||
if (__len11 + __len21 < __len12 + __len22)
|
||||
{
|
||||
_VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
|
||||
// _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
|
||||
__first = __middle;
|
||||
__middle = __m2;
|
||||
__len1 = __len12;
|
||||
__len2 = __len22;
|
||||
}
|
||||
else
|
||||
{
|
||||
_VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
|
||||
// _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
|
||||
__last = __middle;
|
||||
__middle = __m1;
|
||||
__len1 = __len11;
|
||||
__len2 = __len21;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
|
||||
_Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
|
||||
difference_type __len1 = _VSTD::distance(__first, __middle);
|
||||
difference_type __len2 = _VSTD::distance(__middle, __last);
|
||||
difference_type __buf_size = _VSTD::min(__len1, __len2);
|
||||
pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
|
||||
unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2,
|
||||
__buf.first, __buf.second);
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last)
|
||||
{
|
||||
_VSTD::inplace_merge(__first, __middle, __last,
|
||||
__less<typename iterator_traits<_BidirectionalIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_INPLACE_MERGE_H
|
||||
48
lib/libcxx/include/__algorithm/is_heap.h
vendored
Normal file
48
lib/libcxx/include/__algorithm/is_heap.h
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_IS_HEAP_H
|
||||
#define _LIBCPP___ALGORITHM_IS_HEAP_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/is_heap_until.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
return _VSTD::is_heap_until(__first, __last, __comp) == __last;
|
||||
}
|
||||
|
||||
template<class _RandomAccessIterator>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
return _VSTD::is_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_IS_HEAP_H
|
||||
65
lib/libcxx/include/__algorithm/is_heap_until.h
vendored
Normal file
65
lib/libcxx/include/__algorithm/is_heap_until.h
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
|
||||
#define _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
|
||||
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
difference_type __len = __last - __first;
|
||||
difference_type __p = 0;
|
||||
difference_type __c = 1;
|
||||
_RandomAccessIterator __pp = __first;
|
||||
while (__c < __len)
|
||||
{
|
||||
_RandomAccessIterator __cp = __first + __c;
|
||||
if (__comp(*__pp, *__cp))
|
||||
return __cp;
|
||||
++__c;
|
||||
++__cp;
|
||||
if (__c == __len)
|
||||
return __last;
|
||||
if (__comp(*__pp, *__cp))
|
||||
return __cp;
|
||||
++__p;
|
||||
++__pp;
|
||||
__c = 2 * __p + 1;
|
||||
}
|
||||
return __last;
|
||||
}
|
||||
|
||||
template<class _RandomAccessIterator>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_RandomAccessIterator
|
||||
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
return _VSTD::is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
|
||||
43
lib/libcxx/include/__algorithm/is_partitioned.h
vendored
Normal file
43
lib/libcxx/include/__algorithm/is_partitioned.h
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_IS_PARTITIONED_H
|
||||
#define _LIBCPP___ALGORITHM_IS_PARTITIONED_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _Predicate>
|
||||
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
if (!__pred(*__first))
|
||||
break;
|
||||
if ( __first == __last )
|
||||
return true;
|
||||
++__first;
|
||||
for (; __first != __last; ++__first)
|
||||
if (__pred(*__first))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_IS_PARTITIONED_H
|
||||
168
lib/libcxx/include/__algorithm/is_permutation.h
vendored
Normal file
168
lib/libcxx/include/__algorithm/is_permutation.h
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_IS_PERMUTATION_H
|
||||
#define _LIBCPP___ALGORITHM_IS_PERMUTATION_H
|
||||
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__iterator/next.h>
|
||||
#include <iterator> // FIXME: replace with <__iterator/distance.h> when it lands
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
|
||||
_BinaryPredicate __pred) {
|
||||
// shorten sequences as much as possible by lopping of any equal prefix
|
||||
for (; __first1 != __last1; ++__first1, (void)++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
break;
|
||||
if (__first1 == __last1)
|
||||
return true;
|
||||
|
||||
// __first1 != __last1 && *__first1 != *__first2
|
||||
typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
|
||||
_D1 __l1 = _VSTD::distance(__first1, __last1);
|
||||
if (__l1 == _D1(1))
|
||||
return false;
|
||||
_ForwardIterator2 __last2 = _VSTD::next(__first2, __l1);
|
||||
// For each element in [f1, l1) see if there are the same number of
|
||||
// equal elements in [f2, l2)
|
||||
for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) {
|
||||
// Have we already counted the number of *__i in [f1, l1)?
|
||||
_ForwardIterator1 __match = __first1;
|
||||
for (; __match != __i; ++__match)
|
||||
if (__pred(*__match, *__i))
|
||||
break;
|
||||
if (__match == __i) {
|
||||
// Count number of *__i in [f2, l2)
|
||||
_D1 __c2 = 0;
|
||||
for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
|
||||
if (__pred(*__i, *__j))
|
||||
++__c2;
|
||||
if (__c2 == 0)
|
||||
return false;
|
||||
// Count number of *__i in [__i, l1) (we can start with 1)
|
||||
_D1 __c1 = 1;
|
||||
for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j)
|
||||
if (__pred(*__i, *__j))
|
||||
++__c1;
|
||||
if (__c1 != __c2)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
|
||||
typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
|
||||
return _VSTD::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
__is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
|
||||
_ForwardIterator2 __last2, _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) {
|
||||
// shorten sequences as much as possible by lopping of any equal prefix
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
break;
|
||||
if (__first1 == __last1)
|
||||
return __first2 == __last2;
|
||||
else if (__first2 == __last2)
|
||||
return false;
|
||||
|
||||
typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
|
||||
_D1 __l1 = _VSTD::distance(__first1, __last1);
|
||||
|
||||
typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2;
|
||||
_D2 __l2 = _VSTD::distance(__first2, __last2);
|
||||
if (__l1 != __l2)
|
||||
return false;
|
||||
|
||||
// For each element in [f1, l1) see if there are the same number of
|
||||
// equal elements in [f2, l2)
|
||||
for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) {
|
||||
// Have we already counted the number of *__i in [f1, l1)?
|
||||
_ForwardIterator1 __match = __first1;
|
||||
for (; __match != __i; ++__match)
|
||||
if (__pred(*__match, *__i))
|
||||
break;
|
||||
if (__match == __i) {
|
||||
// Count number of *__i in [f2, l2)
|
||||
_D1 __c2 = 0;
|
||||
for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
|
||||
if (__pred(*__i, *__j))
|
||||
++__c2;
|
||||
if (__c2 == 0)
|
||||
return false;
|
||||
// Count number of *__i in [__i, l1) (we can start with 1)
|
||||
_D1 __c1 = 1;
|
||||
for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j)
|
||||
if (__pred(*__i, *__j))
|
||||
++__c1;
|
||||
if (__c1 != __c2)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool __is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1,
|
||||
_RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2,
|
||||
_BinaryPredicate __pred, random_access_iterator_tag,
|
||||
random_access_iterator_tag) {
|
||||
if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
|
||||
return false;
|
||||
return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2,
|
||||
typename add_lvalue_reference<_BinaryPredicate>::type>(__first1, __last1, __first2,
|
||||
__pred);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
|
||||
_ForwardIterator2 __last2, _BinaryPredicate __pred) {
|
||||
return _VSTD::__is_permutation<typename add_lvalue_reference<_BinaryPredicate>::type>(
|
||||
__first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(),
|
||||
typename iterator_traits<_ForwardIterator2>::iterator_category());
|
||||
}
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
|
||||
_ForwardIterator2 __last2) {
|
||||
typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
|
||||
return _VSTD::__is_permutation(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(),
|
||||
typename iterator_traits<_ForwardIterator1>::iterator_category(),
|
||||
typename iterator_traits<_ForwardIterator2>::iterator_category());
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_IS_PERMUTATION_H
|
||||
48
lib/libcxx/include/__algorithm/is_sorted.h
vendored
Normal file
48
lib/libcxx/include/__algorithm/is_sorted.h
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_IS_SORTED_H
|
||||
#define _LIBCPP___ALGORITHM_IS_SORTED_H
|
||||
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/is_sorted_until.h>
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
{
|
||||
return _VSTD::is_sorted_until(__first, __last, __comp) == __last;
|
||||
}
|
||||
|
||||
template<class _ForwardIterator>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
is_sorted(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
return _VSTD::is_sorted(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_IS_SORTED_H
|
||||
55
lib/libcxx/include/__algorithm/is_sorted_until.h
vendored
Normal file
55
lib/libcxx/include/__algorithm/is_sorted_until.h
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H
|
||||
#define _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
{
|
||||
if (__first != __last)
|
||||
{
|
||||
_ForwardIterator __i = __first;
|
||||
while (++__i != __last)
|
||||
{
|
||||
if (__comp(*__i, *__first))
|
||||
return __i;
|
||||
__first = __i;
|
||||
}
|
||||
}
|
||||
return __last;
|
||||
}
|
||||
|
||||
template<class _ForwardIterator>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_ForwardIterator
|
||||
is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
return _VSTD::is_sorted_until(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H
|
||||
37
lib/libcxx/include/__algorithm/iter_swap.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/iter_swap.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_ITER_SWAP_H
|
||||
#define _LIBCPP___ALGORITHM_ITER_SWAP_H
|
||||
|
||||
#include <__config>
|
||||
#include <__utility/declval.h>
|
||||
#include <__utility/swap.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void iter_swap(_ForwardIterator1 __a,
|
||||
_ForwardIterator2 __b)
|
||||
// _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
|
||||
_NOEXCEPT_(_NOEXCEPT_(swap(*declval<_ForwardIterator1>(), *declval<_ForwardIterator2>()))) {
|
||||
swap(*__a, *__b);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_ITER_SWAP_H
|
||||
68
lib/libcxx/include/__algorithm/lexicographical_compare.h
vendored
Normal file
68
lib/libcxx/include/__algorithm/lexicographical_compare.h
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
|
||||
#define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _InputIterator1, class _InputIterator2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
__lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
|
||||
{
|
||||
for (; __first2 != __last2; ++__first1, (void) ++__first2)
|
||||
{
|
||||
if (__first1 == __last1 || __comp(*__first1, *__first2))
|
||||
return true;
|
||||
if (__comp(*__first2, *__first1))
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2)
|
||||
{
|
||||
return _VSTD::lexicographical_compare(__first1, __last1, __first2, __last2,
|
||||
__less<typename iterator_traits<_InputIterator1>::value_type,
|
||||
typename iterator_traits<_InputIterator2>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
|
||||
72
lib/libcxx/include/__algorithm/lower_bound.h
vendored
Normal file
72
lib/libcxx/include/__algorithm/lower_bound.h
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_LOWER_BOUND_H
|
||||
#define _LIBCPP___ALGORITHM_LOWER_BOUND_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/half_positive.h>
|
||||
#include <iterator>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _ForwardIterator, class _Tp>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
__lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
|
||||
difference_type __len = _VSTD::distance(__first, __last);
|
||||
while (__len != 0)
|
||||
{
|
||||
difference_type __l2 = _VSTD::__half_positive(__len);
|
||||
_ForwardIterator __m = __first;
|
||||
_VSTD::advance(__m, __l2);
|
||||
if (__comp(*__m, __value_))
|
||||
{
|
||||
__first = ++__m;
|
||||
__len -= __l2 + 1;
|
||||
}
|
||||
else
|
||||
__len = __l2;
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_ForwardIterator
|
||||
lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
|
||||
{
|
||||
typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__lower_bound<_Comp_ref>(__first, __last, __value_, __comp);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_ForwardIterator
|
||||
lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
|
||||
{
|
||||
return _VSTD::lower_bound(__first, __last, __value_,
|
||||
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_LOWER_BOUND_H
|
||||
64
lib/libcxx/include/__algorithm/make_heap.h
vendored
Normal file
64
lib/libcxx/include/__algorithm/make_heap.h
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_MAKE_HEAP_H
|
||||
#define _LIBCPP___ALGORITHM_MAKE_HEAP_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/sift_down.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 void
|
||||
__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
difference_type __n = __last - __first;
|
||||
if (__n > 1)
|
||||
{
|
||||
// start from the first parent, there is no need to consider children
|
||||
for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start)
|
||||
{
|
||||
_VSTD::__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
_VSTD::__make_heap<_Comp_ref>(__first, __last, __comp);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
_VSTD::make_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_MAKE_HEAP_H
|
||||
70
lib/libcxx/include/__algorithm/max.h
vendored
Normal file
70
lib/libcxx/include/__algorithm/max.h
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_MAX_H
|
||||
#define _LIBCPP___ALGORITHM_MAX_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/max_element.h>
|
||||
#include <initializer_list>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&
|
||||
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
{
|
||||
return __comp(__a, __b) ? __b : __a;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&
|
||||
max(const _Tp& __a, const _Tp& __b)
|
||||
{
|
||||
return _VSTD::max(__a, __b, __less<_Tp>());
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template<class _Tp, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp
|
||||
max(initializer_list<_Tp> __t, _Compare __comp)
|
||||
{
|
||||
return *_VSTD::max_element(__t.begin(), __t.end(), __comp);
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp
|
||||
max(initializer_list<_Tp> __t)
|
||||
{
|
||||
return *_VSTD::max_element(__t.begin(), __t.end(), __less<_Tp>());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_MAX_H
|
||||
58
lib/libcxx/include/__algorithm/max_element.h
vendored
Normal file
58
lib/libcxx/include/__algorithm/max_element.h
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_MAX_ELEMENT_H
|
||||
#define _LIBCPP___ALGORITHM_MAX_ELEMENT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_ForwardIterator
|
||||
max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
{
|
||||
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
|
||||
"std::max_element requires a ForwardIterator");
|
||||
if (__first != __last)
|
||||
{
|
||||
_ForwardIterator __i = __first;
|
||||
while (++__i != __last)
|
||||
if (__comp(*__first, *__i))
|
||||
__first = __i;
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
|
||||
template <class _ForwardIterator>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_ForwardIterator
|
||||
max_element(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
return _VSTD::max_element(__first, __last,
|
||||
__less<typename iterator_traits<_ForwardIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_MAX_ELEMENT_H
|
||||
76
lib/libcxx/include/__algorithm/merge.h
vendored
Normal file
76
lib/libcxx/include/__algorithm/merge.h
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_MERGE_H
|
||||
#define _LIBCPP___ALGORITHM_MERGE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/copy.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
__merge(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
for (; __first1 != __last1; ++__result)
|
||||
{
|
||||
if (__first2 == __last2)
|
||||
return _VSTD::copy(__first1, __last1, __result);
|
||||
if (__comp(*__first2, *__first1))
|
||||
{
|
||||
*__result = *__first2;
|
||||
++__first2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*__result = *__first1;
|
||||
++__first1;
|
||||
}
|
||||
}
|
||||
return _VSTD::copy(__first2, __last2, __result);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
merge(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
merge(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_InputIterator2>::value_type __v2;
|
||||
return _VSTD::merge(__first1, __last1, __first2, __last2, __result, __less<__v1, __v2>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_MERGE_H
|
||||
70
lib/libcxx/include/__algorithm/min.h
vendored
Normal file
70
lib/libcxx/include/__algorithm/min.h
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_MIN_H
|
||||
#define _LIBCPP___ALGORITHM_MIN_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/min_element.h>
|
||||
#include <initializer_list>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&
|
||||
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
{
|
||||
return __comp(__b, __a) ? __b : __a;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&
|
||||
min(const _Tp& __a, const _Tp& __b)
|
||||
{
|
||||
return _VSTD::min(__a, __b, __less<_Tp>());
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template<class _Tp, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp
|
||||
min(initializer_list<_Tp> __t, _Compare __comp)
|
||||
{
|
||||
return *_VSTD::min_element(__t.begin(), __t.end(), __comp);
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp
|
||||
min(initializer_list<_Tp> __t)
|
||||
{
|
||||
return *_VSTD::min_element(__t.begin(), __t.end(), __less<_Tp>());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_MIN_H
|
||||
57
lib/libcxx/include/__algorithm/min_element.h
vendored
Normal file
57
lib/libcxx/include/__algorithm/min_element.h
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_MIN_ELEMENT_H
|
||||
#define _LIBCPP___ALGORITHM_MIN_ELEMENT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_ForwardIterator
|
||||
min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
{
|
||||
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
|
||||
"std::min_element requires a ForwardIterator");
|
||||
if (__first != __last)
|
||||
{
|
||||
_ForwardIterator __i = __first;
|
||||
while (++__i != __last)
|
||||
if (__comp(*__i, *__first))
|
||||
__first = __i;
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_ForwardIterator
|
||||
min_element(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
return _VSTD::min_element(__first, __last,
|
||||
__less<typename iterator_traits<_ForwardIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_MIN_ELEMENT_H
|
||||
101
lib/libcxx/include/__algorithm/minmax.h
vendored
Normal file
101
lib/libcxx/include/__algorithm/minmax.h
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_MINMAX_H
|
||||
#define _LIBCPP___ALGORITHM_MINMAX_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <initializer_list>
|
||||
#include <utility>
|
||||
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template<class _Tp, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
{
|
||||
return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) :
|
||||
pair<const _Tp&, const _Tp&>(__a, __b);
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(const _Tp& __a, const _Tp& __b)
|
||||
{
|
||||
return _VSTD::minmax(__a, __b, __less<_Tp>());
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template<class _Tp, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<_Tp, _Tp>
|
||||
minmax(initializer_list<_Tp> __t, _Compare __comp)
|
||||
{
|
||||
typedef typename initializer_list<_Tp>::const_iterator _Iter;
|
||||
_Iter __first = __t.begin();
|
||||
_Iter __last = __t.end();
|
||||
pair<_Tp, _Tp> __result(*__first, *__first);
|
||||
|
||||
++__first;
|
||||
if (__t.size() % 2 == 0)
|
||||
{
|
||||
if (__comp(*__first, __result.first))
|
||||
__result.first = *__first;
|
||||
else
|
||||
__result.second = *__first;
|
||||
++__first;
|
||||
}
|
||||
|
||||
while (__first != __last)
|
||||
{
|
||||
_Tp __prev = *__first++;
|
||||
if (__comp(*__first, __prev)) {
|
||||
if ( __comp(*__first, __result.first)) __result.first = *__first;
|
||||
if (!__comp(__prev, __result.second)) __result.second = __prev;
|
||||
}
|
||||
else {
|
||||
if ( __comp(__prev, __result.first)) __result.first = __prev;
|
||||
if (!__comp(*__first, __result.second)) __result.second = *__first;
|
||||
}
|
||||
|
||||
__first++;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<_Tp, _Tp>
|
||||
minmax(initializer_list<_Tp> __t)
|
||||
{
|
||||
return _VSTD::minmax(__t, __less<_Tp>());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_MINMAX_H
|
||||
90
lib/libcxx/include/__algorithm/minmax_element.h
vendored
Normal file
90
lib/libcxx/include/__algorithm/minmax_element.h
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H
|
||||
#define _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <utility>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<_ForwardIterator, _ForwardIterator>
|
||||
minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
{
|
||||
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
|
||||
"std::minmax_element requires a ForwardIterator");
|
||||
pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);
|
||||
if (__first != __last)
|
||||
{
|
||||
if (++__first != __last)
|
||||
{
|
||||
if (__comp(*__first, *__result.first))
|
||||
__result.first = __first;
|
||||
else
|
||||
__result.second = __first;
|
||||
while (++__first != __last)
|
||||
{
|
||||
_ForwardIterator __i = __first;
|
||||
if (++__first == __last)
|
||||
{
|
||||
if (__comp(*__i, *__result.first))
|
||||
__result.first = __i;
|
||||
else if (!__comp(*__i, *__result.second))
|
||||
__result.second = __i;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__comp(*__first, *__i))
|
||||
{
|
||||
if (__comp(*__first, *__result.first))
|
||||
__result.first = __first;
|
||||
if (!__comp(*__i, *__result.second))
|
||||
__result.second = __i;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__comp(*__i, *__result.first))
|
||||
__result.first = __i;
|
||||
if (!__comp(*__first, *__result.second))
|
||||
__result.second = __first;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<_ForwardIterator, _ForwardIterator>
|
||||
minmax_element(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
return _VSTD::minmax_element(__first, __last,
|
||||
__less<typename iterator_traits<_ForwardIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H
|
||||
72
lib/libcxx/include/__algorithm/mismatch.h
vendored
Normal file
72
lib/libcxx/include/__algorithm/mismatch.h
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_MISMATCH_H
|
||||
#define _LIBCPP___ALGORITHM_MISMATCH_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <utility>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
|
||||
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
|
||||
for (; __first1 != __last1; ++__first1, (void)++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
break;
|
||||
return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
|
||||
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
|
||||
typedef typename iterator_traits<_InputIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_InputIterator2>::value_type __v2;
|
||||
return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
|
||||
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
|
||||
_BinaryPredicate __pred) {
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
break;
|
||||
return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
|
||||
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
|
||||
typedef typename iterator_traits<_InputIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_InputIterator2>::value_type __v2;
|
||||
return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_MISMATCH_H
|
||||
83
lib/libcxx/include/__algorithm/move.h
vendored
Normal file
83
lib/libcxx/include/__algorithm/move.h
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_MOVE_H
|
||||
#define _LIBCPP___ALGORITHM_MOVE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/unwrap_iter.h>
|
||||
#include <__utility/move.h>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// move
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
_OutputIterator
|
||||
__move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
*__result = _VSTD::move(*__first);
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
_OutputIterator
|
||||
__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
return _VSTD::__move_constexpr(__first, __last, __result);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
typename enable_if
|
||||
<
|
||||
is_same<typename remove_const<_Tp>::type, _Up>::value &&
|
||||
is_trivially_move_assignable<_Up>::value,
|
||||
_Up*
|
||||
>::type
|
||||
__move(_Tp* __first, _Tp* __last, _Up* __result)
|
||||
{
|
||||
const size_t __n = static_cast<size_t>(__last - __first);
|
||||
if (__n > 0)
|
||||
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
|
||||
return __result + __n;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
if (__libcpp_is_constant_evaluated()) {
|
||||
return _VSTD::__move_constexpr(__first, __last, __result);
|
||||
} else {
|
||||
return _VSTD::__rewrap_iter(__result,
|
||||
_VSTD::__move(_VSTD::__unwrap_iter(__first),
|
||||
_VSTD::__unwrap_iter(__last),
|
||||
_VSTD::__unwrap_iter(__result)));
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_MOVE_H
|
||||
84
lib/libcxx/include/__algorithm/move_backward.h
vendored
Normal file
84
lib/libcxx/include/__algorithm/move_backward.h
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
|
||||
#define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/unwrap_iter.h>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
_OutputIterator
|
||||
__move_backward_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
while (__first != __last)
|
||||
*--__result = _VSTD::move(*--__last);
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
_OutputIterator
|
||||
__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
return _VSTD::__move_backward_constexpr(__first, __last, __result);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
typename enable_if
|
||||
<
|
||||
is_same<typename remove_const<_Tp>::type, _Up>::value &&
|
||||
is_trivially_move_assignable<_Up>::value,
|
||||
_Up*
|
||||
>::type
|
||||
__move_backward(_Tp* __first, _Tp* __last, _Up* __result)
|
||||
{
|
||||
const size_t __n = static_cast<size_t>(__last - __first);
|
||||
if (__n > 0)
|
||||
{
|
||||
__result -= __n;
|
||||
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator1, class _BidirectionalIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_BidirectionalIterator2
|
||||
move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
|
||||
_BidirectionalIterator2 __result)
|
||||
{
|
||||
if (__libcpp_is_constant_evaluated()) {
|
||||
return _VSTD::__move_backward_constexpr(__first, __last, __result);
|
||||
} else {
|
||||
return _VSTD::__rewrap_iter(__result,
|
||||
_VSTD::__move_backward(_VSTD::__unwrap_iter(__first),
|
||||
_VSTD::__unwrap_iter(__last),
|
||||
_VSTD::__unwrap_iter(__result)));
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
|
||||
77
lib/libcxx/include/__algorithm/next_permutation.h
vendored
Normal file
77
lib/libcxx/include/__algorithm/next_permutation.h
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H
|
||||
#define _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/reverse.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/swap.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _BidirectionalIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
__next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
|
||||
{
|
||||
_BidirectionalIterator __i = __last;
|
||||
if (__first == __last || __first == --__i)
|
||||
return false;
|
||||
while (true)
|
||||
{
|
||||
_BidirectionalIterator __ip1 = __i;
|
||||
if (__comp(*--__i, *__ip1))
|
||||
{
|
||||
_BidirectionalIterator __j = __last;
|
||||
while (!__comp(*__i, *--__j))
|
||||
;
|
||||
swap(*__i, *__j);
|
||||
_VSTD::reverse(__ip1, __last);
|
||||
return true;
|
||||
}
|
||||
if (__i == __first)
|
||||
{
|
||||
_VSTD::reverse(__first, __last);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__next_permutation<_Comp_ref>(__first, __last, __comp);
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
|
||||
{
|
||||
return _VSTD::next_permutation(__first, __last,
|
||||
__less<typename iterator_traits<_BidirectionalIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H
|
||||
37
lib/libcxx/include/__algorithm/none_of.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/none_of.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_NONE_OF_H
|
||||
#define _LIBCPP___ALGORITHM_NONE_OF_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _Predicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
|
||||
for (; __first != __last; ++__first)
|
||||
if (__pred(*__first))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_NONE_OF_H
|
||||
244
lib/libcxx/include/__algorithm/nth_element.h
vendored
Normal file
244
lib/libcxx/include/__algorithm/nth_element.h
vendored
Normal file
@ -0,0 +1,244 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_NTH_ELEMENT_H
|
||||
#define _LIBCPP___ALGORITHM_NTH_ELEMENT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/sort.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/swap.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template<class _Compare, class _RandomAccessIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 bool
|
||||
__nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,
|
||||
_RandomAccessIterator __m, _Compare __comp)
|
||||
{
|
||||
// manually guard downward moving __j against __i
|
||||
while (true) {
|
||||
if (__i == --__j) {
|
||||
return false;
|
||||
}
|
||||
if (__comp(*__j, *__m)) {
|
||||
return true; // found guard for downward moving __j, now use unguarded partition
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 void
|
||||
__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
// _Compare is known to be a reference type
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
const difference_type __limit = 7;
|
||||
while (true)
|
||||
{
|
||||
if (__nth == __last)
|
||||
return;
|
||||
difference_type __len = __last - __first;
|
||||
switch (__len)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
return;
|
||||
case 2:
|
||||
if (__comp(*--__last, *__first))
|
||||
swap(*__first, *__last);
|
||||
return;
|
||||
case 3:
|
||||
{
|
||||
_RandomAccessIterator __m = __first;
|
||||
_VSTD::__sort3<_Compare>(__first, ++__m, --__last, __comp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (__len <= __limit)
|
||||
{
|
||||
_VSTD::__selection_sort<_Compare>(__first, __last, __comp);
|
||||
return;
|
||||
}
|
||||
// __len > __limit >= 3
|
||||
_RandomAccessIterator __m = __first + __len/2;
|
||||
_RandomAccessIterator __lm1 = __last;
|
||||
unsigned __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, --__lm1, __comp);
|
||||
// *__m is median
|
||||
// partition [__first, __m) < *__m and *__m <= [__m, __last)
|
||||
// (this inhibits tossing elements equivalent to __m around unnecessarily)
|
||||
_RandomAccessIterator __i = __first;
|
||||
_RandomAccessIterator __j = __lm1;
|
||||
// j points beyond range to be tested, *__lm1 is known to be <= *__m
|
||||
// The search going up is known to be guarded but the search coming down isn't.
|
||||
// Prime the downward search with a guard.
|
||||
if (!__comp(*__i, *__m)) // if *__first == *__m
|
||||
{
|
||||
// *__first == *__m, *__first doesn't go in first part
|
||||
if (_VSTD::__nth_element_find_guard<_Compare>(__i, __j, __m, __comp)) {
|
||||
swap(*__i, *__j);
|
||||
++__n_swaps;
|
||||
} else {
|
||||
// *__first == *__m, *__m <= all other elements
|
||||
// Partition instead into [__first, __i) == *__first and *__first < [__i, __last)
|
||||
++__i; // __first + 1
|
||||
__j = __last;
|
||||
if (!__comp(*__first, *--__j)) { // we need a guard if *__first == *(__last-1)
|
||||
while (true) {
|
||||
if (__i == __j) {
|
||||
return; // [__first, __last) all equivalent elements
|
||||
} else if (__comp(*__first, *__i)) {
|
||||
swap(*__i, *__j);
|
||||
++__n_swaps;
|
||||
++__i;
|
||||
break;
|
||||
}
|
||||
++__i;
|
||||
}
|
||||
}
|
||||
// [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
|
||||
if (__i == __j) {
|
||||
return;
|
||||
}
|
||||
while (true) {
|
||||
while (!__comp(*__first, *__i))
|
||||
++__i;
|
||||
while (__comp(*__first, *--__j))
|
||||
;
|
||||
if (__i >= __j)
|
||||
break;
|
||||
swap(*__i, *__j);
|
||||
++__n_swaps;
|
||||
++__i;
|
||||
}
|
||||
// [__first, __i) == *__first and *__first < [__i, __last)
|
||||
// The first part is sorted,
|
||||
if (__nth < __i) {
|
||||
return;
|
||||
}
|
||||
// __nth_element the second part
|
||||
// _VSTD::__nth_element<_Compare>(__i, __nth, __last, __comp);
|
||||
__first = __i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++__i;
|
||||
// j points beyond range to be tested, *__lm1 is known to be <= *__m
|
||||
// if not yet partitioned...
|
||||
if (__i < __j)
|
||||
{
|
||||
// known that *(__i - 1) < *__m
|
||||
while (true)
|
||||
{
|
||||
// __m still guards upward moving __i
|
||||
while (__comp(*__i, *__m))
|
||||
++__i;
|
||||
// It is now known that a guard exists for downward moving __j
|
||||
while (!__comp(*--__j, *__m))
|
||||
;
|
||||
if (__i >= __j)
|
||||
break;
|
||||
swap(*__i, *__j);
|
||||
++__n_swaps;
|
||||
// It is known that __m != __j
|
||||
// If __m just moved, follow it
|
||||
if (__m == __i)
|
||||
__m = __j;
|
||||
++__i;
|
||||
}
|
||||
}
|
||||
// [__first, __i) < *__m and *__m <= [__i, __last)
|
||||
if (__i != __m && __comp(*__m, *__i))
|
||||
{
|
||||
swap(*__i, *__m);
|
||||
++__n_swaps;
|
||||
}
|
||||
// [__first, __i) < *__i and *__i <= [__i+1, __last)
|
||||
if (__nth == __i)
|
||||
return;
|
||||
if (__n_swaps == 0)
|
||||
{
|
||||
// We were given a perfectly partitioned sequence. Coincidence?
|
||||
if (__nth < __i)
|
||||
{
|
||||
// Check for [__first, __i) already sorted
|
||||
__j = __m = __first;
|
||||
while (true) {
|
||||
if (++__j == __i) {
|
||||
// [__first, __i) sorted
|
||||
return;
|
||||
}
|
||||
if (__comp(*__j, *__m)) {
|
||||
// not yet sorted, so sort
|
||||
break;
|
||||
}
|
||||
__m = __j;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check for [__i, __last) already sorted
|
||||
__j = __m = __i;
|
||||
while (true) {
|
||||
if (++__j == __last) {
|
||||
// [__i, __last) sorted
|
||||
return;
|
||||
}
|
||||
if (__comp(*__j, *__m)) {
|
||||
// not yet sorted, so sort
|
||||
break;
|
||||
}
|
||||
__m = __j;
|
||||
}
|
||||
}
|
||||
}
|
||||
// __nth_element on range containing __nth
|
||||
if (__nth < __i)
|
||||
{
|
||||
// _VSTD::__nth_element<_Compare>(__first, __nth, __i, __comp);
|
||||
__last = __i;
|
||||
}
|
||||
else
|
||||
{
|
||||
// _VSTD::__nth_element<_Compare>(__i+1, __nth, __last, __comp);
|
||||
__first = ++__i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
_VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last)
|
||||
{
|
||||
_VSTD::nth_element(__first, __nth, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_NTH_ELEMENT_H
|
||||
71
lib/libcxx/include/__algorithm/partial_sort.h
vendored
Normal file
71
lib/libcxx/include/__algorithm/partial_sort.h
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_PARTIAL_SORT_H
|
||||
#define _LIBCPP___ALGORITHM_PARTIAL_SORT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/make_heap.h>
|
||||
#include <__algorithm/sift_down.h>
|
||||
#include <__algorithm/sort_heap.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/swap.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 void
|
||||
__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
|
||||
_Compare __comp)
|
||||
{
|
||||
_VSTD::__make_heap<_Compare>(__first, __middle, __comp);
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
|
||||
for (_RandomAccessIterator __i = __middle; __i != __last; ++__i)
|
||||
{
|
||||
if (__comp(*__i, *__first))
|
||||
{
|
||||
swap(*__i, *__first);
|
||||
_VSTD::__sift_down<_Compare>(__first, __middle, __comp, __len, __first);
|
||||
}
|
||||
}
|
||||
_VSTD::__sort_heap<_Compare>(__first, __middle, __comp);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
|
||||
_Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
_VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
|
||||
{
|
||||
_VSTD::partial_sort(__first, __middle, __last,
|
||||
__less<typename iterator_traits<_RandomAccessIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_H
|
||||
77
lib/libcxx/include/__algorithm/partial_sort_copy.h
vendored
Normal file
77
lib/libcxx/include/__algorithm/partial_sort_copy.h
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H
|
||||
#define _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/make_heap.h>
|
||||
#include <__algorithm/sift_down.h>
|
||||
#include <__algorithm/sort_heap.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <type_traits> // swap
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _InputIterator, class _RandomAccessIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
|
||||
__partial_sort_copy(_InputIterator __first, _InputIterator __last,
|
||||
_RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
|
||||
{
|
||||
_RandomAccessIterator __r = __result_first;
|
||||
if (__r != __result_last)
|
||||
{
|
||||
for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)
|
||||
*__r = *__first;
|
||||
_VSTD::__make_heap<_Compare>(__result_first, __r, __comp);
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
|
||||
for (; __first != __last; ++__first)
|
||||
if (__comp(*__first, *__result_first))
|
||||
{
|
||||
*__result_first = *__first;
|
||||
_VSTD::__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first);
|
||||
}
|
||||
_VSTD::__sort_heap<_Compare>(__result_first, __r, __comp);
|
||||
}
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _RandomAccessIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_RandomAccessIterator
|
||||
partial_sort_copy(_InputIterator __first, _InputIterator __last,
|
||||
_RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp);
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_RandomAccessIterator
|
||||
partial_sort_copy(_InputIterator __first, _InputIterator __last,
|
||||
_RandomAccessIterator __result_first, _RandomAccessIterator __result_last)
|
||||
{
|
||||
return _VSTD::partial_sort_copy(__first, __last, __result_first, __result_last,
|
||||
__less<typename iterator_traits<_RandomAccessIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H
|
||||
88
lib/libcxx/include/__algorithm/partition.h
vendored
Normal file
88
lib/libcxx/include/__algorithm/partition.h
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_PARTITION_H
|
||||
#define _LIBCPP___ALGORITHM_PARTITION_H
|
||||
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/swap.h>
|
||||
#include <utility> // pair
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Predicate, class _ForwardIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
__partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (__first == __last)
|
||||
return __first;
|
||||
if (!__pred(*__first))
|
||||
break;
|
||||
++__first;
|
||||
}
|
||||
for (_ForwardIterator __p = __first; ++__p != __last;)
|
||||
{
|
||||
if (__pred(*__p))
|
||||
{
|
||||
swap(*__first, *__p);
|
||||
++__first;
|
||||
}
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
template <class _Predicate, class _BidirectionalIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator
|
||||
__partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
|
||||
bidirectional_iterator_tag)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (__first == __last)
|
||||
return __first;
|
||||
if (!__pred(*__first))
|
||||
break;
|
||||
++__first;
|
||||
}
|
||||
do
|
||||
{
|
||||
if (__first == --__last)
|
||||
return __first;
|
||||
} while (!__pred(*__last));
|
||||
swap(*__first, *__last);
|
||||
++__first;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Predicate>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_ForwardIterator
|
||||
partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
|
||||
{
|
||||
return _VSTD::__partition<typename add_lvalue_reference<_Predicate>::type>
|
||||
(__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_PARTITION_H
|
||||
52
lib/libcxx/include/__algorithm/partition_copy.h
vendored
Normal file
52
lib/libcxx/include/__algorithm/partition_copy.h
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_PARTITION_COPY_H
|
||||
#define _LIBCPP___ALGORITHM_PARTITION_COPY_H
|
||||
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <utility> // pair
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _OutputIterator1,
|
||||
class _OutputIterator2, class _Predicate>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_OutputIterator1, _OutputIterator2>
|
||||
partition_copy(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator1 __out_true, _OutputIterator2 __out_false,
|
||||
_Predicate __pred)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
{
|
||||
if (__pred(*__first))
|
||||
{
|
||||
*__out_true = *__first;
|
||||
++__out_true;
|
||||
}
|
||||
else
|
||||
{
|
||||
*__out_false = *__first;
|
||||
++__out_false;
|
||||
}
|
||||
}
|
||||
return pair<_OutputIterator1, _OutputIterator2>(__out_true, __out_false);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_PARTITION_COPY_H
|
||||
51
lib/libcxx/include/__algorithm/partition_point.h
vendored
Normal file
51
lib/libcxx/include/__algorithm/partition_point.h
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_PARTITION_POINT_H
|
||||
#define _LIBCPP___ALGORITHM_PARTITION_POINT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/half_positive.h>
|
||||
#include <iterator>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template<class _ForwardIterator, class _Predicate>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
|
||||
difference_type __len = _VSTD::distance(__first, __last);
|
||||
while (__len != 0)
|
||||
{
|
||||
difference_type __l2 = _VSTD::__half_positive(__len);
|
||||
_ForwardIterator __m = __first;
|
||||
_VSTD::advance(__m, __l2);
|
||||
if (__pred(*__m))
|
||||
{
|
||||
__first = ++__m;
|
||||
__len -= __l2 + 1;
|
||||
}
|
||||
else
|
||||
__len = __l2;
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_PARTITION_POINT_H
|
||||
62
lib/libcxx/include/__algorithm/pop_heap.h
vendored
Normal file
62
lib/libcxx/include/__algorithm/pop_heap.h
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_POP_HEAP_H
|
||||
#define _LIBCPP___ALGORITHM_POP_HEAP_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/sift_down.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/swap.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len)
|
||||
{
|
||||
if (__len > 1)
|
||||
{
|
||||
swap(*__first, *--__last);
|
||||
_VSTD::__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
_VSTD::__pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
_VSTD::pop_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_POP_HEAP_H
|
||||
77
lib/libcxx/include/__algorithm/prev_permutation.h
vendored
Normal file
77
lib/libcxx/include/__algorithm/prev_permutation.h
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_PREV_PERMUTATION_H
|
||||
#define _LIBCPP___ALGORITHM_PREV_PERMUTATION_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/reverse.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/swap.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _BidirectionalIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
__prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
|
||||
{
|
||||
_BidirectionalIterator __i = __last;
|
||||
if (__first == __last || __first == --__i)
|
||||
return false;
|
||||
while (true)
|
||||
{
|
||||
_BidirectionalIterator __ip1 = __i;
|
||||
if (__comp(*__ip1, *--__i))
|
||||
{
|
||||
_BidirectionalIterator __j = __last;
|
||||
while (!__comp(*--__j, *__i))
|
||||
;
|
||||
swap(*__i, *__j);
|
||||
_VSTD::reverse(__ip1, __last);
|
||||
return true;
|
||||
}
|
||||
if (__i == __first)
|
||||
{
|
||||
_VSTD::reverse(__first, __last);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__prev_permutation<_Comp_ref>(__first, __last, __comp);
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
bool
|
||||
prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
|
||||
{
|
||||
return _VSTD::prev_permutation(__first, __last,
|
||||
__less<typename iterator_traits<_BidirectionalIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_PREV_PERMUTATION_H
|
||||
75
lib/libcxx/include/__algorithm/push_heap.h
vendored
Normal file
75
lib/libcxx/include/__algorithm/push_heap.h
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_PUSH_HEAP_H
|
||||
#define _LIBCPP___ALGORITHM_PUSH_HEAP_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/move.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 void
|
||||
__sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
if (__len > 1)
|
||||
{
|
||||
__len = (__len - 2) / 2;
|
||||
_RandomAccessIterator __ptr = __first + __len;
|
||||
if (__comp(*__ptr, *--__last))
|
||||
{
|
||||
value_type __t(_VSTD::move(*__last));
|
||||
do
|
||||
{
|
||||
*__last = _VSTD::move(*__ptr);
|
||||
__last = __ptr;
|
||||
if (__len == 0)
|
||||
break;
|
||||
__len = (__len - 1) / 2;
|
||||
__ptr = __first + __len;
|
||||
} while (__comp(*__ptr, __t));
|
||||
*__last = _VSTD::move(__t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
_VSTD::__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
_VSTD::push_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_PUSH_HEAP_H
|
||||
50
lib/libcxx/include/__algorithm/remove.h
vendored
Normal file
50
lib/libcxx/include/__algorithm/remove.h
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_REMOVE_H
|
||||
#define _LIBCPP___ALGORITHM_REMOVE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/find.h>
|
||||
#include <__algorithm/find_if.h>
|
||||
#include <__utility/move.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
|
||||
{
|
||||
__first = _VSTD::find(__first, __last, __value_);
|
||||
if (__first != __last)
|
||||
{
|
||||
_ForwardIterator __i = __first;
|
||||
while (++__i != __last)
|
||||
{
|
||||
if (!(*__i == __value_))
|
||||
{
|
||||
*__first = _VSTD::move(*__i);
|
||||
++__first;
|
||||
}
|
||||
}
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_REMOVE_H
|
||||
43
lib/libcxx/include/__algorithm/remove_copy.h
vendored
Normal file
43
lib/libcxx/include/__algorithm/remove_copy.h
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_REMOVE_COPY_H
|
||||
#define _LIBCPP___ALGORITHM_REMOVE_COPY_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
{
|
||||
if (!(*__first == __value_))
|
||||
{
|
||||
*__result = *__first;
|
||||
++__result;
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_REMOVE_COPY_H
|
||||
43
lib/libcxx/include/__algorithm/remove_copy_if.h
vendored
Normal file
43
lib/libcxx/include/__algorithm/remove_copy_if.h
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_REMOVE_COPY_IF_H
|
||||
#define _LIBCPP___ALGORITHM_REMOVE_COPY_IF_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Predicate>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
{
|
||||
if (!__pred(*__first))
|
||||
{
|
||||
*__result = *__first;
|
||||
++__result;
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_REMOVE_COPY_IF_H
|
||||
51
lib/libcxx/include/__algorithm/remove_if.h
vendored
Normal file
51
lib/libcxx/include/__algorithm/remove_if.h
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_REMOVE_IF_H
|
||||
#define _LIBCPP___ALGORITHM_REMOVE_IF_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/find_if.h>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _Predicate>
|
||||
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
|
||||
{
|
||||
__first = _VSTD::find_if<_ForwardIterator, typename add_lvalue_reference<_Predicate>::type>
|
||||
(__first, __last, __pred);
|
||||
if (__first != __last)
|
||||
{
|
||||
_ForwardIterator __i = __first;
|
||||
while (++__i != __last)
|
||||
{
|
||||
if (!__pred(*__i))
|
||||
{
|
||||
*__first = _VSTD::move(*__i);
|
||||
++__first;
|
||||
}
|
||||
}
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_REMOVE_IF_H
|
||||
37
lib/libcxx/include/__algorithm/replace.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/replace.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_REPLACE_H
|
||||
#define _LIBCPP___ALGORITHM_REPLACE_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
if (*__first == __old_value)
|
||||
*__first = __new_value;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_REPLACE_H
|
||||
41
lib/libcxx/include/__algorithm/replace_copy.h
vendored
Normal file
41
lib/libcxx/include/__algorithm/replace_copy.h
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_REPLACE_COPY_H
|
||||
#define _LIBCPP___ALGORITHM_REPLACE_COPY_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
|
||||
const _Tp& __old_value, const _Tp& __new_value)
|
||||
{
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
if (*__first == __old_value)
|
||||
*__result = __new_value;
|
||||
else
|
||||
*__result = *__first;
|
||||
return __result;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_REPLACE_COPY_H
|
||||
41
lib/libcxx/include/__algorithm/replace_copy_if.h
vendored
Normal file
41
lib/libcxx/include/__algorithm/replace_copy_if.h
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H
|
||||
#define _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
|
||||
_Predicate __pred, const _Tp& __new_value)
|
||||
{
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
if (__pred(*__first))
|
||||
*__result = __new_value;
|
||||
else
|
||||
*__result = *__first;
|
||||
return __result;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H
|
||||
37
lib/libcxx/include/__algorithm/replace_if.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/replace_if.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_REPLACE_IF_H
|
||||
#define _LIBCPP___ALGORITHM_REPLACE_IF_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _Predicate, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
if (__pred(*__first))
|
||||
*__first = __new_value;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_REPLACE_IF_H
|
||||
61
lib/libcxx/include/__algorithm/reverse.h
vendored
Normal file
61
lib/libcxx/include/__algorithm/reverse.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_REVERSE_H
|
||||
#define _LIBCPP___ALGORITHM_REVERSE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/iter_swap.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _BidirectionalIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
__reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
|
||||
{
|
||||
while (__first != __last)
|
||||
{
|
||||
if (__first == --__last)
|
||||
break;
|
||||
_VSTD::iter_swap(__first, __last);
|
||||
++__first;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
__reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
|
||||
{
|
||||
if (__first != __last)
|
||||
for (; __first < --__last; ++__first)
|
||||
_VSTD::iter_swap(__first, __last);
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
|
||||
{
|
||||
_VSTD::__reverse(__first, __last, typename iterator_traits<_BidirectionalIterator>::iterator_category());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_REVERSE_H
|
||||
37
lib/libcxx/include/__algorithm/reverse_copy.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/reverse_copy.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_REVERSE_COPY_H
|
||||
#define _LIBCPP___ALGORITHM_REVERSE_COPY_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _BidirectionalIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
|
||||
{
|
||||
for (; __first != __last; ++__result)
|
||||
*__result = *--__last;
|
||||
return __result;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_REVERSE_COPY_H
|
||||
205
lib/libcxx/include/__algorithm/rotate.h
vendored
Normal file
205
lib/libcxx/include/__algorithm/rotate.h
vendored
Normal file
@ -0,0 +1,205 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_ROTATE_H
|
||||
#define _LIBCPP___ALGORITHM_ROTATE_H
|
||||
|
||||
#include <__algorithm/move.h>
|
||||
#include <__algorithm/move_backward.h>
|
||||
#include <__algorithm/swap_ranges.h>
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__iterator/next.h>
|
||||
#include <__iterator/prev.h>
|
||||
#include <__utility/swap.h>
|
||||
#include <iterator>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
|
||||
__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
|
||||
value_type __tmp = _VSTD::move(*__first);
|
||||
_ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first);
|
||||
*__lm1 = _VSTD::move(__tmp);
|
||||
return __lm1;
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
|
||||
__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
|
||||
{
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
|
||||
_BidirectionalIterator __lm1 = _VSTD::prev(__last);
|
||||
value_type __tmp = _VSTD::move(*__lm1);
|
||||
_BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last);
|
||||
*__first = _VSTD::move(__tmp);
|
||||
return __fp1;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator
|
||||
__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
|
||||
{
|
||||
_ForwardIterator __i = __middle;
|
||||
while (true)
|
||||
{
|
||||
swap(*__first, *__i);
|
||||
++__first;
|
||||
if (++__i == __last)
|
||||
break;
|
||||
if (__first == __middle)
|
||||
__middle = __i;
|
||||
}
|
||||
_ForwardIterator __r = __first;
|
||||
if (__first != __middle)
|
||||
{
|
||||
__i = __middle;
|
||||
while (true)
|
||||
{
|
||||
swap(*__first, *__i);
|
||||
++__first;
|
||||
if (++__i == __last)
|
||||
{
|
||||
if (__first == __middle)
|
||||
break;
|
||||
__i = __middle;
|
||||
}
|
||||
else if (__first == __middle)
|
||||
__middle = __i;
|
||||
}
|
||||
}
|
||||
return __r;
|
||||
}
|
||||
|
||||
template<typename _Integral>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 _Integral
|
||||
__algo_gcd(_Integral __x, _Integral __y)
|
||||
{
|
||||
do
|
||||
{
|
||||
_Integral __t = __x % __y;
|
||||
__x = __y;
|
||||
__y = __t;
|
||||
} while (__y);
|
||||
return __x;
|
||||
}
|
||||
|
||||
template<typename _RandomAccessIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator
|
||||
__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
|
||||
const difference_type __m1 = __middle - __first;
|
||||
const difference_type __m2 = __last - __middle;
|
||||
if (__m1 == __m2)
|
||||
{
|
||||
_VSTD::swap_ranges(__first, __middle, __middle);
|
||||
return __middle;
|
||||
}
|
||||
const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);
|
||||
for (_RandomAccessIterator __p = __first + __g; __p != __first;)
|
||||
{
|
||||
value_type __t(_VSTD::move(*--__p));
|
||||
_RandomAccessIterator __p1 = __p;
|
||||
_RandomAccessIterator __p2 = __p1 + __m1;
|
||||
do
|
||||
{
|
||||
*__p1 = _VSTD::move(*__p2);
|
||||
__p1 = __p2;
|
||||
const difference_type __d = __last - __p2;
|
||||
if (__m1 < __d)
|
||||
__p2 += __m1;
|
||||
else
|
||||
__p2 = __first + (__m1 - __d);
|
||||
} while (__p2 != __p);
|
||||
*__p1 = _VSTD::move(__t);
|
||||
}
|
||||
return __first + __m2;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
|
||||
__rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
|
||||
_VSTD::forward_iterator_tag)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
|
||||
if (is_trivially_move_assignable<value_type>::value)
|
||||
{
|
||||
if (_VSTD::next(__first) == __middle)
|
||||
return _VSTD::__rotate_left(__first, __last);
|
||||
}
|
||||
return _VSTD::__rotate_forward(__first, __middle, __last);
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
|
||||
__rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
|
||||
bidirectional_iterator_tag)
|
||||
{
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
|
||||
if (is_trivially_move_assignable<value_type>::value)
|
||||
{
|
||||
if (_VSTD::next(__first) == __middle)
|
||||
return _VSTD::__rotate_left(__first, __last);
|
||||
if (_VSTD::next(__middle) == __last)
|
||||
return _VSTD::__rotate_right(__first, __last);
|
||||
}
|
||||
return _VSTD::__rotate_forward(__first, __middle, __last);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
|
||||
__rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
|
||||
random_access_iterator_tag)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
if (is_trivially_move_assignable<value_type>::value)
|
||||
{
|
||||
if (_VSTD::next(__first) == __middle)
|
||||
return _VSTD::__rotate_left(__first, __last);
|
||||
if (_VSTD::next(__middle) == __last)
|
||||
return _VSTD::__rotate_right(__first, __last);
|
||||
return _VSTD::__rotate_gcd(__first, __middle, __last);
|
||||
}
|
||||
return _VSTD::__rotate_forward(__first, __middle, __last);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
|
||||
{
|
||||
if (__first == __middle)
|
||||
return __last;
|
||||
if (__middle == __last)
|
||||
return __first;
|
||||
return _VSTD::__rotate(__first, __middle, __last,
|
||||
typename iterator_traits<_ForwardIterator>::iterator_category());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_ROTATE_H
|
||||
38
lib/libcxx/include/__algorithm/rotate_copy.h
vendored
Normal file
38
lib/libcxx/include/__algorithm/rotate_copy.h
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_ROTATE_COPY_H
|
||||
#define _LIBCPP___ALGORITHM_ROTATE_COPY_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/copy.h>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)
|
||||
{
|
||||
return _VSTD::copy(__first, __middle, _VSTD::copy(__middle, __last, __result));
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_ROTATE_COPY_H
|
||||
101
lib/libcxx/include/__algorithm/sample.h
vendored
Normal file
101
lib/libcxx/include/__algorithm/sample.h
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SAMPLE_H
|
||||
#define _LIBCPP___ALGORITHM_SAMPLE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/min.h>
|
||||
#include <__random/uniform_int_distribution.h>
|
||||
#include <iterator>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_SampleIterator __sample(_PopulationIterator __first,
|
||||
_PopulationIterator __last, _SampleIterator __output_iter,
|
||||
_Distance __n,
|
||||
_UniformRandomNumberGenerator & __g,
|
||||
input_iterator_tag) {
|
||||
|
||||
_Distance __k = 0;
|
||||
for (; __first != __last && __k < __n; ++__first, (void) ++__k)
|
||||
__output_iter[__k] = *__first;
|
||||
_Distance __sz = __k;
|
||||
for (; __first != __last; ++__first, (void) ++__k) {
|
||||
_Distance __r = uniform_int_distribution<_Distance>(0, __k)(__g);
|
||||
if (__r < __sz)
|
||||
__output_iter[__r] = *__first;
|
||||
}
|
||||
return __output_iter + _VSTD::min(__n, __k);
|
||||
}
|
||||
|
||||
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_SampleIterator __sample(_PopulationIterator __first,
|
||||
_PopulationIterator __last, _SampleIterator __output_iter,
|
||||
_Distance __n,
|
||||
_UniformRandomNumberGenerator& __g,
|
||||
forward_iterator_tag) {
|
||||
_Distance __unsampled_sz = _VSTD::distance(__first, __last);
|
||||
for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) {
|
||||
_Distance __r = uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
|
||||
if (__r < __n) {
|
||||
*__output_iter++ = *__first;
|
||||
--__n;
|
||||
}
|
||||
}
|
||||
return __output_iter;
|
||||
}
|
||||
|
||||
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_SampleIterator __sample(_PopulationIterator __first,
|
||||
_PopulationIterator __last, _SampleIterator __output_iter,
|
||||
_Distance __n, _UniformRandomNumberGenerator& __g) {
|
||||
typedef typename iterator_traits<_PopulationIterator>::iterator_category
|
||||
_PopCategory;
|
||||
typedef typename iterator_traits<_PopulationIterator>::difference_type
|
||||
_Difference;
|
||||
static_assert(__is_cpp17_forward_iterator<_PopulationIterator>::value ||
|
||||
__is_cpp17_random_access_iterator<_SampleIterator>::value,
|
||||
"SampleIterator must meet the requirements of RandomAccessIterator");
|
||||
typedef typename common_type<_Distance, _Difference>::type _CommonType;
|
||||
_LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
|
||||
return _VSTD::__sample(
|
||||
__first, __last, __output_iter, _CommonType(__n),
|
||||
__g, _PopCategory());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_SampleIterator sample(_PopulationIterator __first,
|
||||
_PopulationIterator __last, _SampleIterator __output_iter,
|
||||
_Distance __n, _UniformRandomNumberGenerator&& __g) {
|
||||
return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
|
||||
}
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SAMPLE_H
|
||||
131
lib/libcxx/include/__algorithm/search.h
vendored
Normal file
131
lib/libcxx/include/__algorithm/search.h
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_SEARCH_H
|
||||
#define _LIBCPP___ALGORITHM_SEARCH_H
|
||||
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
|
||||
pair<_ForwardIterator1, _ForwardIterator1>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
|
||||
_BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) {
|
||||
if (__first2 == __last2)
|
||||
return _VSTD::make_pair(__first1, __first1); // Everything matches an empty sequence
|
||||
while (true) {
|
||||
// Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks
|
||||
while (true) {
|
||||
if (__first1 == __last1) // return __last1 if no element matches *__first2
|
||||
return _VSTD::make_pair(__last1, __last1);
|
||||
if (__pred(*__first1, *__first2))
|
||||
break;
|
||||
++__first1;
|
||||
}
|
||||
// *__first1 matches *__first2, now match elements after here
|
||||
_ForwardIterator1 __m1 = __first1;
|
||||
_ForwardIterator2 __m2 = __first2;
|
||||
while (true) {
|
||||
if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern)
|
||||
return _VSTD::make_pair(__first1, __m1);
|
||||
if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found
|
||||
return _VSTD::make_pair(__last1, __last1);
|
||||
if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1
|
||||
{
|
||||
++__first1;
|
||||
break;
|
||||
} // else there is a match, check next elements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_RandomAccessIterator1, _RandomAccessIterator1>
|
||||
__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
|
||||
_RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag,
|
||||
random_access_iterator_tag) {
|
||||
typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;
|
||||
typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;
|
||||
// Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
|
||||
const _D2 __len2 = __last2 - __first2;
|
||||
if (__len2 == 0)
|
||||
return _VSTD::make_pair(__first1, __first1);
|
||||
const _D1 __len1 = __last1 - __first1;
|
||||
if (__len1 < __len2)
|
||||
return _VSTD::make_pair(__last1, __last1);
|
||||
const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here
|
||||
|
||||
while (true) {
|
||||
while (true) {
|
||||
if (__first1 == __s)
|
||||
return _VSTD::make_pair(__last1, __last1);
|
||||
if (__pred(*__first1, *__first2))
|
||||
break;
|
||||
++__first1;
|
||||
}
|
||||
|
||||
_RandomAccessIterator1 __m1 = __first1;
|
||||
_RandomAccessIterator2 __m2 = __first2;
|
||||
while (true) {
|
||||
if (++__m2 == __last2)
|
||||
return _VSTD::make_pair(__first1, __first1 + __len2);
|
||||
++__m1; // no need to check range on __m1 because __s guarantees we have enough source
|
||||
if (!__pred(*__m1, *__m2)) {
|
||||
++__first1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
|
||||
search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2,
|
||||
_BinaryPredicate __pred) {
|
||||
return _VSTD::__search<typename add_lvalue_reference<_BinaryPredicate>::type>(
|
||||
__first1, __last1, __first2, __last2, __pred,
|
||||
typename iterator_traits<_ForwardIterator1>::iterator_category(),
|
||||
typename iterator_traits<_ForwardIterator2>::iterator_category()).first;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
|
||||
search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
|
||||
typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
|
||||
return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _ForwardIterator, class _Searcher>
|
||||
_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) {
|
||||
return __s(__f, __l).first;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SEARCH_H
|
||||
116
lib/libcxx/include/__algorithm/search_n.h
vendored
Normal file
116
lib/libcxx/include/__algorithm/search_n.h
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
// -*- 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 _LIBCPP___ALGORITHM_SEARCH_N_H
|
||||
#define _LIBCPP___ALGORITHM_SEARCH_N_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _BinaryPredicate, class _ForwardIterator, class _Size, class _Tp>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __search_n(_ForwardIterator __first, _ForwardIterator __last,
|
||||
_Size __count, const _Tp& __value_, _BinaryPredicate __pred,
|
||||
forward_iterator_tag) {
|
||||
if (__count <= 0)
|
||||
return __first;
|
||||
while (true) {
|
||||
// Find first element in sequence that matchs __value_, with a mininum of loop checks
|
||||
while (true) {
|
||||
if (__first == __last) // return __last if no element matches __value_
|
||||
return __last;
|
||||
if (__pred(*__first, __value_))
|
||||
break;
|
||||
++__first;
|
||||
}
|
||||
// *__first matches __value_, now match elements after here
|
||||
_ForwardIterator __m = __first;
|
||||
_Size __c(0);
|
||||
while (true) {
|
||||
if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)
|
||||
return __first;
|
||||
if (++__m == __last) // Otherwise if source exhaused, pattern not found
|
||||
return __last;
|
||||
if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first
|
||||
{
|
||||
__first = __m;
|
||||
++__first;
|
||||
break;
|
||||
} // else there is a match, check next elements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _RandomAccessIterator, class _Size, class _Tp>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Size __count,
|
||||
const _Tp& __value_, _BinaryPredicate __pred,
|
||||
random_access_iterator_tag) {
|
||||
if (__count <= 0)
|
||||
return __first;
|
||||
_Size __len = static_cast<_Size>(__last - __first);
|
||||
if (__len < __count)
|
||||
return __last;
|
||||
const _RandomAccessIterator __s = __last - (__count - 1); // Start of pattern match can't go beyond here
|
||||
while (true) {
|
||||
// Find first element in sequence that matchs __value_, with a mininum of loop checks
|
||||
while (true) {
|
||||
if (__first >= __s) // return __last if no element matches __value_
|
||||
return __last;
|
||||
if (__pred(*__first, __value_))
|
||||
break;
|
||||
++__first;
|
||||
}
|
||||
// *__first matches __value_, now match elements after here
|
||||
_RandomAccessIterator __m = __first;
|
||||
_Size __c(0);
|
||||
while (true) {
|
||||
if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)
|
||||
return __first;
|
||||
++__m; // no need to check range on __m because __s guarantees we have enough source
|
||||
if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first
|
||||
{
|
||||
__first = __m;
|
||||
++__first;
|
||||
break;
|
||||
} // else there is a match, check next elements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator search_n(
|
||||
_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred) {
|
||||
return _VSTD::__search_n<typename add_lvalue_reference<_BinaryPredicate>::type>(
|
||||
__first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred,
|
||||
typename iterator_traits<_ForwardIterator>::iterator_category());
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Size, class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_) {
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type __v;
|
||||
return _VSTD::search_n(__first, __last, _VSTD::__convert_to_integral(__count), __value_, __equal_to<__v, _Tp>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SEARCH_N_H
|
||||
77
lib/libcxx/include/__algorithm/set_difference.h
vendored
Normal file
77
lib/libcxx/include/__algorithm/set_difference.h
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SET_DIFFERENCE_H
|
||||
#define _LIBCPP___ALGORITHM_SET_DIFFERENCE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/copy.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
|
||||
__set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
while (__first1 != __last1)
|
||||
{
|
||||
if (__first2 == __last2)
|
||||
return _VSTD::copy(__first1, __last1, __result);
|
||||
if (__comp(*__first1, *__first2))
|
||||
{
|
||||
*__result = *__first1;
|
||||
++__result;
|
||||
++__first1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!__comp(*__first2, *__first1))
|
||||
++__first1;
|
||||
++__first2;
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
|
||||
{
|
||||
return _VSTD::set_difference(__first1, __last1, __first2, __last2, __result,
|
||||
__less<typename iterator_traits<_InputIterator1>::value_type,
|
||||
typename iterator_traits<_InputIterator2>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SET_DIFFERENCE_H
|
||||
74
lib/libcxx/include/__algorithm/set_intersection.h
vendored
Normal file
74
lib/libcxx/include/__algorithm/set_intersection.h
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SET_INTERSECTION_H
|
||||
#define _LIBCPP___ALGORITHM_SET_INTERSECTION_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
|
||||
__set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
while (__first1 != __last1 && __first2 != __last2)
|
||||
{
|
||||
if (__comp(*__first1, *__first2))
|
||||
++__first1;
|
||||
else
|
||||
{
|
||||
if (!__comp(*__first2, *__first1))
|
||||
{
|
||||
*__result = *__first1;
|
||||
++__result;
|
||||
++__first1;
|
||||
}
|
||||
++__first2;
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
|
||||
{
|
||||
return _VSTD::set_intersection(__first1, __last1, __first2, __last2, __result,
|
||||
__less<typename iterator_traits<_InputIterator1>::value_type,
|
||||
typename iterator_traits<_InputIterator2>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SET_INTERSECTION_H
|
||||
82
lib/libcxx/include/__algorithm/set_symmetric_difference.h
vendored
Normal file
82
lib/libcxx/include/__algorithm/set_symmetric_difference.h
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H
|
||||
#define _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/copy.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
|
||||
__set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
while (__first1 != __last1)
|
||||
{
|
||||
if (__first2 == __last2)
|
||||
return _VSTD::copy(__first1, __last1, __result);
|
||||
if (__comp(*__first1, *__first2))
|
||||
{
|
||||
*__result = *__first1;
|
||||
++__result;
|
||||
++__first1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__comp(*__first2, *__first1))
|
||||
{
|
||||
*__result = *__first2;
|
||||
++__result;
|
||||
}
|
||||
else
|
||||
++__first1;
|
||||
++__first2;
|
||||
}
|
||||
}
|
||||
return _VSTD::copy(__first2, __last2, __result);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
|
||||
{
|
||||
return _VSTD::set_symmetric_difference(__first1, __last1, __first2, __last2, __result,
|
||||
__less<typename iterator_traits<_InputIterator1>::value_type,
|
||||
typename iterator_traits<_InputIterator2>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H
|
||||
77
lib/libcxx/include/__algorithm/set_union.h
vendored
Normal file
77
lib/libcxx/include/__algorithm/set_union.h
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SET_UNION_H
|
||||
#define _LIBCPP___ALGORITHM_SET_UNION_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/copy.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
|
||||
__set_union(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
for (; __first1 != __last1; ++__result)
|
||||
{
|
||||
if (__first2 == __last2)
|
||||
return _VSTD::copy(__first1, __last1, __result);
|
||||
if (__comp(*__first2, *__first1))
|
||||
{
|
||||
*__result = *__first2;
|
||||
++__first2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!__comp(*__first1, *__first2))
|
||||
++__first2;
|
||||
*__result = *__first1;
|
||||
++__first1;
|
||||
}
|
||||
}
|
||||
return _VSTD::copy(__first2, __last2, __result);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
set_union(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
set_union(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
|
||||
{
|
||||
return _VSTD::set_union(__first1, __last1, __first2, __last2, __result,
|
||||
__less<typename iterator_traits<_InputIterator1>::value_type,
|
||||
typename iterator_traits<_InputIterator2>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SET_UNION_H
|
||||
61
lib/libcxx/include/__algorithm/shift_left.h
vendored
Normal file
61
lib/libcxx/include/__algorithm/shift_left.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SHIFT_LEFT_H
|
||||
#define _LIBCPP___ALGORITHM_SHIFT_LEFT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/move.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <type_traits> // swap
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
|
||||
template <class _ForwardIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr
|
||||
_ForwardIterator
|
||||
shift_left(_ForwardIterator __first, _ForwardIterator __last,
|
||||
typename iterator_traits<_ForwardIterator>::difference_type __n)
|
||||
{
|
||||
if (__n == 0) {
|
||||
return __last;
|
||||
}
|
||||
|
||||
_ForwardIterator __m = __first;
|
||||
if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) {
|
||||
if (__n >= __last - __first) {
|
||||
return __first;
|
||||
}
|
||||
__m += __n;
|
||||
} else {
|
||||
for (; __n > 0; --__n) {
|
||||
if (__m == __last) {
|
||||
return __first;
|
||||
}
|
||||
++__m;
|
||||
}
|
||||
}
|
||||
return _VSTD::move(__m, __last, __first);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 17
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SHIFT_LEFT_H
|
||||
106
lib/libcxx/include/__algorithm/shift_right.h
vendored
Normal file
106
lib/libcxx/include/__algorithm/shift_right.h
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SHIFT_RIGHT_H
|
||||
#define _LIBCPP___ALGORITHM_SHIFT_RIGHT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/move.h>
|
||||
#include <__algorithm/move_backward.h>
|
||||
#include <__algorithm/swap_ranges.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <type_traits> // swap
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
|
||||
template <class _ForwardIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr
|
||||
_ForwardIterator
|
||||
shift_right(_ForwardIterator __first, _ForwardIterator __last,
|
||||
typename iterator_traits<_ForwardIterator>::difference_type __n)
|
||||
{
|
||||
if (__n == 0) {
|
||||
return __first;
|
||||
}
|
||||
|
||||
if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) {
|
||||
decltype(__n) __d = __last - __first;
|
||||
if (__n >= __d) {
|
||||
return __last;
|
||||
}
|
||||
_ForwardIterator __m = __first + (__d - __n);
|
||||
return _VSTD::move_backward(__first, __m, __last);
|
||||
} else if constexpr (__is_cpp17_bidirectional_iterator<_ForwardIterator>::value) {
|
||||
_ForwardIterator __m = __last;
|
||||
for (; __n > 0; --__n) {
|
||||
if (__m == __first) {
|
||||
return __last;
|
||||
}
|
||||
--__m;
|
||||
}
|
||||
return _VSTD::move_backward(__first, __m, __last);
|
||||
} else {
|
||||
_ForwardIterator __ret = __first;
|
||||
for (; __n > 0; --__n) {
|
||||
if (__ret == __last) {
|
||||
return __last;
|
||||
}
|
||||
++__ret;
|
||||
}
|
||||
|
||||
// We have an __n-element scratch space from __first to __ret.
|
||||
// Slide an __n-element window [__trail, __lead) from left to right.
|
||||
// We're essentially doing swap_ranges(__first, __ret, __trail, __lead)
|
||||
// over and over; but once __lead reaches __last we needn't bother
|
||||
// to save the values of elements [__trail, __last).
|
||||
|
||||
auto __trail = __first;
|
||||
auto __lead = __ret;
|
||||
while (__trail != __ret) {
|
||||
if (__lead == __last) {
|
||||
_VSTD::move(__first, __trail, __ret);
|
||||
return __ret;
|
||||
}
|
||||
++__trail;
|
||||
++__lead;
|
||||
}
|
||||
|
||||
_ForwardIterator __mid = __first;
|
||||
while (true) {
|
||||
if (__lead == __last) {
|
||||
__trail = _VSTD::move(__mid, __ret, __trail);
|
||||
_VSTD::move(__first, __mid, __trail);
|
||||
return __ret;
|
||||
}
|
||||
swap(*__mid, *__trail);
|
||||
++__mid;
|
||||
++__trail;
|
||||
++__lead;
|
||||
if (__mid == __ret) {
|
||||
__mid = __first;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 17
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SHIFT_RIGHT_H
|
||||
127
lib/libcxx/include/__algorithm/shuffle.h
vendored
Normal file
127
lib/libcxx/include/__algorithm/shuffle.h
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SHUFFLE_H
|
||||
#define _LIBCPP___ALGORITHM_SHUFFLE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__random/uniform_int_distribution.h>
|
||||
#include <__utility/swap.h>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
|
||||
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) \
|
||||
|| defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
class _LIBCPP_TYPE_VIS __rs_default;
|
||||
|
||||
_LIBCPP_FUNC_VIS __rs_default __rs_get();
|
||||
|
||||
class _LIBCPP_TYPE_VIS __rs_default
|
||||
{
|
||||
static unsigned __c_;
|
||||
|
||||
__rs_default();
|
||||
public:
|
||||
typedef uint_fast32_t result_type;
|
||||
|
||||
static const result_type _Min = 0;
|
||||
static const result_type _Max = 0xFFFFFFFF;
|
||||
|
||||
__rs_default(const __rs_default&);
|
||||
~__rs_default();
|
||||
|
||||
result_type operator()();
|
||||
|
||||
static _LIBCPP_CONSTEXPR result_type min() {return _Min;}
|
||||
static _LIBCPP_CONSTEXPR result_type max() {return _Max;}
|
||||
|
||||
friend _LIBCPP_FUNC_VIS __rs_default __rs_get();
|
||||
};
|
||||
|
||||
_LIBCPP_FUNC_VIS __rs_default __rs_get();
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
_LIBCPP_DEPRECATED_IN_CXX14 void
|
||||
random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
typedef uniform_int_distribution<ptrdiff_t> _Dp;
|
||||
typedef typename _Dp::param_type _Pp;
|
||||
difference_type __d = __last - __first;
|
||||
if (__d > 1)
|
||||
{
|
||||
_Dp __uid;
|
||||
__rs_default __g = __rs_get();
|
||||
for (--__last, (void) --__d; __first < __last; ++__first, (void) --__d)
|
||||
{
|
||||
difference_type __i = __uid(__g, _Pp(0, __d));
|
||||
if (__i != difference_type(0))
|
||||
swap(*__first, *(__first + __i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _RandomNumberGenerator>
|
||||
_LIBCPP_DEPRECATED_IN_CXX14 void
|
||||
random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_RandomNumberGenerator&& __rand)
|
||||
#else
|
||||
_RandomNumberGenerator& __rand)
|
||||
#endif
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
difference_type __d = __last - __first;
|
||||
if (__d > 1)
|
||||
{
|
||||
for (--__last; __first < __last; ++__first, (void) --__d)
|
||||
{
|
||||
difference_type __i = __rand(__d);
|
||||
if (__i != difference_type(0))
|
||||
swap(*__first, *(__first + __i));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
|
||||
void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_UniformRandomNumberGenerator&& __g)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
typedef uniform_int_distribution<ptrdiff_t> _Dp;
|
||||
typedef typename _Dp::param_type _Pp;
|
||||
difference_type __d = __last - __first;
|
||||
if (__d > 1)
|
||||
{
|
||||
_Dp __uid;
|
||||
for (--__last, (void) --__d; __first < __last; ++__first, (void) --__d)
|
||||
{
|
||||
difference_type __i = __uid(__g, _Pp(0, __d));
|
||||
if (__i != difference_type(0))
|
||||
swap(*__first, *(__first + __i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SHUFFLE_H
|
||||
84
lib/libcxx/include/__algorithm/sift_down.h
vendored
Normal file
84
lib/libcxx/include/__algorithm/sift_down.h
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SIFT_DOWN_H
|
||||
#define _LIBCPP___ALGORITHM_SIFT_DOWN_H
|
||||
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/move.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 void
|
||||
__sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/,
|
||||
_Compare __comp,
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
|
||||
_RandomAccessIterator __start)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
// left-child of __start is at 2 * __start + 1
|
||||
// right-child of __start is at 2 * __start + 2
|
||||
difference_type __child = __start - __first;
|
||||
|
||||
if (__len < 2 || (__len - 2) / 2 < __child)
|
||||
return;
|
||||
|
||||
__child = 2 * __child + 1;
|
||||
_RandomAccessIterator __child_i = __first + __child;
|
||||
|
||||
if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
|
||||
// right-child exists and is greater than left-child
|
||||
++__child_i;
|
||||
++__child;
|
||||
}
|
||||
|
||||
// check if we are in heap-order
|
||||
if (__comp(*__child_i, *__start))
|
||||
// we are, __start is larger than it's largest child
|
||||
return;
|
||||
|
||||
value_type __top(_VSTD::move(*__start));
|
||||
do
|
||||
{
|
||||
// we are not in heap-order, swap the parent with its largest child
|
||||
*__start = _VSTD::move(*__child_i);
|
||||
__start = __child_i;
|
||||
|
||||
if ((__len - 2) / 2 < __child)
|
||||
break;
|
||||
|
||||
// recompute the child based off of the updated parent
|
||||
__child = 2 * __child + 1;
|
||||
__child_i = __first + __child;
|
||||
|
||||
if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
|
||||
// right-child exists and is greater than left-child
|
||||
++__child_i;
|
||||
++__child;
|
||||
}
|
||||
|
||||
// check if we are in heap-order
|
||||
} while (!__comp(*__child_i, __top));
|
||||
*__start = _VSTD::move(__top);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SIFT_DOWN_H
|
||||
530
lib/libcxx/include/__algorithm/sort.h
vendored
Normal file
530
lib/libcxx/include/__algorithm/sort.h
vendored
Normal file
@ -0,0 +1,530 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SORT_H
|
||||
#define _LIBCPP___ALGORITHM_SORT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/min_element.h>
|
||||
#include <__algorithm/partial_sort.h>
|
||||
#include <__algorithm/unwrap_iter.h>
|
||||
#include <__utility/swap.h>
|
||||
#include <memory>
|
||||
#include <type_traits> // swap
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// stable, 2-3 compares, 0-2 swaps
|
||||
|
||||
template <class _Compare, class _ForwardIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned
|
||||
__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c)
|
||||
{
|
||||
unsigned __r = 0;
|
||||
if (!__c(*__y, *__x)) // if x <= y
|
||||
{
|
||||
if (!__c(*__z, *__y)) // if y <= z
|
||||
return __r; // x <= y && y <= z
|
||||
// x <= y && y > z
|
||||
swap(*__y, *__z); // x <= z && y < z
|
||||
__r = 1;
|
||||
if (__c(*__y, *__x)) // if x > y
|
||||
{
|
||||
swap(*__x, *__y); // x < y && y <= z
|
||||
__r = 2;
|
||||
}
|
||||
return __r; // x <= y && y < z
|
||||
}
|
||||
if (__c(*__z, *__y)) // x > y, if y > z
|
||||
{
|
||||
swap(*__x, *__z); // x < y && y < z
|
||||
__r = 1;
|
||||
return __r;
|
||||
}
|
||||
swap(*__x, *__y); // x > y && y <= z
|
||||
__r = 1; // x < y && x <= z
|
||||
if (__c(*__z, *__y)) // if y > z
|
||||
{
|
||||
swap(*__y, *__z); // x <= y && y < z
|
||||
__r = 2;
|
||||
}
|
||||
return __r;
|
||||
} // x <= y && y <= z
|
||||
|
||||
// stable, 3-6 compares, 0-5 swaps
|
||||
|
||||
template <class _Compare, class _ForwardIterator>
|
||||
unsigned
|
||||
__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
|
||||
_ForwardIterator __x4, _Compare __c)
|
||||
{
|
||||
unsigned __r = _VSTD::__sort3<_Compare>(__x1, __x2, __x3, __c);
|
||||
if (__c(*__x4, *__x3))
|
||||
{
|
||||
swap(*__x3, *__x4);
|
||||
++__r;
|
||||
if (__c(*__x3, *__x2))
|
||||
{
|
||||
swap(*__x2, *__x3);
|
||||
++__r;
|
||||
if (__c(*__x2, *__x1))
|
||||
{
|
||||
swap(*__x1, *__x2);
|
||||
++__r;
|
||||
}
|
||||
}
|
||||
}
|
||||
return __r;
|
||||
}
|
||||
|
||||
// stable, 4-10 compares, 0-9 swaps
|
||||
|
||||
template <class _Compare, class _ForwardIterator>
|
||||
_LIBCPP_HIDDEN
|
||||
unsigned
|
||||
__sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
|
||||
_ForwardIterator __x4, _ForwardIterator __x5, _Compare __c)
|
||||
{
|
||||
unsigned __r = _VSTD::__sort4<_Compare>(__x1, __x2, __x3, __x4, __c);
|
||||
if (__c(*__x5, *__x4))
|
||||
{
|
||||
swap(*__x4, *__x5);
|
||||
++__r;
|
||||
if (__c(*__x4, *__x3))
|
||||
{
|
||||
swap(*__x3, *__x4);
|
||||
++__r;
|
||||
if (__c(*__x3, *__x2))
|
||||
{
|
||||
swap(*__x2, *__x3);
|
||||
++__r;
|
||||
if (__c(*__x2, *__x1))
|
||||
{
|
||||
swap(*__x1, *__x2);
|
||||
++__r;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return __r;
|
||||
}
|
||||
|
||||
// Assumes size > 0
|
||||
template <class _Compare, class _BidirectionalIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 void
|
||||
__selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
|
||||
{
|
||||
_BidirectionalIterator __lm1 = __last;
|
||||
for (--__lm1; __first != __lm1; ++__first)
|
||||
{
|
||||
_BidirectionalIterator __i = _VSTD::min_element<_BidirectionalIterator,
|
||||
typename add_lvalue_reference<_Compare>::type>
|
||||
(__first, __last, __comp);
|
||||
if (__i != __first)
|
||||
swap(*__first, *__i);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Compare, class _BidirectionalIterator>
|
||||
void
|
||||
__insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
|
||||
if (__first != __last)
|
||||
{
|
||||
_BidirectionalIterator __i = __first;
|
||||
for (++__i; __i != __last; ++__i)
|
||||
{
|
||||
_BidirectionalIterator __j = __i;
|
||||
value_type __t(_VSTD::move(*__j));
|
||||
for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)
|
||||
*__j = _VSTD::move(*__k);
|
||||
*__j = _VSTD::move(__t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
void
|
||||
__insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
_RandomAccessIterator __j = __first+2;
|
||||
_VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
|
||||
for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
|
||||
{
|
||||
if (__comp(*__i, *__j))
|
||||
{
|
||||
value_type __t(_VSTD::move(*__i));
|
||||
_RandomAccessIterator __k = __j;
|
||||
__j = __i;
|
||||
do
|
||||
{
|
||||
*__j = _VSTD::move(*__k);
|
||||
__j = __k;
|
||||
} while (__j != __first && __comp(__t, *--__k));
|
||||
*__j = _VSTD::move(__t);
|
||||
}
|
||||
__j = __i;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
bool
|
||||
__insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
switch (__last - __first)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
return true;
|
||||
case 2:
|
||||
if (__comp(*--__last, *__first))
|
||||
swap(*__first, *__last);
|
||||
return true;
|
||||
case 3:
|
||||
_VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp);
|
||||
return true;
|
||||
case 4:
|
||||
_VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp);
|
||||
return true;
|
||||
case 5:
|
||||
_VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);
|
||||
return true;
|
||||
}
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
_RandomAccessIterator __j = __first+2;
|
||||
_VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
|
||||
const unsigned __limit = 8;
|
||||
unsigned __count = 0;
|
||||
for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
|
||||
{
|
||||
if (__comp(*__i, *__j))
|
||||
{
|
||||
value_type __t(_VSTD::move(*__i));
|
||||
_RandomAccessIterator __k = __j;
|
||||
__j = __i;
|
||||
do
|
||||
{
|
||||
*__j = _VSTD::move(*__k);
|
||||
__j = __k;
|
||||
} while (__j != __first && __comp(__t, *--__k));
|
||||
*__j = _VSTD::move(__t);
|
||||
if (++__count == __limit)
|
||||
return ++__i == __last;
|
||||
}
|
||||
__j = __i;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Compare, class _BidirectionalIterator>
|
||||
void
|
||||
__insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,
|
||||
typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
|
||||
if (__first1 != __last1)
|
||||
{
|
||||
__destruct_n __d(0);
|
||||
unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
|
||||
value_type* __last2 = __first2;
|
||||
::new ((void*)__last2) value_type(_VSTD::move(*__first1));
|
||||
__d.template __incr<value_type>();
|
||||
for (++__last2; ++__first1 != __last1; ++__last2)
|
||||
{
|
||||
value_type* __j2 = __last2;
|
||||
value_type* __i2 = __j2;
|
||||
if (__comp(*__first1, *--__i2))
|
||||
{
|
||||
::new ((void*)__j2) value_type(_VSTD::move(*__i2));
|
||||
__d.template __incr<value_type>();
|
||||
for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
|
||||
*__j2 = _VSTD::move(*__i2);
|
||||
*__j2 = _VSTD::move(*__first1);
|
||||
}
|
||||
else
|
||||
{
|
||||
::new ((void*)__j2) value_type(_VSTD::move(*__first1));
|
||||
__d.template __incr<value_type>();
|
||||
}
|
||||
}
|
||||
__h.release();
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
void
|
||||
__sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
const difference_type __limit = is_trivially_copy_constructible<value_type>::value &&
|
||||
is_trivially_copy_assignable<value_type>::value ? 30 : 6;
|
||||
while (true)
|
||||
{
|
||||
__restart:
|
||||
difference_type __len = __last - __first;
|
||||
switch (__len)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
return;
|
||||
case 2:
|
||||
if (__comp(*--__last, *__first))
|
||||
swap(*__first, *__last);
|
||||
return;
|
||||
case 3:
|
||||
_VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp);
|
||||
return;
|
||||
case 4:
|
||||
_VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp);
|
||||
return;
|
||||
case 5:
|
||||
_VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);
|
||||
return;
|
||||
}
|
||||
if (__len <= __limit)
|
||||
{
|
||||
_VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp);
|
||||
return;
|
||||
}
|
||||
// __len > 5
|
||||
_RandomAccessIterator __m = __first;
|
||||
_RandomAccessIterator __lm1 = __last;
|
||||
--__lm1;
|
||||
unsigned __n_swaps;
|
||||
{
|
||||
difference_type __delta;
|
||||
if (__len >= 1000)
|
||||
{
|
||||
__delta = __len/2;
|
||||
__m += __delta;
|
||||
__delta /= 2;
|
||||
__n_swaps = _VSTD::__sort5<_Compare>(__first, __first + __delta, __m, __m+__delta, __lm1, __comp);
|
||||
}
|
||||
else
|
||||
{
|
||||
__delta = __len/2;
|
||||
__m += __delta;
|
||||
__n_swaps = _VSTD::__sort3<_Compare>(__first, __m, __lm1, __comp);
|
||||
}
|
||||
}
|
||||
// *__m is median
|
||||
// partition [__first, __m) < *__m and *__m <= [__m, __last)
|
||||
// (this inhibits tossing elements equivalent to __m around unnecessarily)
|
||||
_RandomAccessIterator __i = __first;
|
||||
_RandomAccessIterator __j = __lm1;
|
||||
// j points beyond range to be tested, *__m is known to be <= *__lm1
|
||||
// The search going up is known to be guarded but the search coming down isn't.
|
||||
// Prime the downward search with a guard.
|
||||
if (!__comp(*__i, *__m)) // if *__first == *__m
|
||||
{
|
||||
// *__first == *__m, *__first doesn't go in first part
|
||||
// manually guard downward moving __j against __i
|
||||
while (true)
|
||||
{
|
||||
if (__i == --__j)
|
||||
{
|
||||
// *__first == *__m, *__m <= all other elements
|
||||
// Parition instead into [__first, __i) == *__first and *__first < [__i, __last)
|
||||
++__i; // __first + 1
|
||||
__j = __last;
|
||||
if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (__i == __j)
|
||||
return; // [__first, __last) all equivalent elements
|
||||
if (__comp(*__first, *__i))
|
||||
{
|
||||
swap(*__i, *__j);
|
||||
++__n_swaps;
|
||||
++__i;
|
||||
break;
|
||||
}
|
||||
++__i;
|
||||
}
|
||||
}
|
||||
// [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
|
||||
if (__i == __j)
|
||||
return;
|
||||
while (true)
|
||||
{
|
||||
while (!__comp(*__first, *__i))
|
||||
++__i;
|
||||
while (__comp(*__first, *--__j))
|
||||
;
|
||||
if (__i >= __j)
|
||||
break;
|
||||
swap(*__i, *__j);
|
||||
++__n_swaps;
|
||||
++__i;
|
||||
}
|
||||
// [__first, __i) == *__first and *__first < [__i, __last)
|
||||
// The first part is sorted, sort the second part
|
||||
// _VSTD::__sort<_Compare>(__i, __last, __comp);
|
||||
__first = __i;
|
||||
goto __restart;
|
||||
}
|
||||
if (__comp(*__j, *__m))
|
||||
{
|
||||
swap(*__i, *__j);
|
||||
++__n_swaps;
|
||||
break; // found guard for downward moving __j, now use unguarded partition
|
||||
}
|
||||
}
|
||||
}
|
||||
// It is known that *__i < *__m
|
||||
++__i;
|
||||
// j points beyond range to be tested, *__m is known to be <= *__lm1
|
||||
// if not yet partitioned...
|
||||
if (__i < __j)
|
||||
{
|
||||
// known that *(__i - 1) < *__m
|
||||
// known that __i <= __m
|
||||
while (true)
|
||||
{
|
||||
// __m still guards upward moving __i
|
||||
while (__comp(*__i, *__m))
|
||||
++__i;
|
||||
// It is now known that a guard exists for downward moving __j
|
||||
while (!__comp(*--__j, *__m))
|
||||
;
|
||||
if (__i > __j)
|
||||
break;
|
||||
swap(*__i, *__j);
|
||||
++__n_swaps;
|
||||
// It is known that __m != __j
|
||||
// If __m just moved, follow it
|
||||
if (__m == __i)
|
||||
__m = __j;
|
||||
++__i;
|
||||
}
|
||||
}
|
||||
// [__first, __i) < *__m and *__m <= [__i, __last)
|
||||
if (__i != __m && __comp(*__m, *__i))
|
||||
{
|
||||
swap(*__i, *__m);
|
||||
++__n_swaps;
|
||||
}
|
||||
// [__first, __i) < *__i and *__i <= [__i+1, __last)
|
||||
// If we were given a perfect partition, see if insertion sort is quick...
|
||||
if (__n_swaps == 0)
|
||||
{
|
||||
bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp);
|
||||
if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+1, __last, __comp))
|
||||
{
|
||||
if (__fs)
|
||||
return;
|
||||
__last = __i;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__fs)
|
||||
{
|
||||
__first = ++__i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// sort smaller range with recursive call and larger with tail recursion elimination
|
||||
if (__i - __first < __last - __i)
|
||||
{
|
||||
_VSTD::__sort<_Compare>(__first, __i, __comp);
|
||||
// _VSTD::__sort<_Compare>(__i+1, __last, __comp);
|
||||
__first = ++__i;
|
||||
}
|
||||
else
|
||||
{
|
||||
_VSTD::__sort<_Compare>(__i+1, __last, __comp);
|
||||
// _VSTD::__sort<_Compare>(__first, __i, __comp);
|
||||
__last = __i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Compare, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
__sort(_Tp** __first, _Tp** __last, __less<_Tp*>&)
|
||||
{
|
||||
__less<uintptr_t> __comp;
|
||||
_VSTD::__sort<__less<uintptr_t>&, uintptr_t*>((uintptr_t*)__first, (uintptr_t*)__last, __comp);
|
||||
}
|
||||
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))
|
||||
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&))
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))
|
||||
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&))
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
if (__libcpp_is_constant_evaluated()) {
|
||||
_VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp));
|
||||
} else {
|
||||
_VSTD::__sort<_Comp_ref>(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _Comp_ref(__comp));
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
_VSTD::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SORT_H
|
||||
58
lib/libcxx/include/__algorithm/sort_heap.h
vendored
Normal file
58
lib/libcxx/include/__algorithm/sort_heap.h
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SORT_HEAP_H
|
||||
#define _LIBCPP___ALGORITHM_SORT_HEAP_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/pop_heap.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <type_traits> // swap
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 void
|
||||
__sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
|
||||
_VSTD::__pop_heap<_Compare>(__first, __last, __comp, __n);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
_VSTD::__sort_heap<_Comp_ref>(__first, __last, __comp);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
void
|
||||
sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
_VSTD::sort_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SORT_HEAP_H
|
||||
305
lib/libcxx/include/__algorithm/stable_partition.h
vendored
Normal file
305
lib/libcxx/include/__algorithm/stable_partition.h
vendored
Normal file
@ -0,0 +1,305 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_STABLE_PARTITION_H
|
||||
#define _LIBCPP___ALGORITHM_STABLE_PARTITION_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/rotate.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/swap.h>
|
||||
#include <memory>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Predicate, class _ForwardIterator, class _Distance, class _Pair>
|
||||
_ForwardIterator
|
||||
__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
|
||||
_Distance __len, _Pair __p, forward_iterator_tag __fit)
|
||||
{
|
||||
// *__first is known to be false
|
||||
// __len >= 1
|
||||
if (__len == 1)
|
||||
return __first;
|
||||
if (__len == 2)
|
||||
{
|
||||
_ForwardIterator __m = __first;
|
||||
if (__pred(*++__m))
|
||||
{
|
||||
swap(*__first, *__m);
|
||||
return __m;
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
if (__len <= __p.second)
|
||||
{ // The buffer is big enough to use
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
|
||||
__destruct_n __d(0);
|
||||
unique_ptr<value_type, __destruct_n&> __h(__p.first, __d);
|
||||
// Move the falses into the temporary buffer, and the trues to the front of the line
|
||||
// Update __first to always point to the end of the trues
|
||||
value_type* __t = __p.first;
|
||||
::new ((void*)__t) value_type(_VSTD::move(*__first));
|
||||
__d.template __incr<value_type>();
|
||||
++__t;
|
||||
_ForwardIterator __i = __first;
|
||||
while (++__i != __last)
|
||||
{
|
||||
if (__pred(*__i))
|
||||
{
|
||||
*__first = _VSTD::move(*__i);
|
||||
++__first;
|
||||
}
|
||||
else
|
||||
{
|
||||
::new ((void*)__t) value_type(_VSTD::move(*__i));
|
||||
__d.template __incr<value_type>();
|
||||
++__t;
|
||||
}
|
||||
}
|
||||
// All trues now at start of range, all falses in buffer
|
||||
// Move falses back into range, but don't mess up __first which points to first false
|
||||
__i = __first;
|
||||
for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
|
||||
*__i = _VSTD::move(*__t2);
|
||||
// __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
|
||||
return __first;
|
||||
}
|
||||
// Else not enough buffer, do in place
|
||||
// __len >= 3
|
||||
_ForwardIterator __m = __first;
|
||||
_Distance __len2 = __len / 2; // __len2 >= 2
|
||||
_VSTD::advance(__m, __len2);
|
||||
// recurse on [__first, __m), *__first know to be false
|
||||
// F?????????????????
|
||||
// f m l
|
||||
typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
|
||||
_ForwardIterator __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit);
|
||||
// TTTFFFFF??????????
|
||||
// f ff m l
|
||||
// recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
|
||||
_ForwardIterator __m1 = __m;
|
||||
_ForwardIterator __second_false = __last;
|
||||
_Distance __len_half = __len - __len2;
|
||||
while (__pred(*__m1))
|
||||
{
|
||||
if (++__m1 == __last)
|
||||
goto __second_half_done;
|
||||
--__len_half;
|
||||
}
|
||||
// TTTFFFFFTTTF??????
|
||||
// f ff m m1 l
|
||||
__second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit);
|
||||
__second_half_done:
|
||||
// TTTFFFFFTTTTTFFFFF
|
||||
// f ff m sf l
|
||||
return _VSTD::rotate(__first_false, __m, __second_false);
|
||||
// TTTTTTTTFFFFFFFFFF
|
||||
// |
|
||||
}
|
||||
|
||||
template <class _Predicate, class _ForwardIterator>
|
||||
_ForwardIterator
|
||||
__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
|
||||
forward_iterator_tag)
|
||||
{
|
||||
const unsigned __alloc_limit = 3; // might want to make this a function of trivial assignment
|
||||
// Either prove all true and return __first or point to first false
|
||||
while (true)
|
||||
{
|
||||
if (__first == __last)
|
||||
return __first;
|
||||
if (!__pred(*__first))
|
||||
break;
|
||||
++__first;
|
||||
}
|
||||
// We now have a reduced range [__first, __last)
|
||||
// *__first is known to be false
|
||||
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
|
||||
difference_type __len = _VSTD::distance(__first, __last);
|
||||
pair<value_type*, ptrdiff_t> __p(0, 0);
|
||||
unique_ptr<value_type, __return_temporary_buffer> __h;
|
||||
if (__len >= __alloc_limit)
|
||||
{
|
||||
__p = _VSTD::get_temporary_buffer<value_type>(__len);
|
||||
__h.reset(__p.first);
|
||||
}
|
||||
return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
|
||||
(__first, __last, __pred, __len, __p, forward_iterator_tag());
|
||||
}
|
||||
|
||||
template <class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair>
|
||||
_BidirectionalIterator
|
||||
__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
|
||||
_Distance __len, _Pair __p, bidirectional_iterator_tag __bit)
|
||||
{
|
||||
// *__first is known to be false
|
||||
// *__last is known to be true
|
||||
// __len >= 2
|
||||
if (__len == 2)
|
||||
{
|
||||
swap(*__first, *__last);
|
||||
return __last;
|
||||
}
|
||||
if (__len == 3)
|
||||
{
|
||||
_BidirectionalIterator __m = __first;
|
||||
if (__pred(*++__m))
|
||||
{
|
||||
swap(*__first, *__m);
|
||||
swap(*__m, *__last);
|
||||
return __last;
|
||||
}
|
||||
swap(*__m, *__last);
|
||||
swap(*__first, *__m);
|
||||
return __m;
|
||||
}
|
||||
if (__len <= __p.second)
|
||||
{ // The buffer is big enough to use
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
|
||||
__destruct_n __d(0);
|
||||
unique_ptr<value_type, __destruct_n&> __h(__p.first, __d);
|
||||
// Move the falses into the temporary buffer, and the trues to the front of the line
|
||||
// Update __first to always point to the end of the trues
|
||||
value_type* __t = __p.first;
|
||||
::new ((void*)__t) value_type(_VSTD::move(*__first));
|
||||
__d.template __incr<value_type>();
|
||||
++__t;
|
||||
_BidirectionalIterator __i = __first;
|
||||
while (++__i != __last)
|
||||
{
|
||||
if (__pred(*__i))
|
||||
{
|
||||
*__first = _VSTD::move(*__i);
|
||||
++__first;
|
||||
}
|
||||
else
|
||||
{
|
||||
::new ((void*)__t) value_type(_VSTD::move(*__i));
|
||||
__d.template __incr<value_type>();
|
||||
++__t;
|
||||
}
|
||||
}
|
||||
// move *__last, known to be true
|
||||
*__first = _VSTD::move(*__i);
|
||||
__i = ++__first;
|
||||
// All trues now at start of range, all falses in buffer
|
||||
// Move falses back into range, but don't mess up __first which points to first false
|
||||
for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
|
||||
*__i = _VSTD::move(*__t2);
|
||||
// __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
|
||||
return __first;
|
||||
}
|
||||
// Else not enough buffer, do in place
|
||||
// __len >= 4
|
||||
_BidirectionalIterator __m = __first;
|
||||
_Distance __len2 = __len / 2; // __len2 >= 2
|
||||
_VSTD::advance(__m, __len2);
|
||||
// recurse on [__first, __m-1], except reduce __m-1 until *(__m-1) is true, *__first know to be false
|
||||
// F????????????????T
|
||||
// f m l
|
||||
_BidirectionalIterator __m1 = __m;
|
||||
_BidirectionalIterator __first_false = __first;
|
||||
_Distance __len_half = __len2;
|
||||
while (!__pred(*--__m1))
|
||||
{
|
||||
if (__m1 == __first)
|
||||
goto __first_half_done;
|
||||
--__len_half;
|
||||
}
|
||||
// F???TFFF?????????T
|
||||
// f m1 m l
|
||||
typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
|
||||
__first_false = _VSTD::__stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit);
|
||||
__first_half_done:
|
||||
// TTTFFFFF?????????T
|
||||
// f ff m l
|
||||
// recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
|
||||
__m1 = __m;
|
||||
_BidirectionalIterator __second_false = __last;
|
||||
++__second_false;
|
||||
__len_half = __len - __len2;
|
||||
while (__pred(*__m1))
|
||||
{
|
||||
if (++__m1 == __last)
|
||||
goto __second_half_done;
|
||||
--__len_half;
|
||||
}
|
||||
// TTTFFFFFTTTF?????T
|
||||
// f ff m m1 l
|
||||
__second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit);
|
||||
__second_half_done:
|
||||
// TTTFFFFFTTTTTFFFFF
|
||||
// f ff m sf l
|
||||
return _VSTD::rotate(__first_false, __m, __second_false);
|
||||
// TTTTTTTTFFFFFFFFFF
|
||||
// |
|
||||
}
|
||||
|
||||
template <class _Predicate, class _BidirectionalIterator>
|
||||
_BidirectionalIterator
|
||||
__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
|
||||
bidirectional_iterator_tag)
|
||||
{
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
|
||||
const difference_type __alloc_limit = 4; // might want to make this a function of trivial assignment
|
||||
// Either prove all true and return __first or point to first false
|
||||
while (true)
|
||||
{
|
||||
if (__first == __last)
|
||||
return __first;
|
||||
if (!__pred(*__first))
|
||||
break;
|
||||
++__first;
|
||||
}
|
||||
// __first points to first false, everything prior to __first is already set.
|
||||
// Either prove [__first, __last) is all false and return __first, or point __last to last true
|
||||
do
|
||||
{
|
||||
if (__first == --__last)
|
||||
return __first;
|
||||
} while (!__pred(*__last));
|
||||
// We now have a reduced range [__first, __last]
|
||||
// *__first is known to be false
|
||||
// *__last is known to be true
|
||||
// __len >= 2
|
||||
difference_type __len = _VSTD::distance(__first, __last) + 1;
|
||||
pair<value_type*, ptrdiff_t> __p(0, 0);
|
||||
unique_ptr<value_type, __return_temporary_buffer> __h;
|
||||
if (__len >= __alloc_limit)
|
||||
{
|
||||
__p = _VSTD::get_temporary_buffer<value_type>(__len);
|
||||
__h.reset(__p.first);
|
||||
}
|
||||
return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
|
||||
(__first, __last, __pred, __len, __p, bidirectional_iterator_tag());
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Predicate>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator
|
||||
stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
|
||||
{
|
||||
return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
|
||||
(__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_STABLE_PARTITION_H
|
||||
235
lib/libcxx/include/__algorithm/stable_sort.h
vendored
Normal file
235
lib/libcxx/include/__algorithm/stable_sort.h
vendored
Normal file
@ -0,0 +1,235 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_STABLE_SORT_H
|
||||
#define _LIBCPP___ALGORITHM_STABLE_SORT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/comp_ref_type.h>
|
||||
#include <__algorithm/inplace_merge.h>
|
||||
#include <__algorithm/sort.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/swap.h>
|
||||
#include <memory>
|
||||
#include <type_traits> // swap
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _InputIterator1, class _InputIterator2>
|
||||
void
|
||||
__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2,
|
||||
typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIterator1>::value_type value_type;
|
||||
__destruct_n __d(0);
|
||||
unique_ptr<value_type, __destruct_n&> __h(__result, __d);
|
||||
for (; true; ++__result)
|
||||
{
|
||||
if (__first1 == __last1)
|
||||
{
|
||||
for (; __first2 != __last2; ++__first2, ++__result, (void)__d.template __incr<value_type>())
|
||||
::new ((void*)__result) value_type(_VSTD::move(*__first2));
|
||||
__h.release();
|
||||
return;
|
||||
}
|
||||
if (__first2 == __last2)
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1, ++__result, (void)__d.template __incr<value_type>())
|
||||
::new ((void*)__result) value_type(_VSTD::move(*__first1));
|
||||
__h.release();
|
||||
return;
|
||||
}
|
||||
if (__comp(*__first2, *__first1))
|
||||
{
|
||||
::new ((void*)__result) value_type(_VSTD::move(*__first2));
|
||||
__d.template __incr<value_type>();
|
||||
++__first2;
|
||||
}
|
||||
else
|
||||
{
|
||||
::new ((void*)__result) value_type(_VSTD::move(*__first1));
|
||||
__d.template __incr<value_type>();
|
||||
++__first1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
|
||||
void
|
||||
__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2,
|
||||
_OutputIterator __result, _Compare __comp)
|
||||
{
|
||||
for (; __first1 != __last1; ++__result)
|
||||
{
|
||||
if (__first2 == __last2)
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1, (void) ++__result)
|
||||
*__result = _VSTD::move(*__first1);
|
||||
return;
|
||||
}
|
||||
if (__comp(*__first2, *__first1))
|
||||
{
|
||||
*__result = _VSTD::move(*__first2);
|
||||
++__first2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*__result = _VSTD::move(*__first1);
|
||||
++__first1;
|
||||
}
|
||||
}
|
||||
for (; __first2 != __last2; ++__first2, (void) ++__result)
|
||||
*__result = _VSTD::move(*__first2);
|
||||
}
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
void
|
||||
__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
|
||||
typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size);
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
void
|
||||
__stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1, _Compare __comp,
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
|
||||
typename iterator_traits<_RandomAccessIterator>::value_type* __first2)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
switch (__len)
|
||||
{
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
::new ((void*)__first2) value_type(_VSTD::move(*__first1));
|
||||
return;
|
||||
case 2:
|
||||
__destruct_n __d(0);
|
||||
unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
|
||||
if (__comp(*--__last1, *__first1))
|
||||
{
|
||||
::new ((void*)__first2) value_type(_VSTD::move(*__last1));
|
||||
__d.template __incr<value_type>();
|
||||
++__first2;
|
||||
::new ((void*)__first2) value_type(_VSTD::move(*__first1));
|
||||
}
|
||||
else
|
||||
{
|
||||
::new ((void*)__first2) value_type(_VSTD::move(*__first1));
|
||||
__d.template __incr<value_type>();
|
||||
++__first2;
|
||||
::new ((void*)__first2) value_type(_VSTD::move(*__last1));
|
||||
}
|
||||
__h2.release();
|
||||
return;
|
||||
}
|
||||
if (__len <= 8)
|
||||
{
|
||||
_VSTD::__insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp);
|
||||
return;
|
||||
}
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
|
||||
_RandomAccessIterator __m = __first1 + __l2;
|
||||
_VSTD::__stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2);
|
||||
_VSTD::__stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);
|
||||
_VSTD::__merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
struct __stable_sort_switch
|
||||
{
|
||||
static const unsigned value = 128*is_trivially_copy_assignable<_Tp>::value;
|
||||
};
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
void
|
||||
__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
|
||||
typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
switch (__len)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
return;
|
||||
case 2:
|
||||
if (__comp(*--__last, *__first))
|
||||
swap(*__first, *__last);
|
||||
return;
|
||||
}
|
||||
if (__len <= static_cast<difference_type>(__stable_sort_switch<value_type>::value))
|
||||
{
|
||||
_VSTD::__insertion_sort<_Compare>(__first, __last, __comp);
|
||||
return;
|
||||
}
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
|
||||
_RandomAccessIterator __m = __first + __l2;
|
||||
if (__len <= __buff_size)
|
||||
{
|
||||
__destruct_n __d(0);
|
||||
unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
|
||||
_VSTD::__stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff);
|
||||
__d.__set(__l2, (value_type*)nullptr);
|
||||
_VSTD::__stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);
|
||||
__d.__set(__len, (value_type*)nullptr);
|
||||
_VSTD::__merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
|
||||
// _VSTD::__merge<_Compare>(move_iterator<value_type*>(__buff),
|
||||
// move_iterator<value_type*>(__buff + __l2),
|
||||
// move_iterator<_RandomAccessIterator>(__buff + __l2),
|
||||
// move_iterator<_RandomAccessIterator>(__buff + __len),
|
||||
// __first, __comp);
|
||||
return;
|
||||
}
|
||||
_VSTD::__stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
|
||||
_VSTD::__stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
|
||||
_VSTD::__inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
difference_type __len = __last - __first;
|
||||
pair<value_type*, ptrdiff_t> __buf(0, 0);
|
||||
unique_ptr<value_type, __return_temporary_buffer> __h;
|
||||
if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value))
|
||||
{
|
||||
__buf = _VSTD::get_temporary_buffer<value_type>(__len);
|
||||
__h.reset(__buf.first);
|
||||
}
|
||||
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
|
||||
_VSTD::__stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
_VSTD::stable_sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_STABLE_SORT_H
|
||||
37
lib/libcxx/include/__algorithm/swap_ranges.h
vendored
Normal file
37
lib/libcxx/include/__algorithm/swap_ranges.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_SWAP_RANGES_H
|
||||
#define _LIBCPP___ALGORITHM_SWAP_RANGES_H
|
||||
|
||||
#include <__config>
|
||||
#include <__utility/swap.h>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator2
|
||||
swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
|
||||
for (; __first1 != __last1; ++__first1, (void)++__first2)
|
||||
swap(*__first1, *__first2);
|
||||
return __first2;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_SWAP_RANGES_H
|
||||
48
lib/libcxx/include/__algorithm/transform.h
vendored
Normal file
48
lib/libcxx/include/__algorithm/transform.h
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_TRANSFORM_H
|
||||
#define _LIBCPP___ALGORITHM_TRANSFORM_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _UnaryOperation>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
|
||||
{
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
*__result = __op(*__first);
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _BinaryOperation>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
|
||||
_OutputIterator __result, _BinaryOperation __binary_op)
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1, (void) ++__first2, ++__result)
|
||||
*__result = __binary_op(*__first1, *__first2);
|
||||
return __result;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_TRANSFORM_H
|
||||
63
lib/libcxx/include/__algorithm/unique.h
vendored
Normal file
63
lib/libcxx/include/__algorithm/unique.h
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_UNIQUE_H
|
||||
#define _LIBCPP___ALGORITHM_UNIQUE_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/adjacent_find.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__utility/move.h>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// unique
|
||||
|
||||
template <class _ForwardIterator, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
|
||||
{
|
||||
__first = _VSTD::adjacent_find<_ForwardIterator, typename add_lvalue_reference<_BinaryPredicate>::type>
|
||||
(__first, __last, __pred);
|
||||
if (__first != __last)
|
||||
{
|
||||
// ... a a ? ...
|
||||
// f i
|
||||
_ForwardIterator __i = __first;
|
||||
for (++__i; ++__i != __last;)
|
||||
if (!__pred(*__first, *__i))
|
||||
*++__first = _VSTD::move(*__i);
|
||||
++__first;
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_ForwardIterator
|
||||
unique(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type __v;
|
||||
return _VSTD::unique(__first, __last, __equal_to<__v>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_UNIQUE_H
|
||||
114
lib/libcxx/include/__algorithm/unique_copy.h
vendored
Normal file
114
lib/libcxx/include/__algorithm/unique_copy.h
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_UNIQUE_COPY_H
|
||||
#define _LIBCPP___ALGORITHM_UNIQUE_COPY_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _BinaryPredicate, class _InputIterator, class _OutputIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
|
||||
__unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
|
||||
input_iterator_tag, output_iterator_tag)
|
||||
{
|
||||
if (__first != __last)
|
||||
{
|
||||
typename iterator_traits<_InputIterator>::value_type __t(*__first);
|
||||
*__result = __t;
|
||||
++__result;
|
||||
while (++__first != __last)
|
||||
{
|
||||
if (!__pred(__t, *__first))
|
||||
{
|
||||
__t = *__first;
|
||||
*__result = __t;
|
||||
++__result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _ForwardIterator, class _OutputIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
|
||||
__unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
|
||||
forward_iterator_tag, output_iterator_tag)
|
||||
{
|
||||
if (__first != __last)
|
||||
{
|
||||
_ForwardIterator __i = __first;
|
||||
*__result = *__i;
|
||||
++__result;
|
||||
while (++__first != __last)
|
||||
{
|
||||
if (!__pred(*__i, *__first))
|
||||
{
|
||||
*__result = *__first;
|
||||
++__result;
|
||||
__i = __first;
|
||||
}
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _InputIterator, class _ForwardIterator>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
__unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __pred,
|
||||
input_iterator_tag, forward_iterator_tag)
|
||||
{
|
||||
if (__first != __last)
|
||||
{
|
||||
*__result = *__first;
|
||||
while (++__first != __last)
|
||||
if (!__pred(*__result, *__first))
|
||||
*++__result = *__first;
|
||||
++__result;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred)
|
||||
{
|
||||
return _VSTD::__unique_copy<typename add_lvalue_reference<_BinaryPredicate>::type>
|
||||
(__first, __last, __result, __pred,
|
||||
typename iterator_traits<_InputIterator>::iterator_category(),
|
||||
typename iterator_traits<_OutputIterator>::iterator_category());
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_OutputIterator
|
||||
unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIterator>::value_type __v;
|
||||
return _VSTD::unique_copy(__first, __last, __result, __equal_to<__v>());
|
||||
}
|
||||
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H
|
||||
87
lib/libcxx/include/__algorithm/unwrap_iter.h
vendored
Normal file
87
lib/libcxx/include/__algorithm/unwrap_iter.h
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_UNWRAP_ITER_H
|
||||
#define _LIBCPP___ALGORITHM_UNWRAP_ITER_H
|
||||
|
||||
#include <__config>
|
||||
#include <iterator>
|
||||
#include <__memory/pointer_traits.h>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// The job of __unwrap_iter is to lower contiguous iterators (such as
|
||||
// vector<T>::iterator) into pointers, to reduce the number of template
|
||||
// instantiations and to enable pointer-based optimizations e.g. in std::copy.
|
||||
// For iterators that are not contiguous, it must be a no-op.
|
||||
// In debug mode, we don't do this.
|
||||
//
|
||||
// __unwrap_iter is non-constexpr for user-defined iterators whose
|
||||
// `to_address` and/or `operator->` is non-constexpr. This is okay; but we
|
||||
// try to avoid doing __unwrap_iter in constant-evaluated contexts anyway.
|
||||
//
|
||||
// Some algorithms (e.g. std::copy, but not std::sort) need to convert an
|
||||
// "unwrapped" result back into a contiguous iterator. Since contiguous iterators
|
||||
// are random-access, we can do this portably using iterator arithmetic; this
|
||||
// is the job of __rewrap_iter.
|
||||
|
||||
template <class _Iter, bool = __is_cpp17_contiguous_iterator<_Iter>::value>
|
||||
struct __unwrap_iter_impl {
|
||||
static _LIBCPP_CONSTEXPR _Iter
|
||||
__apply(_Iter __i) _NOEXCEPT {
|
||||
return __i;
|
||||
}
|
||||
};
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL < 2
|
||||
|
||||
template <class _Iter>
|
||||
struct __unwrap_iter_impl<_Iter, true> {
|
||||
static _LIBCPP_CONSTEXPR decltype(_VSTD::__to_address(declval<_Iter>()))
|
||||
__apply(_Iter __i) _NOEXCEPT {
|
||||
return _VSTD::__to_address(__i);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_DEBUG_LEVEL < 2
|
||||
|
||||
template<class _Iter, class _Impl = __unwrap_iter_impl<_Iter> >
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
decltype(_Impl::__apply(declval<_Iter>()))
|
||||
__unwrap_iter(_Iter __i) _NOEXCEPT
|
||||
{
|
||||
return _Impl::__apply(__i);
|
||||
}
|
||||
|
||||
template<class _OrigIter>
|
||||
_OrigIter __rewrap_iter(_OrigIter, _OrigIter __result)
|
||||
{
|
||||
return __result;
|
||||
}
|
||||
|
||||
template<class _OrigIter, class _UnwrappedIter>
|
||||
_OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result)
|
||||
{
|
||||
// Precondition: __result is reachable from __first
|
||||
// Precondition: _OrigIter is a contiguous iterator
|
||||
return __first + (__result - _VSTD::__unwrap_iter(__first));
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_UNWRAP_ITER_H
|
||||
72
lib/libcxx/include/__algorithm/upper_bound.h
vendored
Normal file
72
lib/libcxx/include/__algorithm/upper_bound.h
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP___ALGORITHM_UPPER_BOUND_H
|
||||
#define _LIBCPP___ALGORITHM_UPPER_BOUND_H
|
||||
|
||||
#include <__config>
|
||||
#include <__algorithm/comp.h>
|
||||
#include <__algorithm/half_positive.h>
|
||||
#include <iterator>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Compare, class _ForwardIterator, class _Tp>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||
__upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
|
||||
difference_type __len = _VSTD::distance(__first, __last);
|
||||
while (__len != 0)
|
||||
{
|
||||
difference_type __l2 = _VSTD::__half_positive(__len);
|
||||
_ForwardIterator __m = __first;
|
||||
_VSTD::advance(__m, __l2);
|
||||
if (__comp(__value_, *__m))
|
||||
__len = __l2;
|
||||
else
|
||||
{
|
||||
__first = ++__m;
|
||||
__len -= __l2 + 1;
|
||||
}
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp, class _Compare>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_ForwardIterator
|
||||
upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
|
||||
{
|
||||
typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
|
||||
return _VSTD::__upper_bound<_Comp_ref>(__first, __last, __value_, __comp);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_ForwardIterator
|
||||
upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
|
||||
{
|
||||
return _VSTD::upper_bound(__first, __last, __value_,
|
||||
__less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___ALGORITHM_UPPER_BOUND_H
|
||||
70
lib/libcxx/include/__availability
vendored
70
lib/libcxx/include/__availability
vendored
@ -43,6 +43,14 @@
|
||||
// as unavailable. When vendors decide to ship the feature as part of their
|
||||
// shared library, they can update the markup appropriately.
|
||||
//
|
||||
// Furthermore, many features in the standard library have corresponding
|
||||
// feature-test macros. When a feature is made unavailable on some deployment
|
||||
// target, a macro should be defined to signal that it is unavailable. That
|
||||
// macro can then be picked up when feature-test macros are generated (see
|
||||
// generate_feature_test_macro_components.py) to make sure that feature-test
|
||||
// macros don't announce a feature as being implemented if it has been marked
|
||||
// as unavailable.
|
||||
//
|
||||
// Note that this mechanism is disabled by default in the "upstream" libc++.
|
||||
// Availability annotations are only meaningful when shipping libc++ inside
|
||||
// a platform (i.e. as a system library), and so vendors that want them should
|
||||
@ -76,6 +84,8 @@
|
||||
// This controls the availability of std::shared_mutex and std::shared_timed_mutex,
|
||||
// which were added to the dylib later.
|
||||
# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
|
||||
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_mutex
|
||||
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_timed_mutex
|
||||
|
||||
// These macros control the availability of std::bad_optional_access and
|
||||
// other exception types. These were put in the shared library to prevent
|
||||
@ -114,6 +124,7 @@
|
||||
# define _LIBCPP_AVAILABILITY_FILESYSTEM
|
||||
# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
|
||||
# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
|
||||
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem
|
||||
|
||||
// This controls the availability of std::to_chars.
|
||||
# define _LIBCPP_AVAILABILITY_TO_CHARS
|
||||
@ -122,6 +133,17 @@
|
||||
// which requires shared library support for various operations
|
||||
// (see libcxx/src/atomic.cpp).
|
||||
# define _LIBCPP_AVAILABILITY_SYNC
|
||||
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait
|
||||
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier
|
||||
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_latch
|
||||
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore
|
||||
|
||||
// This controls the availability of the C++20 format library.
|
||||
// The library is in development and not ABI stable yet. Currently
|
||||
// P2216 is aiming to be retroactively accepted in C++20. This paper
|
||||
// contains ABI breaking changes.
|
||||
# define _LIBCPP_AVAILABILITY_FORMAT
|
||||
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
@ -130,6 +152,14 @@
|
||||
__attribute__((availability(ios,strict,introduced=10.0))) \
|
||||
__attribute__((availability(tvos,strict,introduced=10.0))) \
|
||||
__attribute__((availability(watchos,strict,introduced=3.0)))
|
||||
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200) || \
|
||||
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 100000) || \
|
||||
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 100000) || \
|
||||
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 30000)
|
||||
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_mutex
|
||||
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_timed_mutex
|
||||
# endif
|
||||
|
||||
# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
|
||||
__attribute__((availability(macosx,strict,introduced=10.13))) \
|
||||
__attribute__((availability(ios,strict,introduced=11.0))) \
|
||||
@ -139,27 +169,34 @@
|
||||
_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
|
||||
# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
|
||||
_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
|
||||
|
||||
# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
|
||||
__attribute__((availability(macosx,strict,introduced=10.12))) \
|
||||
__attribute__((availability(ios,strict,introduced=10.0))) \
|
||||
__attribute__((availability(tvos,strict,introduced=10.0))) \
|
||||
__attribute__((availability(watchos,strict,introduced=3.0)))
|
||||
|
||||
# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
|
||||
__attribute__((availability(macosx,strict,introduced=10.12))) \
|
||||
__attribute__((availability(ios,strict,introduced=10.0))) \
|
||||
__attribute__((availability(tvos,strict,introduced=10.0))) \
|
||||
__attribute__((availability(watchos,strict,introduced=3.0)))
|
||||
|
||||
# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \
|
||||
__attribute__((availability(ios,strict,introduced=6.0)))
|
||||
|
||||
# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
|
||||
__attribute__((availability(macosx,strict,introduced=10.9))) \
|
||||
__attribute__((availability(ios,strict,introduced=7.0)))
|
||||
|
||||
# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
|
||||
__attribute__((availability(macosx,strict,introduced=10.9))) \
|
||||
__attribute__((availability(ios,strict,introduced=7.0)))
|
||||
|
||||
# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
|
||||
__attribute__((availability(macosx,strict,introduced=10.9))) \
|
||||
__attribute__((availability(ios,strict,introduced=7.0)))
|
||||
|
||||
# define _LIBCPP_AVAILABILITY_FILESYSTEM \
|
||||
__attribute__((availability(macosx,strict,introduced=10.15))) \
|
||||
__attribute__((availability(ios,strict,introduced=13.0))) \
|
||||
@ -175,11 +212,38 @@
|
||||
_Pragma("clang attribute pop") \
|
||||
_Pragma("clang attribute pop") \
|
||||
_Pragma("clang attribute pop")
|
||||
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
|
||||
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
|
||||
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) || \
|
||||
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000)
|
||||
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem
|
||||
# endif
|
||||
|
||||
# define _LIBCPP_AVAILABILITY_TO_CHARS \
|
||||
_LIBCPP_AVAILABILITY_FILESYSTEM
|
||||
# define _LIBCPP_AVAILABILITY_SYNC \
|
||||
__attribute__((unavailable))
|
||||
|
||||
# define _LIBCPP_AVAILABILITY_SYNC \
|
||||
__attribute__((availability(macosx,strict,introduced=11.0))) \
|
||||
__attribute__((availability(ios,strict,introduced=14.0))) \
|
||||
__attribute__((availability(tvos,strict,introduced=14.0))) \
|
||||
__attribute__((availability(watchos,strict,introduced=7.0)))
|
||||
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \
|
||||
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \
|
||||
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \
|
||||
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000)
|
||||
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait
|
||||
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier
|
||||
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_latch
|
||||
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore
|
||||
# endif
|
||||
|
||||
// This controls the availability of the C++20 format library.
|
||||
// The library is in development and not ABI stable yet. Currently
|
||||
// P2216 is aiming to be retroactively accepted in C++20. This paper
|
||||
// contains ABI breaking changes.
|
||||
# define _LIBCPP_AVAILABILITY_FORMAT \
|
||||
__attribute__((unavailable))
|
||||
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
|
||||
#else
|
||||
|
||||
// ...New vendors can add availability markup here...
|
||||
@ -203,4 +267,4 @@
|
||||
# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP___AVAILABILITY
|
||||
#endif // _LIBCPP___AVAILABILITY
|
||||
|
||||
36
lib/libcxx/include/__bit_reference
vendored
36
lib/libcxx/include/__bit_reference
vendored
@ -1114,28 +1114,26 @@ public:
|
||||
#endif
|
||||
{}
|
||||
|
||||
// avoid re-declaring a copy constructor for the non-const version.
|
||||
using __type_for_copy_to_const =
|
||||
_If<_IsConst, __bit_iterator<_Cp, false>, struct __private_nat>;
|
||||
|
||||
// When _IsConst=false, this is the copy constructor.
|
||||
// It is non-trivial. Making it trivial would break ABI.
|
||||
// When _IsConst=true, this is a converting constructor;
|
||||
// the copy and move constructors are implicitly generated
|
||||
// and trivial.
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__bit_iterator(const __type_for_copy_to_const& __it) _NOEXCEPT
|
||||
__bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
|
||||
: __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
|
||||
|
||||
// The non-const __bit_iterator has historically had a non-trivial
|
||||
// copy constructor (as a quirk of its construction). We need to maintain
|
||||
// this for ABI purposes.
|
||||
using __type_for_abi_non_trivial_copy_ctor =
|
||||
_If<!_IsConst, __bit_iterator, struct __private_nat>;
|
||||
|
||||
// When _IsConst=false, we have a user-provided copy constructor,
|
||||
// so we must also provide a copy assignment operator because
|
||||
// the implicit generation of a defaulted one is deprecated.
|
||||
// When _IsConst=true, the assignment operators are
|
||||
// implicitly generated and trivial.
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__bit_iterator(__type_for_abi_non_trivial_copy_ctor const& __it) _NOEXCEPT
|
||||
: __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
|
||||
|
||||
// Always declare the copy assignment operator since the implicit declaration
|
||||
// is deprecated.
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__bit_iterator& operator=(__bit_iterator const&) = default;
|
||||
__bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {
|
||||
__seg_ = __it.__seg_;
|
||||
__ctz_ = __it.__ctz_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT
|
||||
{return reference(__seg_, __storage_type(1) << __ctz_);}
|
||||
@ -1302,4 +1300,4 @@ _LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___BIT_REFERENCE
|
||||
#endif // _LIBCPP___BIT_REFERENCE
|
||||
|
||||
3
lib/libcxx/include/__bits
vendored
3
lib/libcxx/include/__bits
vendored
@ -76,7 +76,6 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __libcpp_ctz(unsigned long long __x) {
|
||||
unsigned long __where;
|
||||
#if defined(_LIBCPP_HAS_BITSCAN64)
|
||||
(defined(_M_AMD64) || defined(__x86_64__))
|
||||
if (_BitScanForward64(&__where, __x))
|
||||
return static_cast<int>(__where);
|
||||
#else
|
||||
@ -143,4 +142,4 @@ _LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP__BITS
|
||||
#endif // _LIBCPP___BITS
|
||||
|
||||
4
lib/libcxx/include/__bsd_locale_fallbacks.h
vendored
4
lib/libcxx/include/__bsd_locale_fallbacks.h
vendored
@ -13,9 +13,9 @@
|
||||
#ifndef _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
|
||||
#define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <memory>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
|
||||
263
lib/libcxx/include/__config
vendored
263
lib/libcxx/include/__config
vendored
@ -32,7 +32,7 @@
|
||||
# define _GNUC_VER_NEW 0
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_VERSION 12000
|
||||
#define _LIBCPP_VERSION 13000
|
||||
|
||||
#ifndef _LIBCPP_ABI_VERSION
|
||||
# define _LIBCPP_ABI_VERSION 1
|
||||
@ -54,7 +54,7 @@
|
||||
# else
|
||||
# define _LIBCPP_STD_VER 21 // current year, or date of c++2b ratification
|
||||
# endif
|
||||
#endif // _LIBCPP_STD_VER
|
||||
#endif // _LIBCPP_STD_VER
|
||||
|
||||
#if defined(__ELF__)
|
||||
# define _LIBCPP_OBJECT_FORMAT_ELF 1
|
||||
@ -86,17 +86,18 @@
|
||||
// provided under the alternate keyword __nullptr, which changes the mangling
|
||||
// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
|
||||
# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
|
||||
// Define the `pointer_safety` enum as a C++11 strongly typed enumeration
|
||||
// instead of as a class simulating an enum. If this option is enabled
|
||||
// `pointer_safety` and `get_pointer_safety()` will no longer be available
|
||||
// in C++03.
|
||||
# define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
|
||||
// Define a key function for `bad_function_call` in the library, to centralize
|
||||
// its vtable and typeinfo to libc++ rather than having all other libraries
|
||||
// using that class define their own copies.
|
||||
# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
|
||||
// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
|
||||
# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
|
||||
// In C++20 and later, don't derive std::plus from std::binary_function,
|
||||
// nor std::negate from std::unary_function.
|
||||
# define _LIBCPP_ABI_NO_BINDER_BASES
|
||||
// Give reverse_iterator<T> one data member of type T, not two.
|
||||
// Also, in C++17 and later, don't derive iterator types from std::iterator.
|
||||
# define _LIBCPP_ABI_NO_ITERATOR_BASES
|
||||
// Use the smallest possible integer type to represent the index of the variant.
|
||||
// Previously libc++ used "unsigned int" exclusively.
|
||||
# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
|
||||
@ -104,6 +105,8 @@
|
||||
# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
|
||||
// All the regex constants must be distinct and nonzero.
|
||||
# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
|
||||
// Use raw pointers, not wrapped ones, for std::span's iterator type.
|
||||
# define _LIBCPP_ABI_SPAN_POINTER_ITERATORS
|
||||
// Re-worked external template instantiations for std::string with a focus on
|
||||
// performance and fast-path inlining.
|
||||
# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
|
||||
@ -181,11 +184,12 @@
|
||||
#define __has_include(...) 0
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
# define _LIBCPP_COMPILER_CLANG
|
||||
# ifndef __apple_build_version__
|
||||
# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
|
||||
# endif
|
||||
#if defined(__apple_build_version__)
|
||||
# define _LIBCPP_COMPILER_CLANG_BASED
|
||||
# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
|
||||
#elif defined(__clang__)
|
||||
# define _LIBCPP_COMPILER_CLANG_BASED
|
||||
# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
|
||||
#elif defined(__GNUC__)
|
||||
# define _LIBCPP_COMPILER_GCC
|
||||
#elif defined(_MSC_VER)
|
||||
@ -235,13 +239,13 @@
|
||||
# if __LITTLE_ENDIAN__
|
||||
# define _LIBCPP_LITTLE_ENDIAN
|
||||
# endif // __LITTLE_ENDIAN__
|
||||
#endif // __LITTLE_ENDIAN__
|
||||
#endif // __LITTLE_ENDIAN__
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
# if __BIG_ENDIAN__
|
||||
# define _LIBCPP_BIG_ENDIAN
|
||||
# endif // __BIG_ENDIAN__
|
||||
#endif // __BIG_ENDIAN__
|
||||
#endif // __BIG_ENDIAN__
|
||||
|
||||
#ifdef __BYTE_ORDER__
|
||||
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
@ -262,7 +266,7 @@
|
||||
# ifndef __LONG_LONG_SUPPORTED
|
||||
# define _LIBCPP_HAS_NO_LONG_LONG
|
||||
# endif // __LONG_LONG_SUPPORTED
|
||||
#endif // __FreeBSD__
|
||||
#endif // __FreeBSD__
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
# include <sys/endian.h>
|
||||
@ -271,7 +275,7 @@
|
||||
# else // _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# define _LIBCPP_BIG_ENDIAN
|
||||
# endif // _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#endif // defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#endif // defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define _LIBCPP_WIN32API
|
||||
@ -340,7 +344,7 @@
|
||||
# else // __BYTE_ORDER == __BIG_ENDIAN
|
||||
# error unable to determine endian
|
||||
# endif
|
||||
#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
|
||||
#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
|
||||
|
||||
#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
|
||||
# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
|
||||
@ -348,7 +352,7 @@
|
||||
# define _LIBCPP_NO_CFI
|
||||
#endif
|
||||
|
||||
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
|
||||
#if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L
|
||||
# if defined(__FreeBSD__)
|
||||
# define _LIBCPP_HAS_ALIGNED_ALLOC
|
||||
# define _LIBCPP_HAS_QUICK_EXIT
|
||||
@ -387,13 +391,16 @@
|
||||
# define _LIBCPP_HAS_QUICK_EXIT
|
||||
# define _LIBCPP_HAS_TIMESPEC_GET
|
||||
# endif
|
||||
# elif defined(_LIBCPP_MSVCRT)
|
||||
// Using Microsoft's C Runtime library, not MinGW
|
||||
# define _LIBCPP_HAS_TIMESPEC_GET
|
||||
# elif defined(__APPLE__)
|
||||
// timespec_get and aligned_alloc were introduced in macOS 10.15 and
|
||||
// aligned releases
|
||||
# if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500 || \
|
||||
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000 || \
|
||||
__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000 || \
|
||||
__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000)
|
||||
# if ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500) || \
|
||||
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
|
||||
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
|
||||
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000))
|
||||
# define _LIBCPP_HAS_ALIGNED_ALLOC
|
||||
# define _LIBCPP_HAS_TIMESPEC_GET
|
||||
# endif
|
||||
@ -402,7 +409,7 @@
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
|
||||
#elif defined(_LIBCPP_COMPILER_CLANG)
|
||||
#elif defined(_LIBCPP_COMPILER_CLANG_BASED)
|
||||
# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
|
||||
#else
|
||||
# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang"
|
||||
@ -410,7 +417,7 @@
|
||||
|
||||
#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
|
||||
|
||||
#if defined(_LIBCPP_COMPILER_CLANG)
|
||||
#if defined(_LIBCPP_COMPILER_CLANG_BASED)
|
||||
|
||||
#if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
|
||||
# error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead
|
||||
@ -484,12 +491,12 @@ typedef __char32_t char32_t;
|
||||
#define _LIBCPP_HAS_NO_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
|
||||
#if !__has_feature(address_sanitizer)
|
||||
#define _LIBCPP_HAS_NO_ASAN
|
||||
#endif
|
||||
|
||||
// Allow for build-time disabling of unsigned integer sanitization
|
||||
#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
|
||||
#if __has_attribute(no_sanitize)
|
||||
#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
|
||||
#endif
|
||||
|
||||
@ -508,8 +515,8 @@ typedef __char32_t char32_t;
|
||||
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
|
||||
|
||||
// Literal operators ""d and ""y are supported starting with LLVM Clang 8 and AppleClang 10.0.1
|
||||
#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \
|
||||
(defined(__apple_build_version__) && __apple_build_version__ < 10010000)
|
||||
#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \
|
||||
(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1001)
|
||||
#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS
|
||||
#endif
|
||||
|
||||
@ -522,7 +529,7 @@ typedef __char32_t char32_t;
|
||||
|
||||
#define _LIBCPP_NORETURN __attribute__((noreturn))
|
||||
|
||||
#if !__EXCEPTIONS
|
||||
#if !defined(__EXCEPTIONS)
|
||||
# define _LIBCPP_NO_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
@ -536,7 +543,7 @@ typedef __char32_t char32_t;
|
||||
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
|
||||
#if !defined(__SANITIZE_ADDRESS__)
|
||||
#define _LIBCPP_HAS_NO_ASAN
|
||||
#endif
|
||||
|
||||
@ -640,6 +647,7 @@ typedef __char32_t char32_t;
|
||||
#define _LIBCPP_HIDDEN
|
||||
#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
#define _LIBCPP_TEMPLATE_VIS
|
||||
#define _LIBCPP_TEMPLATE_DATA_VIS
|
||||
#define _LIBCPP_ENUM_VIS
|
||||
|
||||
#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
|
||||
@ -689,6 +697,14 @@ typedef __char32_t char32_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_TEMPLATE_DATA_VIS
|
||||
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||
# define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default")))
|
||||
# else
|
||||
# define _LIBCPP_TEMPLATE_DATA_VIS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_EXPORTED_FROM_ABI
|
||||
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||
# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
|
||||
@ -792,10 +808,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#define _VSTD_FS _VSTD::__fs::filesystem
|
||||
|
||||
#ifndef _LIBCPP_PREFERRED_OVERLOAD
|
||||
# if __has_attribute(__enable_if__)
|
||||
# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
|
||||
# endif
|
||||
#if __has_attribute(__enable_if__)
|
||||
# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_NOEXCEPT
|
||||
@ -809,7 +823,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
|
||||
#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
typedef unsigned short char16_t;
|
||||
typedef unsigned int char32_t;
|
||||
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
|
||||
#ifndef __SIZEOF_INT128__
|
||||
#define _LIBCPP_HAS_NO_INT128
|
||||
@ -818,7 +832,7 @@ typedef unsigned int char32_t;
|
||||
#ifdef _LIBCPP_CXX03_LANG
|
||||
# define static_assert(...) _Static_assert(__VA_ARGS__)
|
||||
# define decltype(...) __decltype(__VA_ARGS__)
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
#ifdef _LIBCPP_CXX03_LANG
|
||||
# define _LIBCPP_CONSTEXPR
|
||||
@ -832,6 +846,14 @@ typedef unsigned int char32_t;
|
||||
# define _LIBCPP_CONSTEVAL consteval
|
||||
#endif
|
||||
|
||||
#if !defined(__cpp_concepts) || __cpp_concepts < 201907L
|
||||
#define _LIBCPP_HAS_NO_CONCEPTS
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_HAS_NO_CONCEPTS)
|
||||
#define _LIBCPP_HAS_NO_RANGES
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_CXX03_LANG
|
||||
# define _LIBCPP_DEFAULT {}
|
||||
#else
|
||||
@ -850,11 +872,10 @@ typedef unsigned int char32_t;
|
||||
# define _LIBCPP_NOALIAS
|
||||
#endif
|
||||
|
||||
#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
|
||||
(!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
|
||||
# define _LIBCPP_EXPLICIT explicit
|
||||
#if __has_attribute(using_if_exists)
|
||||
# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
|
||||
#else
|
||||
# define _LIBCPP_EXPLICIT
|
||||
# define _LIBCPP_USING_IF_EXISTS
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
|
||||
@ -868,7 +889,7 @@ typedef unsigned int char32_t;
|
||||
#else // _LIBCPP_HAS_NO_STRONG_ENUMS
|
||||
# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
|
||||
# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
|
||||
#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
|
||||
#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
|
||||
|
||||
// _LIBCPP_DEBUG potential values:
|
||||
// - undefined: No assertions. This is the default.
|
||||
@ -884,33 +905,25 @@ typedef unsigned int char32_t;
|
||||
# error Supported values for _LIBCPP_DEBUG are 0 and 1
|
||||
#endif
|
||||
|
||||
// _LIBCPP_DEBUG_LEVEL is always defined to one of [0, 1, 2] at this point
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE)
|
||||
# define _LIBCPP_EXTERN_TEMPLATE(...)
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
|
||||
# define _LIBCPP_EXTERN_TEMPLATE(...)
|
||||
# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...)
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_EXTERN_TEMPLATE
|
||||
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
|
||||
#endif
|
||||
|
||||
// When the Debug mode is enabled, we disable extern declarations because we
|
||||
// don't want to use the functions compiled in the library, which might not
|
||||
// have had the debug mode enabled when built. However, some extern declarations
|
||||
// need to be used, because code correctness depends on it (several instances
|
||||
// in the <locale>). Those special declarations are declared with
|
||||
// _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled even
|
||||
// when the debug mode is enabled.
|
||||
#ifndef _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE
|
||||
# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_EXTERN_TEMPLATE_DEFINE
|
||||
#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;
|
||||
// Libc++ allows disabling extern template instantiation declarations by
|
||||
// means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE.
|
||||
//
|
||||
// Furthermore, when the Debug mode is enabled, we disable extern declarations
|
||||
// when building user code because we don't want to use the functions compiled
|
||||
// in the library, which might not have had the debug mode enabled when built.
|
||||
// However, some extern declarations need to be used, because code correctness
|
||||
// depends on it (several instances in <locale>). Those special declarations
|
||||
// are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled
|
||||
// even when the debug mode is enabled.
|
||||
#if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE)
|
||||
# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
|
||||
# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */
|
||||
#elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
|
||||
# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
|
||||
#else
|
||||
# define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
|
||||
# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
|
||||
@ -918,13 +931,6 @@ typedef unsigned int char32_t;
|
||||
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
|
||||
#endif
|
||||
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
// Most unix variants have catopen. These are the specific ones that don't.
|
||||
# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
|
||||
# define _LIBCPP_HAS_CATOPEN 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define _DECLARE_C99_LDBL_MATH 1
|
||||
#endif
|
||||
@ -948,9 +954,8 @@ typedef unsigned int char32_t;
|
||||
# endif
|
||||
#endif // defined(__APPLE__)
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
|
||||
(defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
|
||||
(!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606))
|
||||
#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
|
||||
(!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
|
||||
# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
|
||||
#endif
|
||||
|
||||
@ -963,7 +968,7 @@ typedef unsigned int char32_t;
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
|
||||
#define _LIBCPP_NO_HAS_CHAR8_T
|
||||
#define _LIBCPP_HAS_NO_CHAR8_T
|
||||
#endif
|
||||
|
||||
// Deprecation macros.
|
||||
@ -1006,24 +1011,23 @@ typedef unsigned int char32_t;
|
||||
# define _LIBCPP_DEPRECATED_IN_CXX20
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_NO_HAS_CHAR8_T)
|
||||
#if !defined(_LIBCPP_HAS_NO_CHAR8_T)
|
||||
# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
|
||||
#else
|
||||
# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
|
||||
#endif
|
||||
|
||||
// Macros to enter and leave a state where deprecation warnings are suppressed.
|
||||
#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \
|
||||
(defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC))
|
||||
# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
|
||||
# define _LIBCPP_SUPPRESS_DEPRECATED_POP \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
#endif
|
||||
#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH)
|
||||
# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
# define _LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
#if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
|
||||
# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
||||
# define _LIBCPP_SUPPRESS_DEPRECATED_POP \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
#else
|
||||
# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
# define _LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER <= 11
|
||||
@ -1054,7 +1058,7 @@ typedef unsigned int char32_t;
|
||||
// NODISCARD macros to the correct attribute.
|
||||
#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
|
||||
# define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
|
||||
#elif defined(_LIBCPP_COMPILER_CLANG) && !defined(_LIBCPP_CXX03_LANG)
|
||||
#elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
|
||||
# define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]]
|
||||
#else
|
||||
// We can't use GCC's [[gnu::warn_unused_result]] and
|
||||
@ -1084,12 +1088,10 @@ typedef unsigned int char32_t;
|
||||
# define _LIBCPP_INLINE_VAR
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
|
||||
#define _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
# define _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
#else
|
||||
#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
|
||||
#endif
|
||||
# define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
|
||||
#endif
|
||||
|
||||
#if __has_attribute(no_destroy)
|
||||
@ -1104,7 +1106,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
|
||||
#endif
|
||||
|
||||
// Try to find out if RTTI is disabled.
|
||||
#if defined(_LIBCPP_COMPILER_CLANG) && !__has_feature(cxx_rtti)
|
||||
#if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti)
|
||||
# define _LIBCPP_NO_RTTI
|
||||
#elif defined(__GNUC__) && !defined(__GXX_RTTI)
|
||||
# define _LIBCPP_NO_RTTI
|
||||
@ -1132,6 +1134,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
|
||||
defined(__CloudABI__) || \
|
||||
defined(__sun__) || \
|
||||
defined(__MVS__) || \
|
||||
defined(_AIX) || \
|
||||
(defined(__MINGW32__) && __has_include(<pthread.h>))
|
||||
# define _LIBCPP_HAS_THREAD_API_PTHREAD
|
||||
# elif defined(__Fuchsia__)
|
||||
@ -1218,12 +1221,10 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
|
||||
#endif
|
||||
|
||||
// Some systems do not provide gets() in their C library, for security reasons.
|
||||
#ifndef _LIBCPP_C_HAS_NO_GETS
|
||||
# if defined(_LIBCPP_MSVCRT) || \
|
||||
(defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
|
||||
defined(__OpenBSD__)
|
||||
# define _LIBCPP_C_HAS_NO_GETS
|
||||
# endif
|
||||
#if defined(_LIBCPP_MSVCRT) || \
|
||||
(defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
|
||||
defined(__OpenBSD__)
|
||||
# define _LIBCPP_C_HAS_NO_GETS
|
||||
#endif
|
||||
|
||||
#if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) || \
|
||||
@ -1273,13 +1274,11 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
|
||||
# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
|
||||
# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
|
||||
# else
|
||||
# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
|
||||
# endif
|
||||
#endif // _LIBCPP_THREAD_SAFETY_ANNOTATION
|
||||
#ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
|
||||
# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
|
||||
#else
|
||||
# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
|
||||
#endif
|
||||
|
||||
#if __has_attribute(require_constant_initialization)
|
||||
# define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
|
||||
@ -1295,12 +1294,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
|
||||
#define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
|
||||
# if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
|
||||
# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
|
||||
# define _LIBCPP_DIAGNOSE_WARNING(...) \
|
||||
__attribute__((diagnose_if(__VA_ARGS__, "warning")))
|
||||
@ -1328,14 +1321,17 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
|
||||
#define _LIBCPP_NODEBUG
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_NODEBUG_TYPE
|
||||
#if __has_attribute(__nodebug__) && \
|
||||
(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900)
|
||||
#define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug))
|
||||
#if __has_attribute(__nodebug__) && (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900)
|
||||
# define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug))
|
||||
#else
|
||||
#define _LIBCPP_NODEBUG_TYPE
|
||||
# define _LIBCPP_NODEBUG_TYPE
|
||||
#endif
|
||||
|
||||
#if __has_attribute(__standalone_debug__)
|
||||
#define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
|
||||
#else
|
||||
#define _LIBCPP_STANDALONE_DEBUG
|
||||
#endif
|
||||
#endif // !defined(_LIBCPP_NODEBUG_TYPE)
|
||||
|
||||
#if __has_attribute(__preferred_name__)
|
||||
#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
|
||||
@ -1352,11 +1348,19 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
|
||||
|
||||
#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
|
||||
#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
|
||||
#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
|
||||
#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
|
||||
#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
|
||||
#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
|
||||
#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
|
||||
#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
|
||||
|
||||
#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
|
||||
#endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
|
||||
|
||||
#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
|
||||
#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
#endif
|
||||
@ -1405,7 +1409,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
|
||||
|
||||
#ifndef _LIBCPP_NO_AUTO_LINK
|
||||
# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
# if defined(_DLL)
|
||||
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||
# pragma comment(lib, "c++.lib")
|
||||
# else
|
||||
# pragma comment(lib, "libc++.lib")
|
||||
@ -1413,8 +1417,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
|
||||
# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
#endif // _LIBCPP_NO_AUTO_LINK
|
||||
|
||||
#define _LIBCPP_UNUSED_VAR(x) ((void)(x))
|
||||
|
||||
// Configures the fopen close-on-exec mode character, if any. This string will
|
||||
// be appended to any mode string used by fstream for fopen/fdopen.
|
||||
//
|
||||
@ -1445,6 +1447,13 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
|
||||
# define _LIBCPP_INIT_PRIORITY_MAX
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define _LIBCPP_FORMAT_PRINTF(a, b) \
|
||||
__attribute__((__format__(__printf__, a, b)))
|
||||
#else
|
||||
#define _LIBCPP_FORMAT_PRINTF(a, b)
|
||||
#endif
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _LIBCPP_CONFIG
|
||||
|
||||
40
lib/libcxx/include/__config_site.in
vendored
40
lib/libcxx/include/__config_site.in
vendored
@ -1,40 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 _LIBCPP_CONFIG_SITE
|
||||
#define _LIBCPP_CONFIG_SITE
|
||||
|
||||
#cmakedefine _LIBCPP_ABI_VERSION @_LIBCPP_ABI_VERSION@
|
||||
#cmakedefine _LIBCPP_ABI_UNSTABLE
|
||||
#cmakedefine _LIBCPP_ABI_FORCE_ITANIUM
|
||||
#cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT
|
||||
#cmakedefine _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
|
||||
#cmakedefine _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
#cmakedefine _LIBCPP_HAS_NO_STDIN
|
||||
#cmakedefine _LIBCPP_HAS_NO_STDOUT
|
||||
#cmakedefine _LIBCPP_HAS_NO_THREADS
|
||||
#cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
|
||||
#cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
|
||||
#cmakedefine _LIBCPP_HAS_MUSL_LIBC
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_API_WIN32
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL
|
||||
#cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
|
||||
#cmakedefine _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
|
||||
#cmakedefine _LIBCPP_NO_VCRUNTIME
|
||||
#cmakedefine _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION @_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION@
|
||||
#cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@
|
||||
#cmakedefine _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
|
||||
#cmakedefine _LIBCPP_HAS_PARALLEL_ALGORITHMS
|
||||
#cmakedefine _LIBCPP_HAS_NO_RANDOM_DEVICE
|
||||
#cmakedefine _LIBCPP_HAS_NO_LOCALIZATION
|
||||
|
||||
@_LIBCPP_ABI_DEFINES@
|
||||
|
||||
#endif // _LIBCPP_CONFIG_SITE
|
||||
2
lib/libcxx/include/__debug
vendored
2
lib/libcxx/include/__debug
vendored
@ -270,4 +270,4 @@ _LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_DEBUG_H
|
||||
#endif // _LIBCPP_DEBUG_H
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user