Skip to content

Commit

Permalink
Revert "Add views::concat_expert. views::concat with prvalue-xvalue m…
Browse files Browse the repository at this point in the history
…ix disabler, expert without."

This reverts commit 854e75f.
  • Loading branch information
huixie90 committed Sep 8, 2023
1 parent 854e75f commit fe59735
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 86 deletions.
68 changes: 15 additions & 53 deletions concat.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ toc: true

# Revision History

## R4
- Added `views::concat_expert`.

## R3

- Redesigned `iter_swap`
Expand Down Expand Up @@ -466,13 +463,12 @@ namespace std::ranges {
// [...]

// [range.concat], concat view
template <bool expert_mode, input_range... Views>
template <input_range... Views>
requires @*see below*@
class concat_view;

namespace views {
inline constexpr @_unspecified_@ concat = @_unspecified_@;
inline constexpr @_unspecified_@ concat_expert = @_unspecified_@;
}

}
Expand Down Expand Up @@ -528,22 +524,13 @@ Add the following subclause to [range.adaptors]{.sref}.
[1]{.pnum} `concat_view` presents a `view` that concatenates all the underlying
ranges.

[2]{.pnum} The names `views::concat` and `views::concat_expert` denote two
customization point objects ([customization.point.object]{.sref}). Given a pack
of subexpressions `Es...`, the expression `views::concat(Es...)` is
expression-equivalent to
[2]{.pnum} The name `views::concat` denotes a customization point object
([customization.point.object]{.sref}). Given a pack of subexpressions `Es...`,
the expression `views::concat(Es...)` is expression-equivalent to

- [2.1]{.pnum} `views::all(Es...)` if `Es` is a pack with only one element
and `views::all(Es...)` is a well formed expression,
- [2.2]{.pnum} otherwise, `concat_view(Es...)`, which is deduced to be the type
`concat_view<false, views::all_t<decltype(Es)>...>`.

And, the expression `views::concat_expert(Es...)` is expression-equivalent to

- [2.3]{.pnum} `views::all(Es...)` if `Es` is a pack with only one element
and `views::all(Es...)` is a well formed expression,
- [2.4]{.pnum} otherwise, `concat_view<true, views::all_t<decltype(Es)>...>(Es...)`.

- [2.2]{.pnum} otherwise, `concat_view(Es...)`

