Skip to content

Why do deduction guides for take_view and drop_view have different constraints? LWG 3447 #3997

Description

@cpplearner

In [range.take.view], the deduction guide for take_view is declared as:

  template<range R>
    take_view(R&&, range_difference_t<R>)
      -> take_view<views::all_t<R>>;

In [range.drop.view], the deduction guide for drop_view is declared as:

  template<class R>
    drop_view(R&&, range_difference_t<R>) -> drop_view<views::all_t<R>>;

Note the difference between their template parameter lists.

AFAIK there's no difference in effect, because views::all_t only accepts a viewable_range.

Can they be declared in a more similar way?

Activity

  1. jensmaurer commented on May 14, 2020

    @jensmaurer
    Member

    I believe the presence or absence (and the spelling) of associated constraints influences partial ordering, before the shape of the target type is even considered. So, this does not appear to be an editorial change.

    @CaseyCarter , @jwakely ?

  2. jwakely commented on May 14, 2020

    @jwakely
    Member

    drop_view was added later by P1035R7, so the inconsistency could just be an oversight, but I agree it's not editorial.

  3. jwakely commented on May 14, 2020

    @jwakely
    Member

    It looks like that take_view guide and this one are the only constrained guides for view adaptors:

    template<input_range R>
        split_view(R&&, range_value_t<R>)
          -> split_view<views::all_t<R>, single_view<range_value_t<R>>>;
    
  4. CaseyCarter commented on May 14, 2020

    @CaseyCarter
    Contributor

    take_view significantly predates drop_view. When we added take_view, the range constraint was necessary to ensure that iterator_t<R> was well-formed in iter_difference_t<iterator_t<R>>.

    P1035 constrains iterator_t itself with range, and added range_difference_t<R> as a range-constrained alias for iter_difference_t<iterator_t<R>> so neither drop_view nor take_view require this constraint. P1035 had blanket editorial instructions to replace iter_difference_t<iterator_t<R>> with range_difference_t<R>, but it didn't occur to the authors to also audit constraints elsewhere and remove any we'd made extraneous.

    TLDR: Changing this would have no normative effect, but it falls into that grey area where we need experts to attest to that. I suggest filing an LWG issue.

  5. jensmaurer commented on May 16, 2020

    @jensmaurer
    Member

    Handled by LWG3447.

  6. changed the title [-]Why do deduction guides for take_view and drop_view have different constraints?[/-] [+]Why do deduction guides for take_view and drop_view have different constraints? LWG 3447[/+] on May 16, 2020
  7. added
    not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.
    on May 16, 2020
  8. JohelEGP commented on Dec 29, 2020

    @JohelEGP
    Contributor

    Status: WP

    This can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lwgIssue must be reviewed by LWG.not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions