This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 113d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-03-20


1237. Deprecated implicit copy assignment in example

Section: 6.7.7  [class.temporary]     Status: C++11     Submitter: Ryou Ezoe     Date: 2011-01-25

[Voted into the WP at the March, 2011 meeting as part of paper N3262.]

An implicit declaration of a copy assignment operator is deprecated if the class has a user-declared copy constructor or a user-declared destructor. However, the example in 6.7.7 [class.temporary] relies on such an implicit declaration; an explicit declaration for the copy assignment operator for class X should be provided:

    class X {
    public:
      X(int);
      X(const X&);
      ~X();
    };

    class Y {
    public:
      Y(int);
      Y(Y&&);
      ~Y();
    };

    X f(X);
    Y g(Y);

    void h() {
      X a(1);
      X b = f(X(2));
      Y c = g(Y(3));
      a = f(a);  // relies on implicitly-declared X::operator=(const X&)
    }