Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[range.subrange.general,range.adaptors] Use present only if condition is true #6146

Merged
merged 1 commit into from Mar 19, 2023

Conversation

JohelEGP
Copy link
Contributor

Running git grep -C 1 'present only' * in sources shows:

declarations.tex-\grammarterm{init-declarator} or \grammarterm{member-declarator}
declarations.tex:shall be present only if the declarator declares a
declarations.tex-templated function\iref{dcl.fct}.
--
iterators.tex-    using iterator_type = I;
iterators.tex:    using value_type = iter_value_t<I>;                         // present only
iterators.tex-                        // if \tcode{I} models \libconcept{indirectly_readable}
iterators.tex-    using difference_type = iter_difference_t<I>;
iterators.tex:    using iterator_concept = typename I::iterator_concept;      // present only
iterators.tex-                        // if the \grammarterm{qualified-id} \tcode{I::iterator_concept} is valid and denotes a type
iterators.tex:    using iterator_category = typename I::iterator_category;    // present only
iterators.tex-                        // if the \grammarterm{qualified-id} \tcode{I::iterator_category} is valid and denotes a type
--
ranges.tex-    S @\exposid{end_}@ = S();                                           // \expos
ranges.tex:    @\exposidnc{make-unsigned-like-t}@<iter_difference_t<I>> @\exposid{size_}@ = 0;   // \expos; present only
ranges.tex-                                                            // when \exposid{StoreSize} is \tcode{true}
--
ranges.tex-    using iterator_concept = @\seebelow@;
ranges.tex:    using iterator_category = input_iterator_tag;       // present only if \tcode{W} models \libconcept{incrementable} and
ranges.tex-                                                        // \tcode{\placeholdernc{IOTA-DIFF-T}(W)} is an integral type
--
ranges.tex-
ranges.tex:    @\exposidnc{non-propagating-cache}@<remove_cv_t<@\exposidnc{InnerRng}@>> @\exposid{inner_}@;    // \expos, present only
ranges.tex-                                                            // when \tcode{!is_reference_v<\exposid{InnerRng}>}
--
ranges.tex-    V @\exposid{base_}@ = V();                                          // \expos
ranges.tex:    @\exposid{non-propagating-cache}@<remove_cv_t<@\exposid{InnerRng}@>> @\exposid{inner_}@;   // \expos, present only
ranges.tex-                                                            // when \tcode{!is_reference_v<\exposid{InnerRng}>}
--
ranges.tex-
ranges.tex:    @\exposidnc{non-propagating-cache}@<iterator_t<V>> @\exposid{current_}@;              // \expos, present only
ranges.tex-                                                                // if \tcode{!\libconcept{forward_range}<V>}
--
ranges.tex-
ranges.tex:    iterator_t<@\exposidnc{Base}@> @\exposid{current_}@ = iterator_t<@\exposidnc{Base}@>();         // \expos, present only
ranges.tex-                                                            // if \tcode{V} models \libconcept{forward_range}
--
ranges.tex-
ranges.tex:    using iterator_category = input_iterator_tag;           // present only if \exposid{Base}
ranges.tex-                                                            // models \libconcept{forward_range}
--
ranges.tex-
ranges.tex:    using iterator_category = @\seebelownc@;                    // present only if \exposid{Base}
ranges.tex-                                                            // models \libconcept{forward_range}
--
ranges.tex-    iterator_t<@\exposid{Base}@> @\exposid{last_ele_}@  = iterator_t<@\exposid{Base}@>();   // \expos,
ranges.tex:                                               // present only if \tcode{\exposid{Base}} models \tcode{\exposconcept{slide-caches-first}}
ranges.tex-    range_difference_t<@\exposid{Base}@> @\exposid{n_}@ = 0;                    // \expos

Ignoring the first result, we have:

  • Present only if models-condition:
iterators.tex:    using value_type = iter_value_t<I>;                         // present only
iterators.tex-                        // if \tcode{I} models \libconcept{indirectly_readable}
ranges.tex:    iterator_t<@\exposidnc{Base}@> @\exposid{current_}@ = iterator_t<@\exposidnc{Base}@>();         // \expos, present only
ranges.tex-                                                            // if \tcode{V} models \libconcept{forward_range}
ranges.tex:    using iterator_category = input_iterator_tag;           // present only if \exposid{Base}
ranges.tex-                                                            // models \libconcept{forward_range}
ranges.tex:    using iterator_category = @\seebelownc@;                    // present only if \exposid{Base}
ranges.tex-                                                            // models \libconcept{forward_range}
ranges.tex:                                               // present only if \tcode{\exposid{Base}} models \tcode{\exposconcept{slide-caches-first}}
  • Present only if English-condition:
