Skip to content

Commit

Permalink
Deploying to gh-pages from @ f8b91a2 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
huixie90 committed May 29, 2024
1 parent 5ca0912 commit a94b02d
Show file tree
Hide file tree
Showing 14 changed files with 2,180 additions and 19 deletions.
23 changes: 18 additions & 5 deletions any_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,17 @@ For `any_view`, it is much much more complex than that:

- Is it an `input_range`, `forward_range`, `bidirectional_range`, `random_access_range`, or a `contiguous_range` ?
- Is the range `copyable` ?
- Is the iterator `copyable` ?
- Is it a `sized_range` ?
- Is it a `borrowed_range` ?
- Is it a `common_range` ?
- What is the `range_reference_t` ?
- What is the `range_value_t` ?
- What is the `range_rvalue_reference_t` ?
- What is the `range_difference_t` ?
- Is the `range` const-iterable?
- Is the iterator `copyable` for `input_iterator`?
- Is the iterator equality comparable for `input_iterator`?
- sized_sentinel_for<S, I> ?

We can easily get combinatorial explosion of types if we follow the same approach of `std::function`. So let's look at the prior arts.

Expand Down Expand Up @@ -169,26 +172,36 @@ enum class category
forward = 3,
bidirectional = 7,
random_access = 15,
contiguous = 31
contiguous = 31,
mask = contiguous,
sized = 32,
borrowed = 64,
common = 128,
move_only_iterator = 256,
move_only_view = 512
move_only_view = 256
};

