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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
10 changes: 5 additions & 5 deletions libcxx/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ AllowAllParametersOfDeclarationOnNextLine: true
AllowShortFunctionsOnASingleLine: true
AllowShortLambdasOnASingleLine: All
AttributeMacros: [
'_ALIGNAS_TYPE',
'_ALIGNAS',
'_LIBCPP_ALIGNOF',
'alignas',
'alignas',
'alignof',
'_LIBCPP_ALWAYS_INLINE',
'_LIBCPP_CONSTEXPR_SINCE_CXX14',
'_LIBCPP_CONSTEXPR_SINCE_CXX17',
'_LIBCPP_CONSTEXPR_SINCE_CXX20',
'_LIBCPP_CONSTEXPR_SINCE_CXX23',
'_LIBCPP_CONSTEXPR',
'constexpr',
'_LIBCPP_CONSTINIT',
'_LIBCPP_DEPRECATED_IN_CXX11',
'_LIBCPP_DEPRECATED_IN_CXX14',
Expand All @@ -47,7 +47,7 @@ AttributeMacros: [
'_LIBCPP_NOALIAS',
'_LIBCPP_NODISCARD_EXT',
'_LIBCPP_NODISCARD',
'_LIBCPP_NORETURN',
'[[noreturn]]',
'_LIBCPP_OVERRIDABLE_FUNC_VIS',
'_LIBCPP_STANDALONE_DEBUG',
'_LIBCPP_TEMPLATE_DATA_VIS',
Expand Down
2 changes: 0 additions & 2 deletions libcxx/cmake/caches/Generic-cxx03.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion libcxx/docs/TestingLibcxx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ that. However, you can manually specify the option like so if you want:
.. code-block:: bash

$ libcxx/utils/libcxx-lit <build> -sv libcxx/test/std/containers # Run the tests with the newest -std
$ libcxx/utils/libcxx-lit <build> -sv libcxx/test/std/containers --param std=c++03 # Run the tests in C++03
$ libcxx/utils/libcxx-lit <build> -sv libcxx/test/std/containers --param std=c++11 # Run the tests in C++11

Other parameters are supported by the test suite. Those are defined in ``libcxx/utils/libcxx/test/params.py``.
If you want to customize how to run the libc++ test suite beyond what is available
Expand Down
70 changes: 30 additions & 40 deletions libcxx/include/__algorithm/copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIte

template <class _AlgPolicy>
struct __copy_loop {
template <class _InIter, class _Sent, class _OutIter>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
operator()(_InIter __first, _Sent __last, _OutIter __result) const {
while (__first != __last) {
*__result = *__first;
++__first;
++__result;
}

return std::make_pair(std::move(__first), std::move(__result));
}

template <class _InIter, class _OutIter>
struct _CopySegment {
using _Traits = __segmented_iterator_traits<_InIter>;
Expand All @@ -59,38 +47,40 @@ struct __copy_loop {
}
};

template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
std::__for_each_segment(__first, __last, _CopySegment<_InIter, _OutIter>(__result));
return std::make_pair(__last, std::move(__result));
}

template <class _InIter,
class _OutIter,
__enable_if_t<__has_random_access_iterator_category<_InIter>::value &&
!__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
int> = 0>
template <class _InIter, class _Sent, class _OutIter>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
using _Traits = __segmented_iterator_traits<_OutIter>;
using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;

if (__first == __last)
return std::make_pair(std::move(__first), std::move(__result));

auto __local_first = _Traits::__local(__result);
auto __segment_iterator = _Traits::__segment(__result);
while (true) {
auto __local_last = _Traits::__end(__segment_iterator);
auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
auto __iters = std::__copy<_AlgPolicy>(__first, __first + __size, __local_first);
__first = std::move(__iters.first);
operator()(_InIter __first, _Sent __last, _OutIter __result) const {
if constexpr (__is_segmented_iterator<_InIter>::value) {
std::__for_each_segment(__first, __last, _CopySegment<_InIter, _OutIter>(__result));
return std::make_pair(__last, std::move(__result));
} else if constexpr (__has_random_access_iterator_category<_InIter>::value && __is_segmented_iterator<_OutIter>::value) {
using _Traits = __segmented_iterator_traits<_OutIter>;
using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;

if (__first == __last)
return std::make_pair(std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.second)));
return std::make_pair(std::move(__first), std::move(__result));

auto __local_first = _Traits::__local(__result);
auto __segment_iterator = _Traits::__segment(__result);
while (true) {
auto __local_last = _Traits::__end(__segment_iterator);
auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
auto __iters = std::__copy<_AlgPolicy>(__first, __first + __size, __local_first);
__first = std::move(__iters.first);

if (__first == __last)
return std::make_pair(std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.second)));

__local_first = _Traits::__begin(++__segment_iterator);
}
} else {
while (__first != __last) {
*__result = *__first;
++__first;
++__result;
}

__local_first = _Traits::__begin(++__segment_iterator);
return std::make_pair(std::move(__first), std::move(__result));
}
}
};
Expand Down
111 changes: 51 additions & 60 deletions libcxx/include/__algorithm/copy_backward.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,71 +37,62 @@ struct __copy_backward_loop {
template <class _InIter, class _Sent, class _OutIter>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
operator()(_InIter __first, _Sent __last, _OutIter __result) const {
auto __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
auto __original_last_iter = __last_iter;
if constexpr (__is_segmented_iterator<_InIter>::value) {
using _Traits = __segmented_iterator_traits<_InIter>;
auto __sfirst = _Traits::__segment(__first);
auto __slast = _Traits::__segment(__last);
if (__sfirst == __slast) {
auto __iters =
std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
return std::make_pair(__last, __iters.second);
}

while (__first != __last_iter) {
*--__result = *--__last_iter;
}

return std::make_pair(std::move(__original_last_iter), std::move(__result));
}

template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
using _Traits = __segmented_iterator_traits<_InIter>;
auto __sfirst = _Traits::__segment(__first);
auto __slast = _Traits::__segment(__last);
if (__sfirst == __slast) {
auto __iters =
std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
return std::make_pair(__last, __iters.second);
}

__result =
std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__local(__last), std::move(__result))
.second;
--__slast;
while (__sfirst != __slast) {
__result =
std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__end(__slast), std::move(__result))
std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__local(__last), std::move(__result))
.second;
--__slast;
}
__result = std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__slast), std::move(__result))
.second;
return std::make_pair(__last, std::move(__result));
}

