Title
What is the “corresponding special member” of a variant member?
Status
cd5
Section
11.4.5.3 [class.copy.ctor]
Submitter
Richard Smith

Created on 2016-08-15.00:00:00 last changed 48 months ago

Messages

Date: 2017-08-15.00:00:00

Proposed resolution (August, 2017):

Change 11.4.5.3 [class.copy.ctor] paragraph 10 as follows:

An implicitly-declared copy/move constructor is an inline public member of its class. A defaulted copy/move constructor for a class X is defined as deleted (9.5.3 [dcl.fct.def.delete]) if X has:

  • a variant member with a non-trivial corresponding constructor and X is a union-like class,

  • a potentially constructed subobject type M (or array thereof) that cannot be copied/moved because overload resolution (12.2 [over.match]), as applied to find M's corresponding constructor, results in an ambiguity or a function that is deleted or inaccessible from the defaulted constructor,

  • a variant member whose corresponding constructor as selected by overload resolution is non-trivial,

  • any potentially constructed subobject of a type with a destructor that is deleted or inaccessible from the defaulted constructor, or,

  • for the copy constructor, a non-static data member of rvalue reference type.

Date: 2017-11-15.00:00:00

[Accepted as a DR at the November, 2017 meeting.]

According to 11.4.5.3 [class.copy.ctor] bullet 10.1,

A defaulted copy/move constructor for a class X is defined as deleted (9.5.3 [dcl.fct.def.delete]) if X has:

  • a variant member with a non-trivial corresponding constructor and X is a union-like class,

However, it is not clear from this specification how to handle an example like:

  struct A {
    A();
    A(const A&);
  };
  union B {
    A a;
  };

since there is no corresponding special member in A.

History
Date User Action Args
2020-12-15 00:00:00adminsetstatus: dr -> cd5
2018-02-27 00:00:00adminsetmessages: + msg6118
2016-08-15 00:00:00admincreate