\[*Example:*
```cpp
Expand Down Expand Up @@ -574,9 +561,6 @@ namespace std::ranges {
concept @*concat-indirectly-readable*@ = @*see below*@; // exposition only

template <class... Rs>
concept @*concat-require-expert*@ = @*see below*@; // exposition only

template <bool expert_mode, class... Rs>
concept @_concatable_@ = @*see below*@; // exposition only

template <bool Const, class... Rs>
Expand All @@ -590,10 +574,10 @@ namespace std::ranges {
template <bool Const, class... Rs>
concept @_concat-is-bidirectional_@ = @*see below*@; // exposition only

template <bool expert_mode, input_range... Views>
template <input_range... Views>
requires (view<Views> && ...) && (sizeof...(Views) > 0) &&
@_concatable_@<expert_mode, Views...>
class concat_view : public view_interface<concat_view<expert_mode, Views...>> {
@_concatable_@<Views...>
class concat_view : public view_interface<concat_view<Views...>> {
tuple<Views...> @*views_*@; // exposition only

template <bool Const>
Expand All @@ -619,7 +603,7 @@ namespace std::ranges {
};

template <class... R>
concat_view(R&&...) -> concat_view<false, views::all_t<R>...>;
concat_view(R&&...) -> concat_view<views::all_t<R>...>;
}
```
Expand Down Expand Up @@ -656,29 +640,8 @@ concept @*concat-indirectly-readable*@ = // exposition only
:::
```cpp
template <class... Rs>
concept @*concat-require-expert*@ = @*see below*@; // exposition only
```

:::bq

[2]{.pnum} The exposition-only `@*concat-require-expert*@` concept is equivalent to:

```cpp
template <class... Rs>
concept @*concat-require-expert*@ = // exposition only
is_reference_v<@*concat-reference-t*@<Rs...>> ||
((!is_reference_v<range_reference_t<Rs>> ||
!same_as<remove_reference_t<range_reference_t<Rs>>, @*concat-reference-t*@<Rs...>>)
&& ...);
```
:::
```cpp
template <bool expert_mode, class... Rs>
concept @_concatable_@ = @*see below*@; // exposition only
```

Expand All @@ -688,13 +651,12 @@ concept @_concatable_@ = @*see below*@; // exposition only
concept is equivalent to:

```cpp
template <bool expert_mode, class... Rs>
template <class... Rs>
concept @_concatable_@ = requires { // exposition only
typename @*concat-reference-t*@<Rs...>;
typename @*concat-value-t*@<Rs...>;
typename @*concat-rvalue-reference-t*@<Rs...>;
} && @*concat-indirectly-readable*@<Rs...>
&& (expert_mode || @*concat-require-expert*@<Rs...>);
} && @*concat-indirectly-readable*@<Rs...>;
```
:::
Expand Down Expand Up @@ -747,7 +709,7 @@ constexpr explicit concat_view(Views... views);
```cpp
constexpr @_iterator_@<false> begin() requires(!(@_simple-view_@<Views> && ...));
constexpr @_iterator_@<true> begin() const
requires((range<const Views> && ...) && @_concatable_@<expert_mode, const Views...>);
requires((range<const Views> && ...) && @_concatable_@<const Views...>);
```
:::bq
Expand Down Expand Up @@ -812,11 +774,11 @@ return apply(
```cpp
namespace std::ranges{

template <bool expert_mode, input_range... Views>
template <input_range... Views>
requires (view<Views> && ...) && (sizeof...(Views) > 0) &&
@_concatable_@<expert_mode, Views...>
@_concatable_@<Views...>
template <bool Const>
class concat_view<expert_mode, Views...>::@_iterator_@ {
class concat_view<Views...>::@_iterator_@ {

public:
using iterator_category = @*see below*@; // not always present.
Expand Down
41 changes: 8 additions & 33 deletions impl/concat/concat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ using concat_rvalue_reference_t =
template <class... Rs>
using concat_value_t = common_type_t<range_value_t<Rs>...>;

// modelled only if concat reference_t is a prvalue T and at least one of the
// argument ranges' reference_t is a T reference
template <class... Rs>
concept concat_require_expert =
is_reference_v<concat_reference_t<Rs...>> ||
(is_reference_v<range_reference_t<Rs>>&&...) &&
(!same_as<std::remove_reference_t<range_reference_t<Rs>>,
concat_reference_t<Rs...>> &&
...);

// clang-format off
template <class Ref, class RRef, class It>
concept concat_indirectly_readable_impl = requires (const It it){
Expand All @@ -65,14 +55,12 @@ concept concat_indirectly_readable =
} // namespace not_to_spec

// clang-format off
template <bool expert_mode, class... Rs>
template <class... Rs>
concept concatable = requires {
typename concat_reference_t<Rs...>;
typename concat_value_t<Rs...>;
typename concat_rvalue_reference_t<Rs...>;
} && concat_indirectly_readable<Rs...>
&& (expert_mode || concat_require_expert<Rs...>)
;
} && concat_indirectly_readable<Rs...>;
// clang-format on

static_assert(true); // clang-format badness
Expand Down Expand Up @@ -258,9 +246,9 @@ using iter_cat_base_t = decltype(iter_cat_base_sel<Const, Views...>());

// clang-format off
// [TODO] constrain less and allow just a `view`? (i.e. including output_range in the mix - need an example)
template <bool expert_mode, input_range... Views>
requires (view<Views>&&...) && (sizeof...(Views) > 0) && xo::concatable<expert_mode, Views...>
class concat_view : public view_interface<concat_view<expert_mode, Views...>> {
template <input_range... Views>
requires (view<Views>&&...) && (sizeof...(Views) > 0) && xo::concatable<Views...>
class concat_view : public view_interface<concat_view<Views...>> {
// clang-format on
tuple<Views...> views_; // exposition only

Expand Down Expand Up @@ -648,7 +636,7 @@ class concat_view : public view_interface<concat_view<expert_mode, Views...>> {

constexpr iterator<true> begin() const
requires((range<const Views> && ...) &&
xo::concatable<expert_mode, const Views...>) //
xo::concatable<const Views...>) //
{
iterator<true> it{this, in_place_index<0u>, ranges::begin(get<0>(views_))};
it.template satisfy<0>();
Expand Down Expand Up @@ -697,7 +685,7 @@ class concat_view : public view_interface<concat_view<expert_mode, Views...>> {
};

template <class... R>
concat_view(R&&...) -> concat_view<false, views::all_t<R>...>;
concat_view(R&&...) -> concat_view<views::all_t<R>...>;

// cpo:

Expand All @@ -714,30 +702,17 @@ class concat_fn {
}

template <input_range... V>
requires(sizeof...(V) > 1) && ranges::xo::concatable<false, all_t<V&&>...> &&
requires(sizeof...(V) > 1) && ranges::xo::concatable<all_t<V&&>...> &&
(viewable_range<V> && ...) //
constexpr auto
operator()(V&&... v)
const { // noexcept(noexcept(concat_view{static_cast<V&&>(v)...})) {
return concat_view{static_cast<V&&>(v)...};
}
};

class concat_expert_fn : concat_fn {
public:
template <input_range... V>
requires(sizeof...(V) > 1) && ranges::xo::concatable<true, all_t<V&&>...> &&
(viewable_range<V> && ...) //
constexpr auto
operator()(V&&... v)
const { // noexcept(noexcept(concat_view{static_cast<V&&>(v)...})) {
return concat_view<true, views::all_t<V>...>{static_cast<V&&>(v)...};
}
};
} // namespace xo

inline constexpr xo::concat_fn concat;
inline constexpr xo::concat_expert_fn concat_expert;
} // namespace views

} // namespace std::ranges
Expand Down

0 comments on commit fe59735

Please sign in to comment.