template <class Ref,
category Cat = category::input,
class Value = decay_t<Ref>,
class RValueRef = add_rvalue_reference_t<Value>,
class Diff = ptrdiff_t>
struct any_view;
class any_view;
```
#### Considerations
- `contiguous_range` is still useful to support even though we have already `std::span`. But `span` is non-owning.
- move-only iterator is not a useful thing to be configured. We can always make the `input_iterator` move-only, as algorithms that deal with input ranges must already deal with the non-copyability.
- move-only view is still useful. (see `std::function` vs `std::move_only_function`)
- const-iteratable will make the design super complicated as all the types can be different between const and non-const.
# Implementation Experience
- Reference implementation in the repo
# Wording
## Feature Test Macro
Expand Down
49 changes: 36 additions & 13 deletions generated/any_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,6 @@ <h2 data-number="4.1" id="what-parameters-can-users-configure"><span class="head
<code class="sourceCode default">random_access_range</code>, or a
<code class="sourceCode default">contiguous_range</code> ?</li>
<li>Is the range <code class="sourceCode default">copyable</code> ?</li>
<li>Is the iterator <code class="sourceCode default">copyable</code>
?</li>
<li>Is it a <code class="sourceCode default">sized_range</code> ?</li>
<li>Is it a <code class="sourceCode default">borrowed_range</code>
?</li>
Expand All @@ -594,6 +592,13 @@ <h2 data-number="4.1" id="what-parameters-can-users-configure"><span class="head
<code class="sourceCode default">range_rvalue_reference_t</code> ?</li>
<li>What is the
<code class="sourceCode default">range_difference_t</code> ?</li>
<li>Is the <code class="sourceCode default">range</code>
const-iterable?</li>
<li>Is the iterator <code class="sourceCode default">copyable</code> for
<code class="sourceCode default">input_iterator</code>?</li>
<li>Is the iterator equality comparable for
<code class="sourceCode default">input_iterator</code>?</li>
<li>sized_sentinel_for&lt;S, I&gt; ?</li>
</ul>
<p>We can easily get combinatorial explosion of types if we follow the
same approach of <code class="sourceCode default">std::function</code>.
Expand Down Expand Up @@ -661,22 +666,40 @@ <h3 data-number="4.1.3" id="parameters-design"><span class="header-section-numbe
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> forward <span class="op">=</span> <span class="dv">3</span>,</span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> bidirectional <span class="op">=</span> <span class="dv">7</span>,</span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> random_access <span class="op">=</span> <span class="dv">15</span>,</span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> contiguous <span class="op">=</span> <span class="dv">31</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> contiguous <span class="op">=</span> <span class="dv">31</span>,</span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a> mask <span class="op">=</span> contiguous,</span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a> sized <span class="op">=</span> <span class="dv">32</span>,</span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a> borrowed <span class="op">=</span> <span class="dv">64</span>,</span>
<span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a> common <span class="op">=</span> <span class="dv">128</span>,</span>
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a> move_only_iterator <span class="op">=</span> <span class="dv">256</span>,</span>
<span id="cb5-14"><a href="#cb5-14" aria-hidden="true" tabindex="-1"></a> move_only_view <span class="op">=</span> <span class="dv">512</span></span>
<span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb5-16"><a href="#cb5-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-17"><a href="#cb5-17" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span> <span class="op">&lt;</span><span class="kw">class</span> Ref, </span>
<span id="cb5-18"><a href="#cb5-18" aria-hidden="true" tabindex="-1"></a> category Cat <span class="op">=</span> category<span class="op">::</span>input,</span>
<span id="cb5-19"><a href="#cb5-19" aria-hidden="true" tabindex="-1"></a> <span class="kw">class</span> Value <span class="op">=</span> decay_t<span class="op">&lt;</span>Ref<span class="op">&gt;</span>,</span>
<span id="cb5-20"><a href="#cb5-20" aria-hidden="true" tabindex="-1"></a> <span class="kw">class</span> RValueRef <span class="op">=</span> add_rvalue_reference_t<span class="op">&lt;</span>Value<span class="op">&gt;</span>,</span>
<span id="cb5-21"><a href="#cb5-21" aria-hidden="true" tabindex="-1"></a> <span class="kw">class</span> Diff <span class="op">=</span> <span class="dt">ptrdiff_t</span><span class="op">&gt;</span></span>
<span id="cb5-22"><a href="#cb5-22" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> any_view;</span></code></pre></div>
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a> move_only_view <span class="op">=</span> <span class="dv">256</span></span>
<span id="cb5-14"><a href="#cb5-14" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-16"><a href="#cb5-16" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span> <span class="op">&lt;</span><span class="kw">class</span> Ref, </span>
<span id="cb5-17"><a href="#cb5-17" aria-hidden="true" tabindex="-1"></a> category Cat <span class="op">=</span> category<span class="op">::</span>input,</span>
<span id="cb5-18"><a href="#cb5-18" aria-hidden="true" tabindex="-1"></a> <span class="kw">class</span> Value <span class="op">=</span> decay_t<span class="op">&lt;</span>Ref<span class="op">&gt;</span>,</span>
<span id="cb5-19"><a href="#cb5-19" aria-hidden="true" tabindex="-1"></a> <span class="kw">class</span> RValueRef <span class="op">=</span> add_rvalue_reference_t<span class="op">&lt;</span>Value<span class="op">&gt;</span>,</span>
<span id="cb5-20"><a href="#cb5-20" aria-hidden="true" tabindex="-1"></a> <span class="kw">class</span> Diff <span class="op">=</span> <span class="dt">ptrdiff_t</span><span class="op">&gt;</span></span>
<span id="cb5-21"><a href="#cb5-21" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> any_view;</span></code></pre></div>
<h4 data-number="4.1.3.1" id="considerations"><span class="header-section-number">4.1.3.1</span> Considerations<a href="#considerations" class="self-link"></a></h4>
<ul>
<li><p><code class="sourceCode default">contiguous_range</code> is still
useful to support even though we have already
<code class="sourceCode default">std::span</code>. But
<code class="sourceCode default">span</code> is non-owning.</p></li>
<li><p>move-only iterator is not a useful thing to be configured. We can
always make the <code class="sourceCode default">input_iterator</code>
move-only, as algorithms that deal with input ranges must already deal
with the non-copyability.</p></li>
<li><p>move-only view is still useful. (see
<code class="sourceCode default">std::function</code> vs
<code class="sourceCode default">std::move_only_function</code>)</p></li>
<li><p>const-iteratable will make the design super complicated as all
the types can be different between const and non-const.</p></li>
</ul>
<h1 data-number="5" id="implementation-experience"><span class="header-section-number">5</span> Implementation Experience<a href="#implementation-experience" class="self-link"></a></h1>
<ul>
<li>Reference implementation in the repo</li>
</ul>
<h1 data-number="6" id="wording"><span class="header-section-number">6</span> Wording<a href="#wording" class="self-link"></a></h1>
<h2 data-number="6.1" id="feature-test-macro"><span class="header-section-number">6.1</span> Feature Test Macro<a href="#feature-test-macro" class="self-link"></a></h2>
<p>```</p>
Expand Down
Loading

0 comments on commit a94b02d

Please sign in to comment.