iterators.tex:    using iterator_concept = typename I::iterator_concept;      // present only
iterators.tex-                        // if the \grammarterm{qualified-id} \tcode{I::iterator_concept} is valid and denotes a type
iterators.tex:    using iterator_category = typename I::iterator_category;    // present only
iterators.tex-                        // if the \grammarterm{qualified-id} \tcode{I::iterator_category} is valid and denotes a type
ranges.tex:    using iterator_category = input_iterator_tag;       // present only if \tcode{W} models \libconcept{incrementable} and
ranges.tex-                                                        // \tcode{\placeholdernc{IOTA-DIFF-T}(W)} is an integral type
  • Present only 1 if, 3 when bool-condition:
ranges.tex:    @\exposidnc{make-unsigned-like-t}@<iter_difference_t<I>> @\exposid{size_}@ = 0;   // \expos; present only
ranges.tex-                                                            // when \exposid{StoreSize} is \tcode{true}
ranges.tex:    @\exposidnc{non-propagating-cache}@<remove_cv_t<@\exposidnc{InnerRng}@>> @\exposid{inner_}@;    // \expos, present only
ranges.tex-                                                            // when \tcode{!is_reference_v<\exposid{InnerRng}>}
ranges.tex:    @\exposid{non-propagating-cache}@<remove_cv_t<@\exposid{InnerRng}@>> @\exposid{inner_}@;   // \expos, present only
ranges.tex-                                                            // when \tcode{!is_reference_v<\exposid{InnerRng}>}
ranges.tex:    @\exposidnc{non-propagating-cache}@<iterator_t<V>> @\exposid{current_}@;              // \expos, present only
ranges.tex-                                                                // if \tcode{!\libconcept{forward_range}<V>}

#6128 adds 2 when bool-condition, 2 if models-condition:

    @\exposidnc{non-propagating-cache}@<iterator_t<V>> @\exposidnc{outer_}@;            // \expos, present only
                                                            // when \tcode{!\libconcept{forward_range}<V>}
    @\exposidnc{OuterIter}@ @\exposid{outer_}@ = @\exposidnc{OuterIter}@();                     // \expos, present only
                                                        // if \exposid{Base} models \libconcept{forward_range}
    @\exposid{non-propagating-cache}@<iterator_t<V>> @\exposid{outer_it_}@;         // \expos, present only
                                                            // when \tcode{!\libconcept{forward_range}<V>}
    @\exposid{OuterIter}@ @\exposid{outer_it_}@ = @\exposid{OuterIter}@();                          // \expos, present only
                                                                // if \exposid{Base} models \libconcept{forward_range}

This fixes the only "present only if bool-condition" to use "when".

@tkoeppe
Copy link
Contributor

tkoeppe commented Mar 13, 2023

@jwakely, @CaseyCarter any thoughts?

@CaseyCarter
Copy link
Contributor

This change implies that there are rules that determine for which cases we choose "present when" vs. "present only if", which I think overcomplicates things and isn't a direction we should pursue. I'd much rather see us consistently use either "present when" or "present only if" (I have no strong preference, the first is slightly shorter), and use "is true" with bool expressions to be consistent with the specification style of requirements for library functions.

@JohelEGP JohelEGP changed the title [range.lazy.split.view] Use present only *when* bool-condition [range.subrange.general,range.adaptors] Use present only if condition is true Mar 13, 2023
@CaseyCarter
Copy link
Contributor

Awesome, @JohelEGP - thanks!

@tkoeppe
Copy link
Contributor

tkoeppe commented Mar 13, 2023

Strictly speaking, "present only if X" does not require the thing to be present. It just requires it to not be present if X is false. @CaseyCarter: thoughts?

source/ranges.tex Outdated Show resolved Hide resolved
@tkoeppe tkoeppe merged commit f24d86d into cplusplus:main Mar 19, 2023
2 checks passed
@JohelEGP JohelEGP deleted the range.lazy.split.view branch March 19, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants