From bcc6128276467be3c6e3cb1a6ab19288849c5449 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Fri, 25 Aug 2023 13:11:23 +0200 Subject: [PATCH 1/3] [INFRA] Remove subtree for update --- include/seqan3/contrib/std/.clang-format | 186 --- include/seqan3/contrib/std/.gitignore | 32 - include/seqan3/contrib/std/LICENSE | 27 - include/seqan3/contrib/std/README.md | 2 - include/seqan3/contrib/std/all_view.hpp | 225 ---- include/seqan3/contrib/std/chunk_view.hpp | 613 ---------- include/seqan3/contrib/std/concepts.hpp | 44 - .../contrib/std/detail/adaptor_base.hpp | 215 ---- .../detail/adaptor_for_view_without_args.hpp | 73 -- .../std/detail/adaptor_from_functor.hpp | 75 -- .../std/detail/compiler_definitions.hpp | 31 - .../contrib/std/detail/exposition_only.hpp | 38 - .../std/detail/non_propagating_cache.hpp | 83 -- include/seqan3/contrib/std/join_with_view.hpp | 546 --------- include/seqan3/contrib/std/pair.hpp | 674 ----------- include/seqan3/contrib/std/to.hpp | 237 ---- include/seqan3/contrib/std/tuple.hpp | 1019 ----------------- include/seqan3/contrib/std/zip_view.hpp | 571 --------- 18 files changed, 4691 deletions(-) delete mode 100644 include/seqan3/contrib/std/.clang-format delete mode 100644 include/seqan3/contrib/std/.gitignore delete mode 100644 include/seqan3/contrib/std/LICENSE delete mode 100644 include/seqan3/contrib/std/README.md delete mode 100644 include/seqan3/contrib/std/all_view.hpp delete mode 100644 include/seqan3/contrib/std/chunk_view.hpp delete mode 100644 include/seqan3/contrib/std/concepts.hpp delete mode 100644 include/seqan3/contrib/std/detail/adaptor_base.hpp delete mode 100644 include/seqan3/contrib/std/detail/adaptor_for_view_without_args.hpp delete mode 100644 include/seqan3/contrib/std/detail/adaptor_from_functor.hpp delete mode 100644 include/seqan3/contrib/std/detail/compiler_definitions.hpp delete mode 100644 include/seqan3/contrib/std/detail/exposition_only.hpp delete mode 100644 include/seqan3/contrib/std/detail/non_propagating_cache.hpp delete mode 100644 include/seqan3/contrib/std/join_with_view.hpp delete mode 100644 include/seqan3/contrib/std/pair.hpp delete mode 100644 include/seqan3/contrib/std/to.hpp delete mode 100644 include/seqan3/contrib/std/tuple.hpp delete mode 100644 include/seqan3/contrib/std/zip_view.hpp diff --git a/include/seqan3/contrib/std/.clang-format b/include/seqan3/contrib/std/.clang-format deleted file mode 100644 index c6ab535291..0000000000 --- a/include/seqan3/contrib/std/.clang-format +++ /dev/null @@ -1,186 +0,0 @@ -# Format all files -# find . -iname "*.hpp" | xargs clang-format-15 --style=file -i ---- -Language: Cpp -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignArrayOfStructures: None -AlignConsecutiveMacros: None -AlignConsecutiveAssignments: None -AlignConsecutiveBitFields: None -AlignConsecutiveDeclarations: None -AlignEscapedNewlines: Right -AlignOperands: AlignAfterOperator -AlignTrailingComments: true -AllowAllArgumentsOnNextLine: false -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortEnumsOnASingleLine: true -AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortLambdasOnASingleLine: Empty -AllowShortIfStatementsOnASingleLine: Never -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: Yes -AttributeMacros: -BinPackArguments: false -BinPackParameters: false -BraceWrapping: - AfterCaseLabel: true - AfterClass: true - AfterControlStatement: Always - AfterEnum: true - AfterFunction: true - AfterNamespace: true - AfterObjCDeclaration: false - AfterStruct: true - AfterUnion: true - AfterExternBlock: true - BeforeCatch: true - BeforeElse: true - BeforeLambdaBody: true - BeforeWhile: true - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: false -BreakBeforeBinaryOperators: NonAssignment -BreakBeforeConceptDeclarations: true -BreakBeforeBraces: Custom -BreakBeforeInheritanceComma: false -BreakInheritanceList: AfterColon -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: AfterColon -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 120 -CommentPragmas: '^ IWYU pragma:' -QualifierAlignment: Custom -QualifierOrder: ['static', 'inline', 'constexpr', 'volatile', 'type', 'const'] -CompactNamespaces: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DeriveLineEnding: true -DerivePointerAlignment: false -DisableFormat: false -EmptyLineAfterAccessModifier: Never -EmptyLineBeforeAccessModifier: Always -ExperimentalAutoDetectBinPacking: false -PackConstructorInitializers: CurrentLine -BasedOnStyle: '' -ConstructorInitializerAllOnOneLineOrOnePerLine: false -AllowAllConstructorInitializersOnNextLine: true -FixNamespaceComments: true -ForEachMacros: -IfMacros: -IncludeBlocks: Regroup -IncludeCategories: - - Regex: '(|)' - Priority: 2 - - Regex: ' - * \brief Provides seqan::std::views::{all, all_t}, and seqan::std::ranges::owning_view. - */ - -// File might be included from multiple libraries. -#ifndef SEQAN_STD_ALL_VIEW -#define SEQAN_STD_ALL_VIEW - -#include - -#if __cpp_lib_ranges >= 202110L - -namespace seqan::std::ranges -{ - -using ::std::ranges::owning_view; - -} // namespace seqan::std::ranges - -namespace seqan::std::views -{ - -using ::std::ranges::views::all; -using ::std::ranges::views::all_t; - -} // namespace seqan::std::views -#else -# include "concepts.hpp" -# include "detail/adaptor_base.hpp" -# include "detail/exposition_only.hpp" - -namespace seqan::std::ranges -{ - -/*!\brief A move-only view that takes unique ownership of a range. - * \sa https://en.cppreference.com/w/cpp/ranges/owning_view - */ -template <::std::ranges::range rng_t> - requires ::std::movable && (!seqan::std::detail::is_initializer_list<::std::remove_cvref_t>) -class owning_view : public ::std::ranges::view_interface> -{ -private: - //!\brief The stored range. - rng_t rng = rng_t(); - -public: - owning_view() - requires ::std::default_initializable - = default; //!< Defaulted. - owning_view(owning_view const &) = delete; //!< Deleted. - owning_view & operator=(owning_view const &) = delete; //!< Deleted. - owning_view(owning_view &&) = default; //!< Defaulted. - owning_view & operator=(owning_view &&) = default; //!< Defaulted. - ~owning_view() = default; //!< Defaulted. - - //!\brief Move construct from a range. - constexpr owning_view(rng_t && r) : rng(::std::move(r)) - {} - - //!\brief Returns the range. - constexpr rng_t & base() & noexcept - { - return rng; - } - - //!\overload - constexpr rng_t const & base() const & noexcept - { - return rng; - } - - //!\overload - constexpr rng_t && base() && noexcept - { - return ::std::move(rng); - } - - //!\overload - constexpr rng_t const && base() const && noexcept - { - return ::std::move(rng); - } - - //!\brief Return the begin iterator of the range. - constexpr ::std::ranges::iterator_t begin() - { - return ::std::ranges::begin(rng); - } - - //!\overload - constexpr auto begin() const - requires ::std::ranges::range - { - return ::std::ranges::begin(rng); - } - - //!\brief Return the end iterator of the range. - constexpr ::std::ranges::sentinel_t end() - { - return ::std::ranges::end(rng); - } - - //!\overload - constexpr auto end() const - requires ::std::ranges::range - { - return ::std::ranges::end(rng); - } - - //!\brief Checks whether the range is empty. - constexpr bool empty() - requires requires { ::std::ranges::empty(rng); } - { - return ::std::ranges::empty(rng); - } - - //!\overload - constexpr bool empty() const - requires requires { ::std::ranges::empty(rng); } - { - return ::std::ranges::empty(rng); - } - - //!\brief Returns the size of the range. - constexpr auto size() - requires ::std::ranges::sized_range - { - return ::std::ranges::size(rng); - } - - //!\overload - constexpr auto size() const - requires ::std::ranges::sized_range - { - return ::std::ranges::size(rng); - } - - //!\brief Returns the raw data pointer of the range. - constexpr auto data() - requires ::std::ranges::contiguous_range - { - return ::std::ranges::data(rng); - } - - //!\overload - constexpr auto data() const - requires ::std::ranges::contiguous_range - { - return ::std::ranges::data(rng); - } -}; - -/*!\brief The functor for seqan::std::views::all. - */ -class all_fn : public seqan::std::detail::adaptor_base -{ -private: - //!\brief Befriend the base class. - friend seqan::std::detail::adaptor_base; - - //!\brief Checks whether a type is a view. - template - static constexpr bool decays_to_view = ::std::ranges::view<::std::decay_t>; - - //!\brief Checks whether a type could be used for ::std::ranges::ref_view. - template - static constexpr bool valid_for_ref_view = requires { ::std::ranges::ref_view(::std::declval()); }; - - //!\brief Checks whether a type could be used for seqan3::detail::owning_view. - template - static constexpr bool valid_for_owning_view = requires { owning_view(::std::declval()); }; - -public: - using seqan::std::detail::adaptor_base::adaptor_base; - - /*!\brief Returns a view that includes all elements of the range argument. - * \sa https://en.cppreference.com/w/cpp/ranges/all_view - * \details - * This implements the new C++20 behaviour that is only available with gcc12 and newer. - * In contrast to the old ::std::views::all, rvalue ranges can be bound. - * \returns - * * `rng` if `rng` is a view. - * * A ::std::ranges::ref_view of `rng` if that expression is valid. - * * Otherwise, a seqan3::detail::owning_view of `rng`. - */ - template - requires decays_to_view || valid_for_ref_view || valid_for_owning_view - static auto impl(rng_t && rng) - { - if constexpr (decays_to_view) - return ::std::forward(rng); - else if constexpr (valid_for_ref_view) - return ::std::ranges::ref_view{::std::forward(rng)}; - else - return owning_view{::std::forward(rng)}; - } -}; - -} // namespace seqan::std::ranges - -namespace seqan::std::views -{ - -/*!\copydoc all_fn::impl - */ -inline constexpr auto all = seqan::std::ranges::all_fn{}; - -/*!\brief Returns the type that results from appying seqan3::detail::all to a range. - */ -template -using all_t = decltype(all(::std::declval())); - -} // namespace seqan::std::views - -#endif // __cpp_lib_ranges >= 202110L - -#endif // SEQAN_STD_ALL_VIEW diff --git a/include/seqan3/contrib/std/chunk_view.hpp b/include/seqan3/contrib/std/chunk_view.hpp deleted file mode 100644 index 33967a0d91..0000000000 --- a/include/seqan3/contrib/std/chunk_view.hpp +++ /dev/null @@ -1,613 +0,0 @@ -// ----------------------------------------------------------------------------------------------------- -// Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin -// Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik -// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan-std/blob/main/LICENSE -// ----------------------------------------------------------------------------------------------------- - -/*!\file - * \author Enrico Seiler - * \brief Provides seqan::std::views::chunk. - */ - -// File might be included from multiple libraries. -#ifndef SEQAN_STD_CHUNK_VIEW -#define SEQAN_STD_CHUNK_VIEW - -#include - -#ifdef __cpp_lib_ranges_chunk - -namespace seqan::std::views -{ - -using ::std::ranges::views::chunk; - -} // namespace seqan::std::views - -#else - -# include - -# include "all_view.hpp" -# include "concepts.hpp" -# include "detail/adaptor_from_functor.hpp" -# include "detail/compiler_definitions.hpp" -# include "detail/exposition_only.hpp" -# include "detail/non_propagating_cache.hpp" - -namespace seqan::std::detail::chunk -{ - -template -constexpr I div_ceil(I num, I denom) -{ - I r = num / denom; - if (num % denom) - ++r; - return r; -} - -template <::std::integral T> -constexpr auto to_unsigned_like(T v) noexcept -{ - return static_cast<::std::make_unsigned_t>(v); -} - -} // namespace seqan::std::detail::chunk - -namespace seqan::std::ranges -{ - -template <::std::ranges::view V> -class chunk_view; - -template <::std::ranges::view V> - requires ::std::ranges::input_range -class chunk_view : public ::std::ranges::view_interface> -{ - // clang-format off -SEQAN_STD_NESTED_VISIBILITY - // clang-format on - V base_; - ::std::ranges::range_difference_t n_; - ::std::ranges::range_difference_t remainder_ = 0; - - seqan::std::detail::non_propagating_cache<::std::ranges::iterator_t> current_; - -private: - class outer_iterator; - - class inner_iterator; - -public: - chunk_view() - requires ::std::default_initializable - = default; - - constexpr explicit chunk_view(V base, ::std::ranges::range_difference_t n) : base_{::std::move(base)}, n_{n} - { - assert(n > 0); - } - - constexpr V base() const & - requires ::std::copy_constructible - { - return base_; - } - constexpr V base() && - { - return ::std::move(base_); - } - - constexpr outer_iterator begin() - { - current_ = ::std::ranges::begin(base_); - remainder_ = n_; - return outer_iterator{*this}; - } - constexpr ::std::default_sentinel_t end() const noexcept - { - return ::std::default_sentinel; - } - - constexpr auto size() - requires ::std::ranges::sized_range - { - return seqan::std::detail::chunk::to_unsigned_like( - seqan::std::detail::chunk::div_ceil(::std::ranges::distance(base_), n_)); - } - constexpr auto size() const - requires ::std::ranges::sized_range - { - return seqan::std::detail::chunk::to_unsigned_like( - seqan::std::detail::chunk::div_ceil(::std::ranges::distance(base_), n_)); - } -}; - -template -chunk_view(R &&, ::std::ranges::range_difference_t) -> chunk_view>; - -template <::std::ranges::view V> - requires ::std::ranges::input_range -class chunk_view::outer_iterator -{ -private: - chunk_view * parent_; - - constexpr explicit outer_iterator(chunk_view & parent) : parent_{::std::addressof(parent)} - {} - - friend chunk_view; - -public: - using iterator_concept = ::std::input_iterator_tag; - using difference_type = ::std::ranges::range_difference_t; - - struct value_type; - - outer_iterator(outer_iterator &&) = default; - outer_iterator & operator=(outer_iterator &&) = default; - - constexpr value_type operator*() const - { - assert(*this != ::std::default_sentinel); - return value_type(*parent_); - } - constexpr outer_iterator & operator++() - { - assert(*this != ::std::default_sentinel); - ::std::ranges::advance(*parent_->current_, parent_->remainder_, ::std::ranges::end(parent_->base_)); - parent_->remainder_ = parent_->n_; - return *this; - } - constexpr void operator++(int) - { - ++*this; - } - - friend constexpr bool operator==(outer_iterator const & x, ::std::default_sentinel_t) - { - return *x.parent_->current_ == ::std::ranges::end(x.parent_->base_) && x.parent_->remainder_ != 0; - } - - friend constexpr difference_type operator-(::std::default_sentinel_t y, outer_iterator const & x) - requires ::std::sized_sentinel_for<::std::ranges::sentinel_t, ::std::ranges::iterator_t> - { - auto const dist = ::std::ranges::end(x.parent_->base_) - *x.parent_->current_; - if (dist < x.parent_->remainder_) - { - return dist == 0 ? 0 : 1; - } - return seqan::std::detail::chunk::div_ceil(dist - x.parent_->remainder_, x.parent_->n_) + 1; - } - friend constexpr difference_type operator-(outer_iterator const & x, ::std::default_sentinel_t y) - requires ::std::sized_sentinel_for<::std::ranges::sentinel_t, ::std::ranges::iterator_t> - { - return -(y - x); - } -}; - -template <::std::ranges::view V> - requires ::std::ranges::input_range -struct chunk_view::outer_iterator::value_type : ::std::ranges::view_interface -{ -private: - chunk_view * parent_; - - constexpr explicit value_type(chunk_view & parent) noexcept : parent_{::std::addressof(parent)} - {} - - friend chunk_view; - -public: - constexpr inner_iterator begin() const noexcept - { - return inner_iterator{*parent_}; - } - constexpr ::std::default_sentinel_t end() const noexcept - { - return ::std::default_sentinel; - } - - constexpr auto size() const - requires ::std::sized_sentinel_for<::std::ranges::sentinel_t, ::std::ranges::iterator_t> - { - return seqan::std::detail::chunk::to_unsigned_like( - ::std::ranges::min(parent_->remainder_, ::std::ranges::end(parent_->base_) - *parent_->current_)); - } -}; - -template <::std::ranges::view V> - requires ::std::ranges::input_range -class chunk_view::inner_iterator -{ -private: - chunk_view * parent_; - - constexpr explicit inner_iterator(chunk_view & parent) noexcept : parent_{::std::addressof(parent)} - {} - - friend chunk_view; - -public: - using iterator_concept = ::std::input_iterator_tag; - using difference_type = ::std::ranges::range_difference_t; - using value_type = ::std::ranges::range_value_t; - - inner_iterator(inner_iterator &&) = default; - inner_iterator & operator=(inner_iterator &&) = default; - - constexpr ::std::ranges::iterator_t const & base() const & - { - return *parent_->current_; - } - - constexpr ::std::ranges::range_reference_t operator*() const - { - assert(*this != ::std::default_sentinel); - return **parent_->current_; - } - constexpr inner_iterator & operator++() - { - assert(*this != ::std::default_sentinel); - ++*parent_->current_; - if (*parent_->current_ == ::std::ranges::end(parent_->base_)) - parent_->remainder_ = 0; - else - --parent_->remainder_; - return *this; - } - constexpr void operator++(int) - { - return ++*this; - } - - friend constexpr bool operator==(inner_iterator const & x, ::std::default_sentinel_t) - { - return x.parent_->remainder_ == 0; - } - - friend constexpr difference_type operator-(::std::default_sentinel_t y, inner_iterator const & x) - requires ::std::sized_sentinel_for<::std::ranges::sentinel_t, ::std::ranges::iterator_t> - { - ::std::ranges::min(x.parent_->remainder_, ::std::ranges::end(x.parent_->base_) - *x.parent_->current_); - } - friend constexpr difference_type operator-(inner_iterator const & x, ::std::default_sentinel_t y) - requires ::std::sized_sentinel_for<::std::ranges::sentinel_t, ::std::ranges::iterator_t> - { - return -(y - x); - } - - friend constexpr ::std::ranges::range_rvalue_reference_t - iter_move(inner_iterator const & i) noexcept(noexcept(::std::ranges::iter_move(*i.parent_->current_))) - { - return ::std::ranges::iter_move(*i.parent_->current_); - } - - friend constexpr void iter_swap(inner_iterator const & x, inner_iterator const & y) noexcept( - noexcept(::std::ranges::iter_swap(*x.parent_->current_, *y.parent_->current_))) - requires ::std::indirectly_swappable<::std::ranges::iterator_t> - { - ::std::ranges::iter_swap(*x.parent_->current_, *y.parent_->current_); - } -}; - -template <::std::ranges::view V> - requires ::std::ranges::forward_range -class chunk_view : public ::std::ranges::view_interface> -{ -private: - V base_; - ::std::ranges::range_difference_t n_; - - template - class iterator; - -public: - chunk_view() - requires ::std::default_initializable - = default; - - constexpr explicit chunk_view(V base, ::std::ranges::range_difference_t n) : base_{::std::move(base)}, n_{n} - { - assert(n > 0); - } - - constexpr V base() const & - requires ::std::copy_constructible - { - return base_; - } - constexpr V base() && - { - return ::std::move(base_); - } - - constexpr auto begin() - requires (!seqan::std::detail::simple_view) - { - return iterator{this, ::std::ranges::begin(base_)}; - } - - constexpr auto begin() const - requires ::std::ranges::forward_range - { - return iterator{this, ::std::ranges::begin(base_)}; - } - - constexpr auto end() - requires (!seqan::std::detail::simple_view) - { - if constexpr (::std::ranges::common_range && ::std::ranges::sized_range) - { - auto missing = (n_ - ::std::ranges::distance(base_) % n_) % n_; - return iterator{this, ::std::ranges::end(base_), missing}; - } - else if constexpr (::std::ranges::common_range && !::std::ranges::bidirectional_range) - { - return iterator{this, ::std::ranges::end(base_)}; - } - else - { - return ::std::default_sentinel; - } - } - - constexpr auto end() const - requires ::std::ranges::forward_range - { - if constexpr (::std::ranges::common_range && ::std::ranges::sized_range) - { - auto missing = (n_ - ::std::ranges::distance(base_) % n_) % n_; - return iterator{this, ::std::ranges::end(base_), missing}; - } - else if constexpr (::std::ranges::common_range && !::std::ranges::bidirectional_range) - { - return iterator{this, ::std::ranges::end(base_)}; - } - else - { - return ::std::default_sentinel; - } - } - - constexpr auto size() - requires ::std::ranges::sized_range - { - return seqan::std::detail::chunk::to_unsigned_like( - seqan::std::detail::chunk::div_ceil(::std::ranges::distance(base_), n_)); - } - constexpr auto size() const - requires ::std::ranges::sized_range - { - return seqan::std::detail::chunk::to_unsigned_like( - seqan::std::detail::chunk::div_ceil(::std::ranges::distance(base_), n_)); - } -}; - -template <::std::ranges::view V> - requires ::std::ranges::forward_range -template -class chunk_view::iterator -{ -private: - using Parent = seqan::std::detail::maybe_const; - using Base = seqan::std::detail::maybe_const; - - ::std::ranges::iterator_t current_ = ::std::ranges::iterator_t{}; - ::std::ranges::sentinel_t end_ = ::std::ranges::sentinel_t{}; - ::std::ranges::range_difference_t n_ = 0; - ::std::ranges::range_difference_t missing_ = 0; - - constexpr iterator(Parent * parent, - ::std::ranges::iterator_t current, - ::std::ranges::range_difference_t missing = 0) : - current_{current}, - end_{::std::ranges::end(parent->base_)}, - n_{parent->n_}, - missing_{missing} - {} - - friend chunk_view; - -public: - using iterator_category = ::std::input_iterator_tag; - using iterator_concept = ::std::conditional_t<::std::ranges::random_access_range, - ::std::random_access_iterator_tag, - ::std::conditional_t<::std::ranges::bidirectional_range, - ::std::bidirectional_iterator_tag, - ::std::forward_iterator_tag>>; - using value_type = decltype(::std::views::take(::std::ranges::subrange{current_, end_}, n_)); - using difference_type = ::std::ranges::range_difference_t; - - iterator() = default; - constexpr iterator(iterator i) - requires Const && ::std::convertible_to<::std::ranges::iterator_t, ::std::ranges::iterator_t> - && ::std::convertible_to<::std::ranges::sentinel_t, ::std::ranges::sentinel_t> - : current_{::std::move(i.current_)}, end_{::std::move(i.end_)}, n_{i.n_}, missing_{i.missing_} - {} - - constexpr ::std::ranges::iterator_t base() const - { - return current_; - } - - constexpr value_type operator*() const - { - assert(current_ != end_); - return ::std::views::take(::std::ranges::subrange(current_, end_), n_); - } - - constexpr iterator & operator++() - { - assert(current_ != end_); - missing_ = ::std::ranges::advance(current_, n_, end_); - return *this; - } - - constexpr iterator operator++(int) - { - auto tmp = *this; - ++*this; - return tmp; - } - - constexpr iterator & operator--() - requires ::std::ranges::bidirectional_range - { - ::std::ranges::advance(current_, missing_ - n_); - missing_ = 0; - return *this; - } - - constexpr iterator operator--(int) - requires ::std::ranges::bidirectional_range - { - auto tmp = *this; - --*this; - return tmp; - } - - constexpr iterator & operator+=(difference_type x) - requires ::std::ranges::random_access_range - { - assert(x <= 0 || ::std::ranges::distance(current_, end_) > n_ * (x - 1)); - if (x > 0) - { - ::std::ranges::advance(current_, n_ * (x - 1)); - missing_ = ::std::ranges::advance(current_, n_, end_); - } - else if (x < 0) - { - ::std::ranges::advance(current_, n_ * x + missing_); - missing_ = 0; - } - return *this; - } - - constexpr iterator & operator-=(difference_type x) - requires ::std::ranges::random_access_range - { - return *this += -x; - } - - constexpr value_type operator[](difference_type n) const - requires ::std::ranges::random_access_range - { - return *(*this + n); - } - - friend constexpr bool operator==(iterator const & x, iterator const & y) - { - return x.current_ == y.current_; - } - - friend constexpr bool operator==(iterator const & x, ::std::default_sentinel_t) - { - return x.current_ == x.end_; - } - - friend constexpr bool operator<(iterator const & x, iterator const & y) - requires ::std::ranges::random_access_range - { - return x.current_ < y.current_; - } - - friend constexpr bool operator>(iterator const & x, iterator const & y) - requires ::std::ranges::random_access_range - { - return y < x; - } - - friend constexpr bool operator<=(iterator const & x, iterator const & y) - requires ::std::ranges::random_access_range - { - return !(y < x); - } - - friend constexpr bool operator>=(iterator const & x, iterator const & y) - requires ::std::ranges::random_access_range - { - return !(x < y); - } - -# ifdef __cpp_lib_three_way_comparison - friend constexpr auto operator<=>(iterator const & x, iterator const & y) - requires ::std::ranges::random_access_range - && ::std::three_way_comparable<::std::ranges::iterator_t> - { - return x.current_ <=> y.current_; - } -# endif - - friend constexpr iterator operator+(iterator const & i, difference_type n) - requires ::std::ranges::random_access_range - { - auto r = i; - r += n; - return r; - } - - friend constexpr iterator operator+(difference_type n, iterator const & i) - requires ::std::ranges::random_access_range - { - auto r = i; - r += n; - return r; - } - - friend constexpr iterator operator-(iterator const & i, difference_type n) - requires ::std::ranges::random_access_range - { - auto r = i; - r -= n; - return r; - } - - friend constexpr difference_type operator-(iterator const & x, iterator const & y) - requires ::std::sized_sentinel_for<::std::ranges::sentinel_t, ::std::ranges::iterator_t> - { - return (x.current_ - y.current_ + x.missing_ - y.missing_) / x.n_; - } - - friend constexpr difference_type operator-(::std::default_sentinel_t y, iterator const & x) - requires ::std::sized_sentinel_for<::std::ranges::sentinel_t, ::std::ranges::iterator_t> - { - return seqan::std::detail::chunk::div_ceil(x.end_ - x.current_, x.n_); - } - - friend constexpr difference_type operator-(iterator const & x, ::std::default_sentinel_t y) - requires ::std::sized_sentinel_for<::std::ranges::sentinel_t, ::std::ranges::iterator_t> - { - return -(y - x); - } -}; - -struct chunk_fn -{ - template - constexpr auto operator()(Difference n) const - { - return seqan::std::detail::adaptor_from_functor{*this, n}; - } - - template > - constexpr auto operator()(Range && range, ::std::type_identity_t n) const - { - return chunk_view{::std::forward(range), n}; - } -}; - -} // namespace seqan::std::ranges - -namespace seqan::std::views -{ - -inline constexpr auto chunk = seqan::std::ranges::chunk_fn{}; - -} // namespace seqan::std::views - -#endif // ifdef __cpp_lib_ranges_chunk - -#endif // SEQAN_STD_CHUNK_VIEW diff --git a/include/seqan3/contrib/std/concepts.hpp b/include/seqan3/contrib/std/concepts.hpp deleted file mode 100644 index c2456221cc..0000000000 --- a/include/seqan3/contrib/std/concepts.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// ----------------------------------------------------------------------------------------------------- -// Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin -// Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik -// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan-std/blob/main/LICENSE -// ----------------------------------------------------------------------------------------------------- - -/*!\file - * \author Enrico Seiler - * \brief Provides seqan::std concepts. - */ - -// File might be included from multiple libraries. -#ifndef SEQAN_STD_CONCEPTS -#define SEQAN_STD_CONCEPTS - -#include - -#if __cpp_lib_ranges >= 202110L -namespace seqan::std::ranges -{ - -using ::std::ranges::viewable_range; - -} -#else -# include "detail/exposition_only.hpp" -namespace seqan::std::ranges -{ - -template -concept viewable_range = ::std::ranges::range - && ((::std::ranges::view<::std::remove_cvref_t> - && ::std::constructible_from<::std::remove_cvref_t, T>) - || (!::std::ranges::view<::std::remove_cvref_t> - && (::std::is_lvalue_reference_v - || (::std::movable<::std::remove_reference_t> - && !seqan::std::detail::is_initializer_list<::std::remove_cvref_t>)))); - -} // namespace seqan::std::ranges - -#endif - -#endif // SEQAN_STD_CONCEPTS diff --git a/include/seqan3/contrib/std/detail/adaptor_base.hpp b/include/seqan3/contrib/std/detail/adaptor_base.hpp deleted file mode 100644 index b80f6f59bf..0000000000 --- a/include/seqan3/contrib/std/detail/adaptor_base.hpp +++ /dev/null @@ -1,215 +0,0 @@ -// ----------------------------------------------------------------------------------------------------- -// Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin -// Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik -// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan-std/blob/main/LICENSE -// ----------------------------------------------------------------------------------------------------- - -/*!\file - * \brief Provides seqan::std::detail::adaptor_base and seqan::std::detail::combined_adaptor - * \author Hannes Hauswedell - */ - -// File might be included from multiple libraries. -#ifndef SEQAN_STD_DETAIL_ADAPTOR_BASE -#define SEQAN_STD_DETAIL_ADAPTOR_BASE - -#include -#include - -namespace seqan::std::detail -{ - -// ============================================================================ -// forwards -// ============================================================================ - -template -class combined_adaptor; - -// ============================================================================ -// adaptor_base -// ============================================================================ - -//!\brief CRTP-base to simplify the definition of range adaptor closure objects and similar types. -template -class adaptor_base -{ -private: - //!\brief Stores the arguments. - ::std::tuple arguments; - - //!\brief Helper function to unpack the tuple and delegate to the derived type. - template - constexpr auto pass_args_to_impl(urng_t && urange, ::std::index_sequence const &) const & - { - // ::std::get returns lvalue-reference to value, but we need to copy the values - // so that the view does not depend on the functor - return static_cast(*this).impl( - ::std::forward(urange), - ::std::tuple_element_t>(::std::get(arguments))...); - } - - //!\overload - template - constexpr auto pass_args_to_impl(urng_t && urange, ::std::index_sequence const &) && - { - // move out values, because we don't need them anymore (*this is temporary) - return static_cast(*this).impl( - ::std::forward(urange), - ::std::tuple_element_t>(::std::get(::std::move(arguments)))...); - } - - //!\brief Befriend the derived_type so it can access private members if need be. - friend derived_type; - -public: - /*!\name Constructors, destructor and assignment - * \{ - */ - // a default constructor is not provided, however the constructor below might be one. - constexpr adaptor_base(adaptor_base const &) noexcept = default; //!< Defaulted. - constexpr adaptor_base(adaptor_base &&) noexcept = default; //!< Defaulted. - constexpr adaptor_base & operator=(adaptor_base const &) noexcept = default; //!< Defaulted. - constexpr adaptor_base & operator=(adaptor_base &&) noexcept = default; //!< Defaulted. - ~adaptor_base() noexcept = default; //!< Defaulted. - - //!\brief Constructor with possible arguments; becomes a default constructor for adaptors without args. - constexpr adaptor_base(stored_args_ts... args) noexcept(noexcept(::std::tuple{ - ::std::forward(args)...})) : - arguments{::std::forward(args)...} - {} - //!\} - - //!\brief Function-style overload for ranges. - template <::std::ranges::input_range urng_t> - constexpr auto operator()(urng_t && urange) const & - { - return pass_args_to_impl(::std::forward(urange), - ::std::make_index_sequence{}); - } - - //!\overload - template <::std::ranges::input_range urng_t> - constexpr auto operator()(urng_t && urange) && - { - return ::std::move(*this).pass_args_to_impl(::std::forward(urange), - ::std::make_index_sequence{}); - } - - /*!\brief Left-hand-side pipe operator that handles range input or composing. - * \tparam arg_t LHS argument type. - * \param[in] arg LHS, either a range or another adaptor. - * \param[in] me RHS. - * - * \details - * - * If the LHS models ::std::ranges::input_range this functions delegates to operator() - * otherwise it assumes the LHS is another range adaptor closure object and it - * returns a seqan3::detail::combined_adaptor that wraps that adaptor and this one. - */ - template - constexpr friend auto operator|(arg_t && arg, derived_type const & me) - { - if constexpr (::std::ranges::input_range) - return me(::std::forward(arg)); - else - return combined_adaptor{::std::forward(arg), me}; - } - - //!\overload - template - constexpr friend auto operator|(arg_t && arg, derived_type && me) - { - if constexpr (::std::ranges::input_range) - return ::std::move(me)(::std::forward(arg)); - else - return combined_adaptor{::std::forward(arg), ::std::move(me)}; - } - - /*!\brief Right-hand-side pipe operator that handles composing. - * \tparam arg_t RHS argument type. - * \param[in] me LHS, another adaptor. - * \param[in] arg RHS. - * - * \details - * - * This operator assumes that the RHS is another range adaptor closure object and it - * returns a seqan3::detail::combined_adaptor that wraps that adaptor and this one. - * - * Note that this operator takes adaptor_base and not derived_type as parameter type - * so that an implicit conversion is required for invoking this function. - * This prioritises the LHS-pipe-operator overload and resolves ambiguity in cases - * where they are competing. - * It has no semantic meaning, the type is down-cast inside the function again. - */ - template - constexpr friend auto operator|(adaptor_base const & me, arg_t && arg) - { - return combined_adaptor{static_cast(me), ::std::forward(arg)}; - } - - //!\overload - template - constexpr friend auto operator|(adaptor_base && me, arg_t && arg) - { - return combined_adaptor{static_cast(me), ::std::forward(arg)}; - } -}; - -// ============================================================================ -// combined_adaptor -// ============================================================================ - -/*!\brief Template for range adaptor closure objects that consist of two other range adaptor closure objects. - * \tparam left_adaptor_t Type of the first stored adaptor. - * \tparam right_adaptor_t Type of the second stored adaptor. - * - * \details - * - * If invoked with a range, this adaptor resolves to piping the range into left adaptor and the resulting - * range into the right adaptor. - */ -template -class combined_adaptor : - public adaptor_base, left_adaptor_t, right_adaptor_t> -{ -private: - //!\brief Type of the CRTP-base. - using base_type = adaptor_base, left_adaptor_t, right_adaptor_t>; - - //!\brief Befriend the base class so it can call impl(). - friend base_type; - - //!\brief Combine all arguments via `operator|`. - template <::std::ranges::input_range urng_t, typename left_adaptor_t_, typename right_adaptor_t_> - static auto impl(urng_t && urange, left_adaptor_t_ && left_adaptor, right_adaptor_t_ && right_adaptor) - { - return ::std::forward(urange) | ::std::forward(left_adaptor) - | ::std::forward(right_adaptor); - } - -public: - /*!\name Constructors, destructor and assignment - * \{ - */ - constexpr combined_adaptor() = default; //!< Defaulted. - constexpr combined_adaptor(combined_adaptor const &) noexcept = default; //!< Defaulted. - constexpr combined_adaptor(combined_adaptor &&) noexcept = default; //!< Defaulted. - constexpr combined_adaptor & operator=(combined_adaptor const &) noexcept = default; //!< Defaulted. - constexpr combined_adaptor & operator=(combined_adaptor &&) noexcept = default; //!< Defaulted. - ~combined_adaptor() noexcept = default; //!< Defaulted. - - //!\brief Inherit the base type's constructors. - using base_type::base_type; - - //!\brief Store both arguments in the adaptor. - constexpr combined_adaptor(left_adaptor_t l, right_adaptor_t r) : - base_type{::std::forward(l), ::std::forward(r)} - {} - //!\} -}; - -} // namespace seqan::std::detail - -#endif // SEQAN_STD_DETAIL_ADAPTOR_BASE diff --git a/include/seqan3/contrib/std/detail/adaptor_for_view_without_args.hpp b/include/seqan3/contrib/std/detail/adaptor_for_view_without_args.hpp deleted file mode 100644 index 61ee565eda..0000000000 --- a/include/seqan3/contrib/std/detail/adaptor_for_view_without_args.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// ----------------------------------------------------------------------------------------------------- -// Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin -// Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik -// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan-std/blob/main/LICENSE -// ----------------------------------------------------------------------------------------------------- - -/*!\file - * \brief Provides seqan::std::detail::adaptor_for_view_without_args - * \author Hannes Hauswedell - */ - -// File might be included from multiple libraries. -#ifndef SEQAN_STD_DETAIL_ADAPTOR_FOR_VIEW_WITHOUT_ARGS -#define SEQAN_STD_DETAIL_ADAPTOR_FOR_VIEW_WITHOUT_ARGS - -#include "adaptor_base.hpp" - -namespace seqan::std::detail -{ - -// ============================================================================ -// adaptor_for_view_without_args -// ============================================================================ - -//!\brief Template for range adaptor closure objects that store no arguments and delegate to the view constructor. -template