Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
changkhothuychung committed Dec 22, 2024
1 parent be9cd17 commit 1d7004f
Showing 1 changed file with 39 additions and 52 deletions.
91 changes: 39 additions & 52 deletions libcxx/include/__ranges/concat_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,66 +241,53 @@ class concat_view : public view_interface<concat_view<Views...>>

};


template <class... _Views>
concat_view(_Views&&...) -> concat_view<views::all_t<_Views>...>;


// begin class iterator


template <input_range... Views>
requires (view<Views> && ...) && (sizeof...(Views) > 0) &&
concatable<Views...>
template <bool Const>
class concat_view<Views...>::iterator {

public:
//using iterator_category = see below; // not always present.

constexpr static bool derive_pack_random_iterator = derived_from_pack<typename iterator_traits<iterator_t<__maybe_const<Const, Views>>>::iterator_category..., random_access_iterator_tag>::value;
constexpr static bool derive_pack_bidirectional_iterator = derived_from_pack<typename iterator_traits<iterator_t<__maybe_const<Const, Views>>>::iterator_category..., bidirectional_iterator_tag>::value;
constexpr static bool derive_pack_forward_iterator = derived_from_pack<typename iterator_traits< iterator_t<__maybe_const<Const, Views>>>::iterator_category..., forward_iterator_tag>::value;
using iterator_category = _If<!is_reference_v<concat_reference_t<__maybe_const<Const, Views>...>>,
input_iterator_tag,
_If<derive_pack_random_iterator,
random_access_iterator_tag,
_If<derive_pack_bidirectional_iterator,
bidirectional_iterator_tag,
_If<derive_pack_forward_iterator,
forward_iterator_tag,
input_iterator_tag
>
>
>
>;
using iterator_concept = _If<concat_is_random_access<Const, Views...>,
random_access_iterator_tag,
_If<concat_is_bidirectional<Const, Views...>,
bidirectional_iterator_tag,
_If<
all_forward<Const, Views...>,
forward_iterator_tag,
input_iterator_tag
>
>
>;
using value_type = concat_value_t<__maybe_const<Const, Views>...>;
using difference_type = common_type_t<range_difference_t<__maybe_const<Const, Views>>...>;
using base_iter = variant<iterator_t<__maybe_const<Const, Views>>...>;

base_iter it_; // exposition only
__maybe_const<Const, concat_view>* parent_ = nullptr; // exposition only

template <std::size_t N>
constexpr void satisfy()
{
if constexpr (N < (sizeof...(Views) - 1)) {
if (get<N>(it_) == ranges::end(get<N>(parent_->views_))) {
it_.template emplace<N + 1>(ranges::begin(get<N + 1>(parent_->views_)));
satisfy<N + 1>();
}
}
public:
constexpr static bool derive_pack_random_iterator =
derived_from_pack<typename iterator_traits<iterator_t<__maybe_const<Const, Views>>>::iterator_category...,
random_access_iterator_tag>::value;
constexpr static bool derive_pack_bidirectional_iterator =
derived_from_pack<typename iterator_traits<iterator_t<__maybe_const<Const, Views>>>::iterator_category...,
bidirectional_iterator_tag>::value;
constexpr static bool derive_pack_forward_iterator =
derived_from_pack<typename iterator_traits< iterator_t<__maybe_const<Const, Views>>>::iterator_category...,
forward_iterator_tag>::value;
using iterator_category =
_If<!is_reference_v<concat_reference_t<__maybe_const<Const, Views>...>>,
input_iterator_tag,
_If<derive_pack_random_iterator,
random_access_iterator_tag,
_If<derive_pack_bidirectional_iterator,
bidirectional_iterator_tag,
_If<derive_pack_forward_iterator, forward_iterator_tag, input_iterator_tag > > > >;
using iterator_concept =
_If<concat_is_random_access<Const, Views...>,
random_access_iterator_tag,
_If<concat_is_bidirectional<Const, Views...>,
bidirectional_iterator_tag,
_If< all_forward<Const, Views...>, forward_iterator_tag, input_iterator_tag > > >;
using value_type = concat_value_t<__maybe_const<Const, Views>...>;
using difference_type = common_type_t<range_difference_t<__maybe_const<Const, Views>>...>;
using base_iter = variant<iterator_t<__maybe_const<Const, Views>>...>;

base_iter it_; // exposition only
__maybe_const<Const, concat_view>* parent_ = nullptr; // exposition only

template <std::size_t N>
constexpr void satisfy() {
if constexpr (N < (sizeof...(Views) - 1)) {
if (get<N>(it_) == ranges::end(get<N>(parent_->views_))) {
it_.template emplace<N + 1>(ranges::begin(get<N + 1>(parent_->views_)));
satisfy<N + 1>();
}
}
}

template <std::size_t N>
Expand Down

0 comments on commit 1d7004f

Please sign in to comment.