diff options
Diffstat (limited to 'libcxx')
21 files changed, 139 insertions, 182 deletions
diff --git a/libcxx/include/__algorithm/copy.h b/libcxx/include/__algorithm/copy.h index ea98031..6387728 100644 --- a/libcxx/include/__algorithm/copy.h +++ b/libcxx/include/__algorithm/copy.h @@ -182,7 +182,7 @@ struct __copy_impl { } }; - template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0> + template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, 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)); @@ -192,7 +192,7 @@ struct __copy_impl { 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, + !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> operator()(_InIter __first, _InIter __last, _OutIter __result) const { diff --git a/libcxx/include/__algorithm/copy_backward.h b/libcxx/include/__algorithm/copy_backward.h index 9f89064..807c64b 100644 --- a/libcxx/include/__algorithm/copy_backward.h +++ b/libcxx/include/__algorithm/copy_backward.h @@ -170,7 +170,7 @@ struct __copy_backward_impl { 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> + template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, 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>; @@ -200,7 +200,7 @@ struct __copy_backward_impl { 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, + !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> operator()(_InIter __first, _InIter __last, _OutIter __result) const { diff --git a/libcxx/include/__algorithm/find.h b/libcxx/include/__algorithm/find.h index a7d9374..8c8cb58 100644 --- a/libcxx/include/__algorithm/find.h +++ b/libcxx/include/__algorithm/find.h @@ -149,7 +149,7 @@ struct __find_segment; template <class _SegmentedIterator, class _Tp, class _Proj, - __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0> + __enable_if_t<__is_segmented_iterator_v<_SegmentedIterator>, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator __find(_SegmentedIterator __first, _SegmentedIterator __last, const _Tp& __value, _Proj& __proj) { return std::__find_segment_if(std::move(__first), std::move(__last), __find_segment<_Tp>(__value), __proj); diff --git a/libcxx/include/__algorithm/for_each.h b/libcxx/include/__algorithm/for_each.h index 4167eec..e31fcae 100644 --- a/libcxx/include/__algorithm/for_each.h +++ b/libcxx/include/__algorithm/for_each.h @@ -39,7 +39,7 @@ __for_each(_InputIterator __first, _Sent __last, _Func& __f, _Proj& __proj) { template <class _SegmentedIterator, class _Func, class _Proj, - __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0> + __enable_if_t<__is_segmented_iterator_v<_SegmentedIterator>, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _SegmentedIterator __for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Func& __func, _Proj& __proj) { using __local_iterator_t = typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator; diff --git a/libcxx/include/__algorithm/for_each_n.h b/libcxx/include/__algorithm/for_each_n.h index 9a6c6bb..04650e1 100644 --- a/libcxx/include/__algorithm/for_each_n.h +++ b/libcxx/include/__algorithm/for_each_n.h @@ -37,8 +37,8 @@ template <class _InputIterator, class _Func, class _Proj, __enable_if_t<!__has_random_access_iterator_category<_InputIterator>::value && - _Or< _Not<__is_segmented_iterator<_InputIterator> >, - _Not<__has_random_access_local_iterator<_InputIterator> > >::value, + _Or<integral_constant<bool, !__is_segmented_iterator_v<_InputIterator> >, + _Not<__has_random_access_local_iterator<_InputIterator> > >::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator __for_each_n(_InputIterator __first, _Size __orig_n, _Func& __f, _Proj& __proj) { @@ -71,7 +71,7 @@ template <class _SegmentedIterator, class _Func, class _Proj, __enable_if_t<!__has_random_access_iterator_category<_SegmentedIterator>::value && - __is_segmented_iterator<_SegmentedIterator>::value && + __is_segmented_iterator_v<_SegmentedIterator> && __has_random_access_iterator_category< typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator>::value, int> = 0> diff --git a/libcxx/include/__algorithm/for_each_n_segment.h b/libcxx/include/__algorithm/for_each_n_segment.h index 1b522fb..a433df5 100644 --- a/libcxx/include/__algorithm/for_each_n_segment.h +++ b/libcxx/include/__algorithm/for_each_n_segment.h @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _SegmentedIterator, class _Size, class _Functor> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator __for_each_n_segment(_SegmentedIterator __first, _Size __orig_n, _Functor __func) { - static_assert(__is_segmented_iterator<_SegmentedIterator>::value && + static_assert(__is_segmented_iterator_v<_SegmentedIterator> && __has_random_access_iterator_category< typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator>::value, "__for_each_n_segment only works with segmented iterators with random-access local iterators"); diff --git a/libcxx/include/__algorithm/move.h b/libcxx/include/__algorithm/move.h index a3320e9..73b780d 100644 --- a/libcxx/include/__algorithm/move.h +++ b/libcxx/include/__algorithm/move.h @@ -65,7 +65,7 @@ struct __move_impl { } }; - template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0> + template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, 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, _MoveSegment<_InIter, _OutIter>(__result)); @@ -75,7 +75,7 @@ struct __move_impl { 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, + !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> operator()(_InIter __first, _InIter __last, _OutIter __result) const { diff --git a/libcxx/include/__algorithm/move_backward.h b/libcxx/include/__algorithm/move_backward.h index 14482fe..e3e61c7b 100644 --- a/libcxx/include/__algorithm/move_backward.h +++ b/libcxx/include/__algorithm/move_backward.h @@ -51,7 +51,7 @@ struct __move_backward_impl { 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> + template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, 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>; @@ -81,7 +81,7 @@ struct __move_backward_impl { 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, + !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> operator()(_InIter __first, _InIter __last, _OutIter __result) const { diff --git a/libcxx/include/__iterator/segmented_iterator.h b/libcxx/include/__iterator/segmented_iterator.h index af27a7b..5df9737 100644 --- a/libcxx/include/__iterator/segmented_iterator.h +++ b/libcxx/include/__iterator/segmented_iterator.h @@ -67,13 +67,13 @@ struct __segmented_iterator_traits; */ template <class _Tp, size_t = 0> -struct __has_specialization : false_type {}; +inline const bool __has_specialization_v = false; template <class _Tp> -struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {}; +inline const bool __has_specialization_v<_Tp, sizeof(_Tp) * 0> = true; template <class _Iterator> -using __is_segmented_iterator _LIBCPP_NODEBUG = __has_specialization<__segmented_iterator_traits<_Iterator> >; +inline const bool __is_segmented_iterator_v = __has_specialization_v<__segmented_iterator_traits<_Iterator> >; template <class _SegmentedIterator> struct __has_random_access_local_iterator diff --git a/libcxx/include/deque b/libcxx/include/deque index e33e7d3..395a107 100644 --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -461,9 +461,8 @@ private: __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>; public: - using __is_segmented_iterator _LIBCPP_NODEBUG = true_type; - using __segment_iterator _LIBCPP_NODEBUG = _MapPointer; - using __local_iterator _LIBCPP_NODEBUG = _Pointer; + using __segment_iterator _LIBCPP_NODEBUG = _MapPointer; + using __local_iterator _LIBCPP_NODEBUG = _Pointer; static _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_Iterator __iter) { return __iter.__m_iter_; } static _LIBCPP_HIDE_FROM_ABI __local_iterator __local(_Iterator __iter) { return __iter.__ptr_; } diff --git a/libcxx/test/libcxx/containers/sequences/deque/segmented_iterator.compile.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/segmented_iterator.compile.pass.cpp index 7ae67d8..b050da4 100644 --- a/libcxx/test/libcxx/containers/sequences/deque/segmented_iterator.compile.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/deque/segmented_iterator.compile.pass.cpp @@ -6,7 +6,9 @@ // //===----------------------------------------------------------------------===// +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + #include <deque> using DequeIterator = typename std::deque<int>::iterator; -static_assert(std::__is_segmented_iterator<DequeIterator>::value, ""); +static_assert(std::__is_segmented_iterator_v<DequeIterator>, ""); diff --git a/libcxx/test/libcxx/containers/sequences/forwardlist/bool-conversion.pass.cpp b/libcxx/test/libcxx/containers/sequences/forwardlist/bool-conversion.pass.cpp deleted file mode 100644 index 237b0f1..0000000 --- a/libcxx/test/libcxx/containers/sequences/forwardlist/bool-conversion.pass.cpp +++ /dev/null @@ -1,37 +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 -// -//===----------------------------------------------------------------------===// - -// REQUIRES: std-at-least-c++20 - -// <forward_list> - -// This test shows the effect of implementing `LWG4135`, before it this code -// was ill-formed, as the predicate is not bool. `LWG4135` suggests that -// std::erase explicitly specifying the lambda's return type as bool. - -#include <forward_list> - -struct Bool { - Bool() = default; - Bool(const Bool&) = delete; - operator bool() const { return true; } -}; - -struct Int { - Bool& operator==(Int) const { - static Bool b; - return b; - } -}; - -int main(int, char**) { - std::forward_list<Int> l; - std::erase(l, Int{}); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp deleted file mode 100644 index 9e3fb88..0000000 --- a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp +++ /dev/null @@ -1,56 +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 -// -//===----------------------------------------------------------------------===// - -// <vector> - -// template <class InputIter> vector(InputIter first, InputIter last); - -#include <vector> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -void test_ctor_under_alloc() { - int arr1[] = {42}; - int arr2[] = {1, 101, 42}; - { - typedef std::vector<int, cpp03_allocator<int> > C; - typedef C::allocator_type Alloc; - { - Alloc::construct_called = false; - C v(arr1, arr1 + 1); - assert(Alloc::construct_called); - } - { - Alloc::construct_called = false; - C v(arr2, arr2 + 3); - assert(Alloc::construct_called); - } - } - { - typedef std::vector<int, cpp03_overload_allocator<int> > C; - typedef C::allocator_type Alloc; - { - Alloc::construct_called = false; - C v(arr1, arr1 + 1); - assert(Alloc::construct_called); - } - { - Alloc::construct_called = false; - C v(arr2, arr2 + 3); - assert(Alloc::construct_called); - } - } -} - -int main(int, char**) { - test_ctor_under_alloc(); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp deleted file mode 100644 index fa1bd2d..0000000 --- a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp +++ /dev/null @@ -1,59 +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 -// -//===----------------------------------------------------------------------===// - -// <vector> - -// template <class InputIter> vector(InputIter first, InputIter last, -// const allocator_type& a); - -#include <vector> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -void test_ctor_under_alloc() { - int arr1[] = {42}; - int arr2[] = {1, 101, 42}; - { - typedef std::vector<int, cpp03_allocator<int> > C; - typedef C::allocator_type Alloc; - Alloc a; - { - Alloc::construct_called = false; - C v(arr1, arr1 + 1, a); - assert(Alloc::construct_called); - } - { - Alloc::construct_called = false; - C v(arr2, arr2 + 3, a); - assert(Alloc::construct_called); - } - } - { - typedef std::vector<int, cpp03_overload_allocator<int> > C; - typedef C::allocator_type Alloc; - Alloc a; - { - Alloc::construct_called = false; - C v(arr1, arr1 + 1, a); - assert(Alloc::construct_called); - } - { - Alloc::construct_called = false; - C v(arr2, arr2 + 3, a); - assert(Alloc::construct_called); - } - } -} - -int main(int, char**) { - test_ctor_under_alloc(); - - return 0; -} diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.join/segmented_iterator.compile.pass.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.join/segmented_iterator.compile.pass.cpp index 6cd17c2..4e4074f 100644 --- a/libcxx/test/libcxx/ranges/range.adaptors/range.join/segmented_iterator.compile.pass.cpp +++ b/libcxx/test/libcxx/ranges/range.adaptors/range.join/segmented_iterator.compile.pass.cpp @@ -14,4 +14,4 @@ using JoinView = decltype(std::views::join(std::declval<std::vector<std::vector<int>>&>())); using JoinIter = std::ranges::iterator_t<JoinView>; -static_assert(std::__is_segmented_iterator<JoinIter>::value); +static_assert(std::__is_segmented_iterator_v<JoinIter>); diff --git a/libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm b/libcxx/test/std/containers/associative/map/find.modules.compile.pass.mm index 82b1c494..82b1c494 100644 --- a/libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm +++ b/libcxx/test/std/containers/associative/map/find.modules.compile.pass.mm diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp index 86d7769..3031276 100644 --- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp +++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp @@ -69,6 +69,25 @@ TEST_CONSTEXPR_CXX26 bool test() { test<std::forward_list<long>>(); test<std::forward_list<double>>(); + { // Ensure that the result of operator== is converted to bool + // See LWG4135. + struct Bool { + Bool() = default; + Bool(const Bool&) = delete; + operator bool() const { return true; } + }; + + struct Int { + Bool& operator==(Int) const { + static Bool b; + return b; + } + }; + + std::forward_list<Int> l; + std::erase(l, Int{}); + } + return true; } diff --git a/libcxx/test/libcxx/containers/sequences/vector/erase.modules.compile.pass.mm b/libcxx/test/std/containers/sequences/vector/erase.modules.compile.pass.mm index d270673..d270673 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/erase.modules.compile.pass.mm +++ b/libcxx/test/std/containers/sequences/vector/erase.modules.compile.pass.mm diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp index bac2ea2..6549735 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp @@ -127,9 +127,9 @@ TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() { } void test_ctor_under_alloc() { -#if TEST_STD_VER >= 11 int arr1[] = {42}; int arr2[] = {1, 101, 42}; +#if TEST_STD_VER >= 11 { using C = TCT::vector<>; using It = forward_iterator<int*>; @@ -155,6 +155,35 @@ void test_ctor_under_alloc() { } } #endif + // FIXME: This is mostly the same test as above, just worse. They should be merged. + { + typedef std::vector<int, cpp03_allocator<int> > C; + typedef C::allocator_type Alloc; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3); + assert(Alloc::construct_called); + } + } + { + typedef std::vector<int, cpp03_overload_allocator<int> > C; + typedef C::allocator_type Alloc; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3); + assert(Alloc::construct_called); + } + } } // In C++03, you can't instantiate a template with a local type. diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp index de32504..019f427 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp @@ -141,9 +141,9 @@ TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() { } void test_ctor_under_alloc() { -#if TEST_STD_VER >= 11 int arr1[] = {42}; int arr2[] = {1, 101, 42}; +#if TEST_STD_VER >= 11 { using C = TCT::vector<>; using It = forward_iterator<int*>; @@ -173,6 +173,37 @@ void test_ctor_under_alloc() { } } #endif + // FIXME: This is mostly the same test as above, just worse. They should be merged. + { + typedef std::vector<int, cpp03_allocator<int> > C; + typedef C::allocator_type Alloc; + Alloc a; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1, a); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3, a); + assert(Alloc::construct_called); + } + } + { + typedef std::vector<int, cpp03_overload_allocator<int> > C; + typedef C::allocator_type Alloc; + Alloc a; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1, a); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3, a); + assert(Alloc::construct_called); + } + } } TEST_CONSTEXPR_CXX20 bool test() { diff --git a/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp b/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp index 4e24dbe..678483b 100644 --- a/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp +++ b/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp @@ -15,6 +15,7 @@ #include <concepts> #include <iterator> #include <ranges> +#include <sstream> #include <type_traits> #include <utility> @@ -45,7 +46,10 @@ constexpr bool test(CPO& o, Args&&...) { int a[10]; int arrays[10][10]; -//std::pair<int, int> pairs[10]; +std::pair<int, int> pairs[10]; +#ifndef TEST_HAS_NO_LOCALIZATION +std::istringstream stream; +#endif // [concept.swappable] static_assert(test(std::ranges::swap, a, a)); @@ -81,25 +85,50 @@ static_assert(test(std::ranges::ssize, a)); // views::empty<T> is not a CPO static_assert(test(std::views::iota, 1)); static_assert(test(std::views::iota, 1, 10)); -//static_assert(test(std::views::istream<int>, 1); +#ifndef TEST_HAS_NO_LOCALIZATION +static_assert(test(std::views::istream<int>, stream)); +#endif static_assert(test(std::views::single, 4)); +#if TEST_STD_VER >= 23 +static_assert(test(std::views::repeat, 1)); +#endif + // [range.adaptors] static_assert(test(std::views::all, a)); static_assert(test(std::views::common, a)); static_assert(test(std::views::counted, a, 10)); static_assert(test(std::views::drop, a, 10)); -//static_assert(test(std::views::drop_while, a, [](int x){ return x < 10; })); -//static_assert(test(std::views::elements<0>, pairs)); +static_assert(test(std::views::drop_while, a, [](int x) { return x < 10; })); +static_assert(test(std::views::elements<0>, pairs)); static_assert(test(std::views::filter, a, [](int x) { return x < 10; })); static_assert(test(std::views::join, arrays)); -//static_assert(test(std::views::split, a, 4)); +static_assert(test(std::views::keys, pairs)); static_assert(test(std::views::lazy_split, a, 4)); static_assert(test(std::views::reverse, a)); +static_assert(test(std::views::split, a, 4)); static_assert(test(std::views::take, a, 10)); -//static_assert(test(std::views::take_while, a, [](int x){ return x < 10; })); +static_assert(test(std::views::take_while, a, [](int x) { return x < 10; })); static_assert(test(std::views::transform, a, [](int x) { return x + 1; })); +static_assert(test(std::views::values, pairs)); #if TEST_STD_VER >= 23 +// static_assert(test(std::views::adjacent_transform<2>, [](int x, int y) { return x + y; }, a)); +// static_assert(test(std::views::adjacent<2>, a)); +// static_assert(test(std::views::as_const, a)); +static_assert(test(std::views::as_rvalue, a)); +// static_assert(test(std::views::cartesian_product, a, a, a)); +static_assert(test(std::views::chunk_by, a, [](int x, int y) { return x < y; })); +// static_assert(test(std::views::chunk, a, 1)); +// static_assert(test(std::views::enumerate, a)); +static_assert(test(std::views::join_with, 1)); +// static_assert(test(std::views::stride, a, 1)); static_assert(test(std::views::zip_transform, [](int x, int y) { return x + y; }, a, a)); +static_assert(test(std::views::zip, a, a)); +#endif + +#if TEST_STD_VER >= 26 +// static_assert(test(std::views::cache_latest, a)); +// static_assert(test(std::views::concat, a, a)); +// static_assert(test(std::views::to_input, a)); #endif |