Skip to content

Commit

Permalink
Merge pull request #3189 from eseiler/infra/update_std
Browse files Browse the repository at this point in the history
[INFRA] Update contrib/std
  • Loading branch information
eseiler authored Aug 25, 2023
2 parents 12e3ce7 + 0f76383 commit b2bc207
Show file tree
Hide file tree
Showing 21 changed files with 1,196 additions and 1,209 deletions.
112 changes: 56 additions & 56 deletions include/seqan3/contrib/std/all_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/*!\file
* \author Enrico Seiler <enrico.seiler AT fu-berlin.de>
* \brief Provides seqan::std::views::{all, all_t}, and seqan::std::ranges::owning_view.
* \brief Provides seqan::stl::views::{all, all_t}, and seqan::stl::ranges::owning_view.
*/

// File might be included from multiple libraries.
Expand All @@ -18,42 +18,42 @@

#if __cpp_lib_ranges >= 202110L

namespace seqan::std::ranges
namespace seqan::stl::ranges
{

using ::std::ranges::owning_view;
using std::ranges::owning_view;

} // namespace seqan::std::ranges
} // namespace seqan::stl::ranges

namespace seqan::std::views
namespace seqan::stl::views
{

using ::std::ranges::views::all;
using ::std::ranges::views::all_t;
using std::ranges::views::all;
using std::ranges::views::all_t;

} // namespace seqan::std::views
} // namespace seqan::stl::views
#else
# include "concepts.hpp"
# include "detail/adaptor_base.hpp"
# include "detail/exposition_only.hpp"

namespace seqan::std::ranges
namespace seqan::stl::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<rng_t> && (!seqan::std::detail::is_initializer_list<::std::remove_cvref_t<rng_t>>)
class owning_view : public ::std::ranges::view_interface<owning_view<rng_t>>
template <std::ranges::range rng_t>
requires std::movable<rng_t> && (!seqan::stl::detail::is_initializer_list<std::remove_cvref_t<rng_t>>)
class owning_view : public std::ranges::view_interface<owning_view<rng_t>>
{
private:
//!\brief The stored range.
rng_t rng = rng_t();

public:
owning_view()
requires ::std::default_initializable<rng_t>
requires std::default_initializable<rng_t>
= default; //!< Defaulted.
owning_view(owning_view const &) = delete; //!< Deleted.
owning_view & operator=(owning_view const &) = delete; //!< Deleted.
Expand All @@ -62,7 +62,7 @@ class owning_view : public ::std::ranges::view_interface<owning_view<rng_t>>
~owning_view() = default; //!< Defaulted.

//!\brief Move construct from a range.
constexpr owning_view(rng_t && r) : rng(::std::move(r))
constexpr owning_view(rng_t && r) : rng(std::move(r))
{}

//!\brief Returns the range.
Expand All @@ -80,145 +80,145 @@ class owning_view : public ::std::ranges::view_interface<owning_view<rng_t>>
//!\overload
constexpr rng_t && base() && noexcept
{
return ::std::move(rng);
return std::move(rng);
}

//!\overload
constexpr rng_t const && base() const && noexcept
{
return ::std::move(rng);
return std::move(rng);
}

//!\brief Return the begin iterator of the range.
constexpr ::std::ranges::iterator_t<rng_t> begin()
constexpr std::ranges::iterator_t<rng_t> begin()
{
return ::std::ranges::begin(rng);
return std::ranges::begin(rng);
}

//!\overload
constexpr auto begin() const
requires ::std::ranges::range<rng_t const>
requires std::ranges::range<rng_t const>
{
return ::std::ranges::begin(rng);
return std::ranges::begin(rng);
}

//!\brief Return the end iterator of the range.
constexpr ::std::ranges::sentinel_t<rng_t> end()
constexpr std::ranges::sentinel_t<rng_t> end()
{
return ::std::ranges::end(rng);
return std::ranges::end(rng);
}

//!\overload
constexpr auto end() const
requires ::std::ranges::range<rng_t const>
requires std::ranges::range<rng_t const>
{
return ::std::ranges::end(rng);
return std::ranges::end(rng);
}

//!\brief Checks whether the range is empty.
constexpr bool empty()
requires requires { ::std::ranges::empty(rng); }
requires requires { std::ranges::empty(rng); }
{
return ::std::ranges::empty(rng);
return std::ranges::empty(rng);
}

//!\overload
constexpr bool empty() const
requires requires { ::std::ranges::empty(rng); }
requires requires { std::ranges::empty(rng); }
{
return ::std::ranges::empty(rng);
return std::ranges::empty(rng);
}

//!\brief Returns the size of the range.
constexpr auto size()
requires ::std::ranges::sized_range<rng_t>
requires std::ranges::sized_range<rng_t>
{
return ::std::ranges::size(rng);
return std::ranges::size(rng);
}

//!\overload
constexpr auto size() const
requires ::std::ranges::sized_range<rng_t const>
requires std::ranges::sized_range<rng_t const>
{
return ::std::ranges::size(rng);
return std::ranges::size(rng);
}

//!\brief Returns the raw data pointer of the range.
constexpr auto data()
requires ::std::ranges::contiguous_range<rng_t>
requires std::ranges::contiguous_range<rng_t>
{
return ::std::ranges::data(rng);
return std::ranges::data(rng);
}

//!\overload
constexpr auto data() const
requires ::std::ranges::contiguous_range<rng_t const>
requires std::ranges::contiguous_range<rng_t const>
{
return ::std::ranges::data(rng);
return std::ranges::data(rng);
}
};

