6#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UTILITY_MAKE_SUBRANGE_HPP_
7#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UTILITY_MAKE_SUBRANGE_HPP_
14#include "arene/base/ranges/detail/range_interface.hpp"
16#include "arene/base/stdlib_choice/enable_if.hpp"
17#include "arene/base/stdlib_choice/integral_constant.hpp"
18#include "arene/base/stdlib_choice/is_copy_constructible.hpp"
19#include "arene/base/stdlib_choice/is_move_constructible.hpp"
20#include "arene/base/stdlib_choice/iterator_traits.hpp"
21#include "arene/base/stdlib_choice/move.hpp"
31namespace make_subrange_detail {
39template <
typename Iterator,
typename Sentinel>
40class iterator_range :
public ranges::detail::range_interface<iterator_range<Iterator, Sentinel>> {
47 using value_type =
typename std::iterator_traits<iterator_type>::value_type;
50 using iterator = iterator_type;
52 using const_iterator = iterator_type;
58 constexpr iterator_range(iterator_type itr, sentinel_type sent)
noexcept(
62 : ranges::detail::range_interface<iterator_range>{
this},
69 constexpr auto begin() const noexcept(std::is_nothrow_copy_constructible<iterator_type>::value) -> iterator_type {
74 constexpr auto end() const noexcept(std::is_nothrow_copy_constructible<sentinel_type>::value) -> sentinel_type {
81 iterator_type iterator_;
83 sentinel_type sentinel_;
98constexpr auto make_subrange(Iterator iterator, Sentinel sentinel)
noexcept(
101) -> make_subrange_detail::iterator_range<Iterator, Sentinel> {
102 return make_subrange_detail::iterator_range<Iterator, Sentinel>{
std::move(iterator),
std::move(sentinel)};
110template <
typename Iterator,
typename Sentinel>
111class enable_borrowed_range<make_subrange_detail::iterator_range<Iterator, Sentinel>> :
public std::true_type {};
static constexpr value_type value
Definition integral_constant.hpp:34
Definition accumulate.hpp:37
constexpr auto make_subrange(Iterator iterator, Sentinel sentinel) noexcept(std::is_nothrow_move_constructible< Iterator >::value &&//std::is_nothrow_move_constructible< Sentinel >::value) -> make_subrange_detail::iterator_range< Iterator, Sentinel >
Combine an iterator and sentinel into a range type that can be used with range-based for loops.
Definition make_subrange.hpp:98
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
remove_cv_t< remove_reference_t< T > > remove_cvref_t
Backport of std::remove_cvref_t.
Definition remove_cvref.hpp:35
Definition accumulate.hpp:36
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
bool_constant< true > true_type
An alias for bool_constant<true>
Definition integral_constant.hpp:76