template <class _InIter,
class _OutIter,
__enable_if_t<__has_random_access_iterator_category<_InIter>::value &&
!__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
operator()(_InIter __first, _InIter __last, _OutIter __result) const {
using _Traits = __segmented_iterator_traits<_OutIter>;
auto __orig_last = __last;
auto __segment_iterator = _Traits::__segment(__result);

// When the range contains no elements, __result might not be a valid iterator
if (__first == __last)
return std::make_pair(__first, __result);

auto __local_last = _Traits::__local(__result);
while (true) {
using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;

auto __local_first = _Traits::__begin(__segment_iterator);
auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
auto __iter = std::__copy_backward<_AlgPolicy>(__last - __size, __last, __local_last).second;
__last -= __size;

while (__sfirst != __slast) {
__result =
std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__end(__slast), std::move(__result))
.second;
--__slast;
}
__result = std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__slast), std::move(__result))
.second;
return std::make_pair(__last, std::move(__result));
} else if constexpr (__has_random_access_iterator_category<_InIter>::value &&
__is_segmented_iterator<_OutIter>::value) {
using _Traits = __segmented_iterator_traits<_OutIter>;
auto __orig_last = __last;
auto __segment_iterator = _Traits::__segment(__result);

// When the range contains no elements, __result might not be a valid iterator
if (__first == __last)
return std::make_pair(std::move(__orig_last), _Traits::__compose(__segment_iterator, std::move(__iter)));
--__segment_iterator;
__local_last = _Traits::__end(__segment_iterator);
return std::make_pair(__first, __result);

auto __local_last = _Traits::__local(__result);
while (true) {
using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;

auto __local_first = _Traits::__begin(__segment_iterator);
auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
auto __iter = std::__copy_backward<_AlgPolicy>(__last - __size, __last, __local_last).second;
__last -= __size;

if (__first == __last)
return std::make_pair(std::move(__orig_last), _Traits::__compose(__segment_iterator, std::move(__iter)));
--__segment_iterator;
__local_last = _Traits::__end(__segment_iterator);
}
} else {
auto __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
auto __original_last_iter = __last_iter;

while (__first != __last_iter) {
*--__result = *--__last_iter;
}

return std::make_pair(std::move(__original_last_iter), std::move(__result));
}
}
};
Expand Down
28 changes: 9 additions & 19 deletions libcxx/include/__algorithm/copy_move_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,17 @@ struct __can_rewrap<_InIter,
__enable_if_t< is_copy_constructible<_InIter>::value &&
is_copy_constructible<_OutIter>::value > > : true_type {};

template <class _Algorithm,
class _InIter,
class _Sent,
class _OutIter,
__enable_if_t<__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
__unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) {
auto __range = std::__unwrap_range(__first, std::move(__last));
auto __result = _Algorithm()(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__out_first));
return std::make_pair(std::__rewrap_range<_Sent>(std::move(__first), std::move(__result.first)),
std::__rewrap_iter(std::move(__out_first), std::move(__result.second)));
}

template <class _Algorithm,
class _InIter,
class _Sent,
class _OutIter,
__enable_if_t<!__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0>
template <class _Algorithm, class _InIter, class _Sent, class _OutIter>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
__unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) {
return _Algorithm()(std::move(__first), std::move(__last), std::move(__out_first));
if constexpr (__can_rewrap<_InIter, _Sent, _OutIter>::value) {
auto __range = std::__unwrap_range(__first, std::move(__last));
auto __result = _Algorithm()(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__out_first));
return std::make_pair(std::__rewrap_range<_Sent>(std::move(__first), std::move(__result.first)),
std::__rewrap_iter(std::move(__out_first), std::move(__result.second)));
} else {
return _Algorithm()(std::move(__first), std::move(__last), std::move(__out_first));
}
}

template <class _AlgPolicy,
Expand Down
30 changes: 8 additions & 22 deletions libcxx/include/__algorithm/copy_n.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
_LIBCPP_BEGIN_NAMESPACE_STD

template<class _InputIterator, class _Size, class _OutputIterator>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
__has_input_iterator_category<_InputIterator>::value &&
!__has_random_access_iterator_category<_InputIterator>::value,
_OutputIterator
>::type
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
{
if constexpr (__has_random_access_iterator_category<_InputIterator>::value) {
typedef typename iterator_traits<_InputIterator>::difference_type difference_type;
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
return _VSTD::copy(__first, __first + difference_type(__n), __result);
} else {
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
if (__n > 0)
Expand All @@ -45,21 +45,7 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
}
}
return __result;
}

template<class _InputIterator, class _Size, class _OutputIterator>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
__has_random_access_iterator_category<_InputIterator>::value,
_OutputIterator
>::type
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
{
typedef typename iterator_traits<_InputIterator>::difference_type difference_type;
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
return _VSTD::copy(__first, __first + difference_type(__n), __result);
}
}

_LIBCPP_END_NAMESPACE_STD
Expand Down
22 changes: 5 additions & 17 deletions libcxx/include/__algorithm/fill.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag)
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
if constexpr (__has_random_access_iterator_category<_ForwardIterator>::value) {
_VSTD::fill_n(__first, __last - __first, __value);
} else {
for (; __first != __last; ++__first)
*__first = __value;
}

template <class _RandomAccessIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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_SINCE_CXX20
void
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
_VSTD::__fill(__first, __last, __value, typename iterator_traits<_ForwardIterator>::iterator_category());
}
}

_LIBCPP_END_NAMESPACE_STD
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__algorithm/find.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ template <class _Tp,
class _Up,
class _Proj,
__enable_if_t<__is_identity<_Proj>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value &&
sizeof(_Tp) == sizeof(wchar_t) && _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t),
sizeof(_Tp) == sizeof(wchar_t) && alignof(_Tp) >= alignof(wchar_t),
int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp*
__find_impl(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) {
Expand Down
Loading