/*!\brief The functor for seqan::std::views::all.
/*!\brief The functor for seqan::stl::views::all.
*/
class all_fn : public seqan::std::detail::adaptor_base<all_fn>
class all_fn : public seqan::stl::detail::adaptor_base<all_fn>
{
private:
//!\brief Befriend the base class.
friend seqan::std::detail::adaptor_base<all_fn>;
friend seqan::stl::detail::adaptor_base<all_fn>;

//!\brief Checks whether a type is a view.
template <typename t>
static constexpr bool decays_to_view = ::std::ranges::view<::std::decay_t<t>>;
static constexpr bool decays_to_view = std::ranges::view<std::decay_t<t>>;

//!\brief Checks whether a type could be used for ::std::ranges::ref_view.
//!\brief Checks whether a type could be used for std::ranges::ref_view.
template <typename t>
static constexpr bool valid_for_ref_view = requires { ::std::ranges::ref_view(::std::declval<t>()); };
static constexpr bool valid_for_ref_view = requires { std::ranges::ref_view(std::declval<t>()); };

//!\brief Checks whether a type could be used for seqan3::detail::owning_view.
template <typename t>
static constexpr bool valid_for_owning_view = requires { owning_view(::std::declval<t>()); };
static constexpr bool valid_for_owning_view = requires { owning_view(std::declval<t>()); };

public:
using seqan::std::detail::adaptor_base<all_fn>::adaptor_base;
using seqan::stl::detail::adaptor_base<all_fn>::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.
* 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.
* * A std::ranges::ref_view of `rng` if that expression is valid.
* * Otherwise, a seqan3::detail::owning_view of `rng`.
*/
template <seqan::std::ranges::viewable_range rng_t>
template <seqan::stl::ranges::viewable_range rng_t>
requires decays_to_view<rng_t> || valid_for_ref_view<rng_t> || valid_for_owning_view<rng_t>
static auto impl(rng_t && rng)
{
if constexpr (decays_to_view<rng_t>)
return ::std::forward<rng_t>(rng);
return std::forward<rng_t>(rng);
else if constexpr (valid_for_ref_view<rng_t>)
return ::std::ranges::ref_view{::std::forward<rng_t>(rng)};
return std::ranges::ref_view{std::forward<rng_t>(rng)};
else
return owning_view{::std::forward<rng_t>(rng)};
return owning_view{std::forward<rng_t>(rng)};
}
};

} // namespace seqan::std::ranges
} // namespace seqan::stl::ranges

namespace seqan::std::views
namespace seqan::stl::views
{

/*!\copydoc all_fn::impl
*/
inline constexpr auto all = seqan::std::ranges::all_fn{};
inline constexpr auto all = seqan::stl::ranges::all_fn{};

/*!\brief Returns the type that results from appying seqan3::detail::all to a range.
*/
template <seqan::std::ranges::viewable_range rng_t>
using all_t = decltype(all(::std::declval<rng_t>()));
template <seqan::stl::ranges::viewable_range rng_t>
using all_t = decltype(all(std::declval<rng_t>()));

} // namespace seqan::std::views
} // namespace seqan::stl::views

#endif // __cpp_lib_ranges >= 202110L

Expand Down
Loading

1 comment on commit b2bc207

@vercel
Copy link

@vercel vercel bot commented on b2bc207 Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

seqan3 – ./

seqan3.vercel.app
seqan3-seqan.vercel.app
seqan3-git-master-seqan.vercel.app

Please sign in to comment.