Skip to content
New issue

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

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

Already on GitHub? # to your account

[containers] Tentative P/R for [LWG4123] "Container effects use..." #7207

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Aug 11, 2024

  1. [containers] Tentative P/R for [LWG4123] "Container effects use..."

    https://cplusplus.github.io/LWG/issue4123
    
    The superficial problem here is that "assignment operator or move assignment operator"
    is redundant. The real problem is that the container might use an assignment operator
    that's not a copy-or-move assignment operator, and/or a constructor that's not
    a copy-or-move constructor.
    
    We want to preserve the idea of "constructing or assigning a T from another T,"
    as opposed to from a U. But we want to permit all the various ways of doing that,
    such as "implicitly convert the source T to U, then assign from U to T," as shown
    in this Godbolt: https://godbolt.org/z/8Ybbxr19e
    (If one of those various ways throws, then there might be effects, even though
    the throwing culprit wasn't a constructor or assignment operator of `T` at all.)
    
    We have similar problems in [optional], e.g.
    https://eel.is/c++draft/optional.optional#optional.ctor-6
     "Any exception thrown by the selected constructor of T."
     (Overload resolution might select a conversion operator, not a constructor.)
    https://eel.is/c++draft/optional.optional#optional.assign-7
     "If an exception is thrown during the call to T's copy constructor, no effect.
     If an exception is thrown during the call to T's copy assignment, the state
     of its contained value is as defined by the exception safety guarantee of T's
     copy assignment."
     (Overload resolution might select a constructor that is not a copy constructor,
     resp. an assignment [operator] that is not a copy assignment operator.)
    
    I have not attempted to fix those problems in this patch.
    Quuxplusone committed Aug 11, 2024
    Configuration menu
    Copy the full SHA
    b502b60 View commit details
    Browse the repository at this point in the history