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

P2226 A function template to move from an object and reset it to its default constructed state #930

Open
wg21bot opened this issue Oct 27, 2020 · 2 comments
Labels
B3 - addition Bucket 3 as described by P0592: material that is not mentioned in P0592 IS Ship vehicle: IS LEWG Library Evolution needs-revision Paper needs changes before it can proceed size - small paper size estimate

Comments

@wg21bot
Copy link
Collaborator

wg21bot commented Oct 27, 2020

P2226R0 A function template to move from an object and reset it to its default constructed state (Giuseppe D'Angelo)

@wg21bot wg21bot added LEWGI Library Evolution Incubator SG1 Concurrency SG20 Education labels Oct 27, 2020
@wg21bot wg21bot added this to the 2020-telecon milestone Oct 27, 2020
@brycelelbach brycelelbach added LEWG Library Evolution B3 - addition Bucket 3 as described by P0592: material that is not mentioned in P0592 IS Ship vehicle: IS size - small paper size estimate ready-for-library-evolution-mailing-list-review This paper needs to be discussed on the Library Evolution mailing list and removed LEWGI Library Evolution Incubator SG20 Education SG1 Concurrency labels Nov 16, 2020
@jensmaurer jensmaurer modified the milestones: 2020-telecon, 2021-telecon Dec 28, 2020
@brycelelbach brycelelbach added the scheduled-for-library-evolution This paper has been scheduled for one of the groups: LEWG, LEWG Incubator, or a Mailing List review label May 26, 2021
@inbal2l
Copy link
Collaborator

inbal2l commented Sep 28, 2021

Summarizing the LEWG ML review (ended on 2021-Sep-28):

  • The names "take", "take_assign" were generally supported. 
  • There was some concern about wrong usage:
    • My main concern is that the short name might lead users astray.  Novices will reach for existing_object = take(object) because it looks simpler, but it's not actually simpler or faster, as Section 3.4 points out. take has fewer characters than exchange, but take is more specialized.
    • (...) Here are some places where it may increase, not decrease, the error-proneness.
  • There seems to be a concern about the motivation of adding std::take (considering std::exchange is provided, and it's flaws), especially about increasing the number of facilities.
    • Arthur's comments about codegen at https://lists.isocpp.org/std-proposals/2020/09/1901.php seem relevant. std::exchange is already potentially worse than just writing the same code by hand, and the proposed 'take' doesn't improve anything.
    • If an exception is thrown, there is no guarantee that other.m_keys.size() == other.m_values.size(). That makes the state of the source object other invalid, not valid-but-unspecified.  Unless the type takes other precautions, it invalidates code such as: other.erase(other.begin(), other.end());
  • Some recommendations to not pursue with the paper. Alternatively, there were some suggestions to improve "std::exchange".

Outcome: I would recommend addressing the possibility of improving "std::exchange" in a new revision, as well as addressing the "safety" (validity) of the operation if an exception is thrown.
Although there were a few voices to not pursue, I would recommend that if willing, the author should make his claims in an LEWG telecon. Preferably, we should address the complete topic, including things which came up regarding std::exchange (as B3 since this is a new facility / non urgent fix).

@inbal2l inbal2l added needs-revision Paper needs changes before it can proceed and removed scheduled-for-library-evolution This paper has been scheduled for one of the groups: LEWG, LEWG Incubator, or a Mailing List review ready-for-library-evolution-mailing-list-review This paper needs to be discussed on the Library Evolution mailing list labels Sep 28, 2021
@jensmaurer jensmaurer removed this from the 2021-telecon milestone Nov 12, 2021
@brycelelbach
Copy link

Closing due to more than 1 year of inactivity. Please re-open if further work is expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B3 - addition Bucket 3 as described by P0592: material that is not mentioned in P0592 IS Ship vehicle: IS LEWG Library Evolution needs-revision Paper needs changes before it can proceed size - small paper size estimate
Projects
None yet
Development

No branches or pull requests

4 participants