Title
Apparently-bogus definition of is_empty type trait
Status
open
Section
[meta.unary.prop]
Submitter
Richard Smith

Created on 2014-02-01.00:00:00 last changed 90 months ago

Messages

Date: 2016-10-10.20:46:47

Proposed resolution:

Modify Table 38 — Type property predicates for is_empty as follows:

T is a class type, but not a union type,is a non-union class type with no non-static data members other than, no unnamed bit-fields of non-zero length 0, no virtual member functions, no virtual base classes, and no base class B for which is_empty_v<B> is false.

Date: 2017-02-02.00:41:18

[ 2016-10 Telecon ]

Should probably point at section 1.8 for some of this. Status back to 'Open'

Date: 2016-10-05.22:21:09

[ 2016-10 by Marshall - this PR incorrectly highlighted changed portions ]

Modify Table 38 — Type property predicates for is_empty as follows:

T is a non-union class type with no non-static data members other than, no unnamed bit-fields of non-zero length 0, no virtual member functions, no virtual base classes, and no base class B for which is_empty_v<B> is false.

Date: 2016-10-05.22:21:09

[ 2016-08 Chicago ]

Walter says: We want is_empty_v<S> to produce false as a result. Therefore, we recommend adoption of the first of the issue's suggestions.

Tuesday AM: Moved to Tentatively Ready

Previous resolution [SUPERSEDED]:

Date: 2014-02-01.00:00:00

The 'Condition' for std::is_empty is listed as:

"T is a class type, but not a union type, with no non-static data members other than bit-fields of length 0, no virtual member functions, no virtual base classes, and no base class B for which is_empty<B>::value is false."

This is incorrect: there is no such thing as a non-static data member that is a bit-field of length 0, since bit-fields of length 0 must be unnamed, and unnamed bit-fields are not members (see [class.bit] p2).

It also means that classes such as:

struct S {
 int : 3;
};

are empty (because they have no non-static data members). There's implementation divergence on the value of is_empty<S>::value.

I'm not sure what the purpose of is_empty is (or how it could be useful), but if it's desirable for the above type to not be treated as empty, something like this could work:

"T is a class type, but not a union type, with no non-static data members other than, no unnamed bit-fields of non-zero length 0, no virtual member functions, no virtual base classes, and no base class B for which is_empty<B>::value is false."

and if the above type should be treated as empty, then this might be appropriate:

"T is a class type, but not a union type, with no (named) non-static data members other than bit-fields of length 0, no virtual member functions, no virtual base classes, and no base class B for which is_empty<B>::value is false."

History
Date User Action Args
2016-10-10 20:46:47adminsetmessages: + msg8551
2016-10-10 20:46:47adminsetstatus: ready -> open
2016-10-05 22:21:09adminsetmessages: + msg8538
2016-08-02 17:30:37adminsetstatus: new -> ready
2016-08-02 13:14:37adminsetmessages: + msg8305
2016-08-02 13:14:37adminsetmessages: + msg8304
2014-02-01 00:00:00admincreate