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

P0288R9 move_only_function editorial fixes #4960

Closed
4 of 5 tasks
jensmaurer opened this issue Oct 3, 2021 · 7 comments
Closed
4 of 5 tasks

P0288R9 move_only_function editorial fixes #4960

jensmaurer opened this issue Oct 3, 2021 · 7 comments
Assignees
Milestone

Comments

@jensmaurer
Copy link
Member

jensmaurer commented Oct 3, 2021

  • [func.wrap.mov.con] Args -> ArgTypes
  • Create LWG issue to make move assignment operator noexcept
  • "f is lvalue of type F" -> "and F is the type of that target object"
  • change phrasing "targets an object" to "has a target object"
  • change phrasing "targets an object" to "has a target object" for std::function [func.wrap.func.con], too

See http://lists.isocpp.org/lib/2021/10/20588.php

@frederick-vs-ja
Copy link
Contributor

Perhaps another LWG issue is needed to add constraints to the assignment operator template.

@jensmaurer
Copy link
Member Author

@jwakely , do we have those LWG issues?

@jwakely
Copy link
Member

jwakely commented Oct 21, 2021

The move assignment operator is intentionally not noexcept, to leave room for an allocator-aware move_only_function in future, which might need to allocate.

Perhaps another LWG issue is needed to add constraints to the assignment operator template.

No, because it already has the constraints from the constructor, through the use of "Effects: Equivalent to ..."

I think this can be closed.

@jwakely
Copy link
Member

jwakely commented Oct 21, 2021

See [structure.specifications] p4.

@cpplearner
Copy link
Contributor

Perhaps another LWG issue is needed to add constraints to the assignment operator template.

No, because it already has the constraints from the constructor, through the use of "Effects: Equivalent to ..."

So is it intentional that assigning std::in_place_type<int(*)()> to a std::move_only_function<int()> is permitted?

@jwakely
Copy link
Member

jwakely commented Oct 21, 2021

The wording in the paper reflects the design that was approved. If you think the design was wrong, please file an LWG issue.

I find it very hard to care about code that does f = std::in_place_type<int(*)()> because that seems very unlikely to happen by mistake, and if you want to do something so silly, then go ahead.

This also compiles fine, despite being useless and silly:

std::move_only_function<int()> f(std::in_place_type<int(*)()>);

If you want to store a null pointer you can do so with nullptr, or with silly nonsense like this. 🤷

@jwakely
Copy link
Member

jwakely commented Oct 21, 2021

Oh, although the "*this has a target object unless any of the following hold" condition only applies to the move_only_function(F&&) constructor, so constructing from std::in_place_type<int(*)()> creates a target object (i.e. a non-empty move_only_function) that will crash if called. That's not an issue with the assignment operator though. And it's also seems like a case where "play stupid games, win stupid prizes" applies.

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

No branches or pull requests

4 participants