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

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

Closed
cpplearner opened this issue May 14, 2020 · 6 comments · Fixed by #4380
Closed
Labels
lwg Issue must be reviewed by LWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.

Comments

@cpplearner
Copy link
Contributor

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?

@jensmaurer
Copy link
Member

jensmaurer commented May 14, 2020

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 ?

@jwakely
Copy link
Member

jwakely commented May 14, 2020

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

@jwakely
Copy link
Member

jwakely commented May 14, 2020

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>>>;

@CaseyCarter
Copy link
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.

@jensmaurer jensmaurer added the lwg Issue must be reviewed by LWG. label May 15, 2020
@jensmaurer
Copy link
Member

jensmaurer commented May 16, 2020

Handled by LWG3447.

@jensmaurer jensmaurer 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 May 16, 2020
@jensmaurer jensmaurer added the not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. label May 16, 2020
@JohelEGP
Copy link
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
Labels
lwg Issue must be reviewed by LWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants