Title
Deprecated implicit copy assignment in example
Status
c++11
Section
6.7.7 [class.temporary]
Submitter
Ryou Ezoe

Created on 2011-01-25.00:00:00 last changed 130 months ago

Messages

Date: 2011-03-15.00:00:00

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

Date: 2011-01-25.00:00:00

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&)
    }
History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3363
2011-04-10 00:00:00adminsetstatus: open -> fdis
2011-01-25 00:00:00admincreate