From patchwork Mon Oct 17 20:09:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 3696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1622874wrs; Mon, 17 Oct 2022 13:10:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4FLq+xjI7+AnKgJ/0gz4biAevFkvk/GbRSjjJr+i5yQiF0CbpORaAYsbYbQH2lsoSS9e5z X-Received: by 2002:a17:907:94c9:b0:78d:3544:ff0a with SMTP id dn9-20020a17090794c900b0078d3544ff0amr9973003ejc.386.1666037444508; Mon, 17 Oct 2022 13:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666037444; cv=none; d=google.com; s=arc-20160816; b=avvjS6RIPtSY1vGjIbTZ0m1/QMwFvVD7uxIcj1uUX780a4vz1c1mxaS7FmASytKt0L X16jfOyJWQJS61yD6RJLNNaHklFPNpujNYlivKHDlEYoT7OcSJ46awcEocIEHknMPhQc 1d8f/mcGMJkyh/t1rGiT9fpDQKQKArn1edBmJMvcl2bgO29skhBQcTZf20u2SmAvCkHJ OduTxXn1wC4ZKlbbDqY/B/DAdbSzrsEnE+u0pmxY0hogjpzYhB2sllIxcKGf6DP3Nxig ihNI4PW7xJheKX5ncqv8n/fjVEl7m+RbRC1+vv4JjCnDLM+CUJ3olHAJjj5qYZEmR13E /nxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Dbk004cP02SPg+QQFc1Hs5uzIZ6EwzxQB1vuff29HCY=; b=OnqlCyCO9kTYxvM0AEV8yBn2PBBYv0AEN0IblWaecaxCgPpICWHlgX01kQp/nhLnjh 7zRZjGFAfNz1MG+spKgMu1SSGsFlKHn/g3bz6dV0eCBqc7kNODrN2ZdmCazgzP1HW1N4 dtuCe4C6VAnrjYK2sfSNTYsE3eqm0LWTWhXgbQBB7OKHj4tld0nW4kGYpax+TzTasHfI y2DhFLnapFRkSTglS4JD4VTacCf1vxjpAJQOftgKCTihPoxGguG+aZy6Ds+9t05gclk0 Kw/TCQORny7aYXV9I7ch9PnyxAVn3qZUCA3NmACrvI9nM+cOf5zKQyJDhzpx7KmC/7mM M7Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fHZPKql2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h16-20020a170906261000b0077156c9124esi8743402ejc.1001.2022.10.17.13.10.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:10:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fHZPKql2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50A123857010 for ; Mon, 17 Oct 2022 20:10:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50A123857010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666037426; bh=Dbk004cP02SPg+QQFc1Hs5uzIZ6EwzxQB1vuff29HCY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=fHZPKql2qfyKoylcoRuQcEk4GAzF10G06GXuf22pRYiYyqjEQF/bOi42ULm39Y3Rj hXcHuib5gfCc0L6GE03pZ761MAAvJGndf3Ka+XgaMicEXvdYA7QUTgiislfC4Kc2n4 U5m6YzlFR/Hlk/dp4iM4KJ1/zWG9ZO+2GZhYNBNg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 1700F3858406 for ; Mon, 17 Oct 2022 20:09:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1700F3858406 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-318-zRFsQklDOCGmvmsU9JjGXg-1; Mon, 17 Oct 2022 16:09:31 -0400 X-MC-Unique: zRFsQklDOCGmvmsU9JjGXg-1 Received: by mail-qv1-f72.google.com with SMTP id dh7-20020ad458c7000000b004b1c8f7205eso7366289qvb.5 for ; Mon, 17 Oct 2022 13:09:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Dbk004cP02SPg+QQFc1Hs5uzIZ6EwzxQB1vuff29HCY=; b=aBOBDUMbc328ml1TL1zD3M9GUdUv+vkNz6A58FakEPZGmKOZbN4EUVDbeREyZdHaeZ BuRUh+W+bQ20mUVW6cUWEa24mD8B+uOhoBCOKFBFZysaFYD9xlqPwO+L2DY78P9NCkfT +rD4ULtv7Q1MoJg3CsXtOcmYJgMB9OMo0qQqpafFcRmvLZCOeNl7ZvTL4OfTryCEZR98 mbMk1MJgdIuTBX8ujukkZGgg5WhfiY3sIHdQGZCjZCS5/cAzZgJKeLUMpTXavDwLb+cf sSbY0sVwAf0Xa/uR04/M10xKH0t+WprITypljVFBwxpBL8JZqXog4ZTUmy2IfhIQI/t6 Wuqg== X-Gm-Message-State: ACrzQf0g6lH6cKdSxknZkcvxGY4bglpXJl1KbB551aYxV249iP8mBTvj 3W2IyHh/0bePlCaHEtiSxX/zYRh3c0kn41arSYJr54SuHizxZ3TMe5LHj5UahR7IJByzS2Gsr61 rvNVkMphF00Y0TFzSeQaiGt4MKjnhz4CGq4coj1iwl8Nu37/LJXYIfMZyFWN7hy3sd94= X-Received: by 2002:a37:b88:0:b0:6ec:5329:2948 with SMTP id 130-20020a370b88000000b006ec53292948mr8930539qkl.7.1666037370631; Mon, 17 Oct 2022 13:09:30 -0700 (PDT) X-Received: by 2002:a37:b88:0:b0:6ec:5329:2948 with SMTP id 130-20020a370b88000000b006ec53292948mr8930503qkl.7.1666037370187; Mon, 17 Oct 2022 13:09:30 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id j6-20020a05620a288600b006ced196a73fsm493253qkp.135.2022.10.17.13.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:09:29 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Implement ranges::stride_view from P1899R3 Date: Mon, 17 Oct 2022 16:09:26 -0400 Message-Id: <20221017200926.1230070-1-ppalka@redhat.com> X-Mailer: git-send-email 2.38.0.68.ge85701b4af MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Cc: libstdc++@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746966879471115176?= X-GMAIL-MSGID: =?utf-8?q?1746966879471115176?= Tested on x86_64-pc-linux-gnu, does this look OK for trunk? libstdc++-v3/ChangeLog: * include/std/ranges (stride_view): Define. (stride_view::_Iterator): Define. (views::__detail::__can_stride_view): Define. (views::_Stride, views::stride): Define. * testsuite/std/ranges/adaptors/stride/1.cc: New test. --- libstdc++-v3/include/std/ranges | 351 ++++++++++++++++++ .../testsuite/std/ranges/adaptors/stride/1.cc | 73 ++++ 2 files changed, 424 insertions(+) create mode 100644 libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 5857d426a66..d113cf19dc7 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -7566,6 +7566,357 @@ namespace views::__adaptor inline constexpr _Repeat repeat; } + + template + requires view<_Vp> + class stride_view : public view_interface> + { + _Vp _M_base; + range_difference_t<_Vp> _M_stride; + + template using _Base = __detail::__maybe_const_t<_Const, _Vp>; + + template + struct __iter_cat + { }; + + template + requires forward_range<_Base<_Const>> + struct __iter_cat<_Const> + { + private: + static auto + _S_iter_cat() + { + using _Cat = typename iterator_traits>>::iterator_category; + if constexpr (derived_from<_Cat, random_access_iterator_tag>) + return random_access_iterator_tag{}; + else + return _Cat{}; + } + public: + using iterator_category = decltype(_S_iter_cat()); + }; + + template class _Iterator; + + public: + constexpr explicit + stride_view(_Vp __base, range_difference_t<_Vp> __stride) + : _M_base(std::move(__base)), _M_stride(__stride) + { __glibcxx_assert(__stride > 0); } + + constexpr _Vp + base() const& requires copy_constructible<_Vp> + { return _M_base; } + + constexpr _Vp + base() && + { return std::move(_M_base); } + + constexpr range_difference_t<_Vp> + stride() const noexcept + { return _M_stride; } + + constexpr auto + begin() requires (!__detail::__simple_view<_Vp>) + { return _Iterator(this, ranges::begin(_M_base)); } + + constexpr auto + begin() const requires range + { return _Iterator(this, ranges::begin(_M_base)); } + + constexpr auto + end() requires (!__detail::__simple_view<_Vp>) + { + if constexpr (common_range<_Vp> && sized_range<_Vp> && forward_range<_Vp>) + { + auto __missing = (_M_stride - ranges::distance(_M_base) % _M_stride) % _M_stride; + return _Iterator(this, ranges::end(_M_base), __missing); + } + else if constexpr (common_range<_Vp> && !bidirectional_range<_Vp>) + return _Iterator(this, ranges::end(_M_base)); + else + return default_sentinel; + } + + constexpr auto + end() const requires range + { + if constexpr (common_range && sized_range + && forward_range) + { + auto __missing = (_M_stride - ranges::distance(_M_base) % _M_stride) % _M_stride; + return _Iterator(this, ranges::end(_M_base), __missing); + } + else if constexpr (common_range && !bidirectional_range) + return _Iterator(this, ranges::end(_M_base)); + else + return default_sentinel; + } + + constexpr auto + size() requires sized_range<_Vp> + { + return __detail::__to_unsigned_like + (__detail::__div_ceil(ranges::distance(_M_base), _M_stride)); + } + + constexpr auto + size() const requires sized_range + { + return __detail::__to_unsigned_like + (__detail::__div_ceil(ranges::distance(_M_base), _M_stride)); + } + }; + + template + stride_view(_Range&&, range_difference_t<_Range>) -> stride_view>; + + template + inline constexpr bool enable_borrowed_range> + = enable_borrowed_range<_Vp>; + + template + requires view<_Vp> + template + class stride_view<_Vp>::_Iterator : public __iter_cat<_Const> + { + using _Parent = __detail::__maybe_const_t<_Const, stride_view>; + using _Base = stride_view::_Base<_Const>; + + iterator_t<_Base> _M_current = iterator_t<_Base>(); + sentinel_t<_Base> _M_end = sentinel_t<_Base>(); + range_difference_t<_Base> _M_stride = 0; + range_difference_t<_Base> _M_missing = 0; + + constexpr + _Iterator(_Parent* __parent, iterator_t<_Base> __current, + range_difference_t<_Base> __missing = 0) + : _M_current(std::move(__current)), _M_end(ranges::end(__parent->_M_base)), + _M_stride(__parent->_M_stride), _M_missing(__missing) + { } + + static auto + _S_iter_concept() + { + if constexpr (random_access_range<_Base>) + return random_access_iterator_tag{}; + else if constexpr (bidirectional_range<_Base>) + return bidirectional_iterator_tag{}; + else if constexpr (forward_range<_Base>) + return forward_iterator_tag{}; + else + return input_iterator_tag{}; + } + + friend stride_view; + + public: + using difference_type = range_difference_t<_Base>; + using value_type = range_value_t<_Base>; + using iterator_concept = decltype(_S_iter_concept()); + // iterator_category defined in stride_view::__iter_cat + + _Iterator() requires default_initializable> = default; + + constexpr + _Iterator(_Iterator __other) + requires _Const + && convertible_to, iterator_t<_Base>> + && convertible_to, sentinel_t<_Base>> + : _M_current(std::move(__other._M_current)), _M_end(std::move(__other._M_end)), + _M_stride(__other._M_stride), _M_missing(__other._M_missing) + { } + + constexpr iterator_t<_Base> + base() && + { return std::move(_M_current); } + + constexpr const iterator_t<_Base>& + base() const & noexcept + { return _M_current; } + + constexpr decltype(auto) + operator*() const + { return *_M_current; } + + constexpr _Iterator& + operator++() + { + __glibcxx_assert(_M_current != _M_end); + _M_missing = ranges::advance(_M_current, _M_stride, _M_end); + return *this; + } + + constexpr void + operator++(int) + { ++*this; } + + constexpr _Iterator + operator++(int) requires forward_range<_Base> + { + auto __tmp = *this; + ++*this; + return __tmp; + } + + constexpr _Iterator& + operator--() requires bidirectional_range<_Base> + { + ranges::advance(_M_current, _M_missing - _M_stride); + _M_missing = 0; + return *this; + } + + constexpr _Iterator + operator--(int) requires bidirectional_range<_Base> + { + auto __tmp = *this; + --*this; + return __tmp; + } + + constexpr _Iterator& + operator+=(difference_type __n) requires random_access_range<_Base> + { + if (__n > 0) + { + __glibcxx_assert(ranges::distance(_M_current, _M_end) > _M_stride * (__n - 1)); + _M_missing = ranges::advance(_M_current, _M_stride * __n, _M_end); + } + else if (__n < 0) + { + ranges::advance(_M_current, _M_stride * __n + _M_missing); + _M_missing = 0; + } + return *this; + } + + constexpr _Iterator& + operator-=(difference_type __n) requires random_access_range<_Base> + { return *this += -__n; } + + constexpr decltype(auto) operator[](difference_type __n) const + requires random_access_range<_Base> + { return *(*this + __n); } + + friend constexpr bool + operator==(const _Iterator& __x, default_sentinel_t) + { return __x._M_current == __x._M_end; } + + friend constexpr bool + operator==(const _Iterator& __x, const _Iterator& __y) + requires equality_comparable> + { return __x._M_current == __y._M_current; } + + friend constexpr bool + operator<(const _Iterator& __x, const _Iterator& __y) + requires random_access_range<_Base> + { return __x._M_current < __y._M_current; } + + friend constexpr bool + operator>(const _Iterator& __x, const _Iterator& __y) + requires random_access_range<_Base> + { return __y._M_current < __x._M_current; } + + friend constexpr bool + operator<=(const _Iterator& __x, const _Iterator& __y) + requires random_access_range<_Base> + { return !(__y._M_current < __x._M_current); } + + friend constexpr bool + operator>=(const _Iterator& __x, const _Iterator& __y) + requires random_access_range<_Base> + { return !(__x._M_current < __y._M_current); } + + friend constexpr auto + operator<=>(const _Iterator& __x, const _Iterator& __y) + requires random_access_range<_Base> && three_way_comparable> + { return __x._M_current <=> __y._M_current; } + + friend constexpr _Iterator + operator+(const _Iterator& __i, difference_type __n) + requires random_access_range<_Base> + { + auto __r = __i; + __r += __n; + return __r; + } + + friend constexpr _Iterator + operator+(difference_type __n, const _Iterator& __i) + requires random_access_range<_Base> + { return __i + __n; } + + friend constexpr _Iterator + operator-(const _Iterator& __i, difference_type __n) + requires random_access_range<_Base> + { + auto __r = __i; + __r -= __n; + return __r; + } + + friend constexpr difference_type + operator-(const _Iterator& __x, const _Iterator& __y) + requires sized_sentinel_for, iterator_t<_Base>> + { + auto __n = __x._M_current - __y._M_current; + if constexpr (forward_range<_Base>) + return (__n + __x._M_missing - __y._M_missing) / __x._M_stride; + else if (__n < 0) + return -__detail::__div_ceil(-__n, __x._M_stride); + else + return __detail::__div_ceil(__n, __x._M_stride); + } + + friend constexpr difference_type + operator-(default_sentinel_t __y, const _Iterator& __x) + requires sized_sentinel_for, iterator_t<_Base>> + { return __detail::__div_ceil(__x._M_end, __x._M_current, __x._M_stride); } + + friend constexpr difference_type + operator-(const _Iterator& __x, default_sentinel_t __y) + requires sized_sentinel_for, iterator_t<_Base>> + { return -(__y - __x); } + + friend constexpr range_rvalue_reference_t<_Base> + iter_move(const _Iterator& __i) + noexcept(noexcept(ranges::iter_move(__i._M_current))) + { return ranges::iter_move(__i._M_current); } + + friend constexpr void + iter_swap(const _Iterator& __x, const _Iterator& __y) + noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current))) + requires indirectly_swappable> + { ranges::iter_swap(__x._M_current, __y._M_current); } + }; + + namespace views + { + namespace __detail + { + template + concept __can_stride_view + = requires { stride_view(std::declval<_Range>(), std::declval<_Dp>()); }; + } + + struct _Stride : __adaptor::_RangeAdaptor<_Stride> + { + template> + requires __detail::__can_stride_view<_Range, _Dp> + constexpr auto + operator() [[nodiscard]] (_Range&& __r, type_identity_t<_Dp> __n) const + { return stride_view(std::forward<_Range>(__r), __n); } + + using __adaptor::_RangeAdaptor<_Stride>::operator(); + static constexpr int _S_arity = 2; + static constexpr bool _S_has_simple_extra_args = true; + }; + + inline constexpr _Stride stride; + } #endif // C++23 } // namespace ranges diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc new file mode 100644 index 00000000000..745d1a61c1b --- /dev/null +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++23" } +// { dg-do run { target c++23 } } + +#include +#include +#include +#include + +namespace ranges = std::ranges; +namespace views = std::views; + +constexpr bool +test01() +{ + int x[] = {1, 2, 3, 4, 5, 6, 7}; + + auto v2 = x | views::stride(2); + const auto i0 = v2.begin(), i1 = v2.begin() + 1; + VERIFY( i0 + 1 - 1 == i0 ); + VERIFY( i0 != i1 ); + VERIFY( i0 < i1 ); + VERIFY( i0 <= i0 ); + VERIFY( i0 >= i0 ); + VERIFY( v2.end() > i1 ); + VERIFY( i1 - i0 == 1 ); + VERIFY( i0 - i1 == -1 ); + VERIFY( v2.end() - i1 == 3 ); + VERIFY( i1 - v2.end() == -3 ); + auto i2 = v2.begin(); + i2 += 2; + i2 -= -2; + VERIFY( i2 == v2.end() ); + VERIFY( ranges::size(v2) == 4 ); + VERIFY( ranges::equal(v2, (int[]){1, 3, 5, 7}) ); + VERIFY( ranges::equal(v2 | views::reverse, (int[]){7, 5, 3, 1}) ); + VERIFY( v2.stride() == 2 ); + + auto v1 = x | views::stride(1); + VERIFY( ranges::size(v1) == ranges::size(x) ); + VERIFY( ranges::equal(v1, x) ); + VERIFY( ranges::equal(v1 | views::reverse, x | views::reverse) ); + VERIFY( v1.stride() == 1 ); + + auto v5 = x | views::stride(5); + VERIFY( ranges::equal(v5, (int[]){1, 6}) ); + VERIFY( ranges::equal(v5 | views::reverse, (int[]){6, 1}) ); + VERIFY( v5.stride() == 5 ); + + auto v10 = x | views::stride(10); + VERIFY( ranges::equal(v10, (int[]){1}) ); + VERIFY( ranges::equal(v10 | views::reverse, (int[]){1}) ); + VERIFY( v10.stride() == 10 ); + + return true; +} + +template +void +test02() +{ + int x[] = {1, 2, 3, 4, 5, 6, 7, 8}; + container rx(x); + auto v = rx | views::stride(3); + VERIFY( ranges::equal(v, (int[]){1, 4, 7}) ); +} + +int +main() +{ + static_assert(test01()); + test02<__gnu_test::test_input_range>(); + test02<__gnu_test::test_forward_range>(); +}