Title
DefaultConstructible is not defined
Status
c++11
Section
[utility.arg.requirements]
Submitter
Pablo Halpern

Created on 2007-09-12.00:00:00 last changed 143 months ago

Messages

Date: 2013-01-25.00:32:44

Proposed resolution:

In section [utility.arg.requirements], before table 33, add the following table:

Table 33: DefaultConstructible requirements [defaultconstructible]
expressionpost-condition
T t;Object t is default-initialized.
T u{};Object u is value-initialized.
T()
T{}
A temporary object of type T is value-initialized.
Date: 2013-01-25.00:32:44

[ Rationale is obsolete. ]

Date: 2013-01-25.00:32:44

[ San Francisco: ]

We believe concepts will solve this problem (N2774).

Date: 2010-02-04.00:00:00

[ 2010-02-04: Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]

Date: 2010-01-24.00:00:00

[ 2010-01-24 At Alisdair's request, moved his proposal into the proposed wording section. The old wording is preserved here: ]

In section [utility.arg.requirements], before table 33, add the following table:

Table 33: DefaultConstructible requirements [defaultconstructible]

expression

post-condition

T t;
T()

T is default constructed.

Date: 2013-01-25.00:32:44

[ 2009-10 Santa Cruz: ]

Leave Open. Core is looking to make Alisdair's proposed resolution correct.

Date: 2009-10-03.00:00:00

[ 2009-10-03 Daniel adds: ]

The suggested definition T{} describing it as value-initialization is wrong, because it belongs to list-initialization which would - as the current rules are - always prefer a initializer-list constructor over a default-constructor. I don't consider this as an appropriate definition of DefaultConstructible. My primary suggestion is to ask core, whether the special case T{} (which also easily leads to ambiguity situations for more than one initializer-list in a class) would always prefer a default-constructor - if any - before considering an initializer-list constructor or to provide another syntax form to prefer value-initialization over list-initialization. If that fails I would fall back to suggest to use the expression T() instead of T{} with all it's disadvantages for the meaning of the expression

T t();
Date: 2009-08-18.00:00:00

[ 2009-08-18 Alisdair adds: ]

Looking at the proposed table in this issue, it really needs two rows:

Table 33: DefaultConstructible requirements [defaultconstructible]
expressionpost-condition
T t;t is default-initialized.
T{}Object of type T is value-initialized.

Note I am using the new brace-initialization syntax that is unambiguous in all use cases (no most vexing parse.)

Date: 2009-08-17.00:00:00

[ 2009-08-17 Daniel adds "[defaultconstructible]" to table title. 408 depends upon this issue. ]

Date: 2009-07-28.00:00:00

[ 2009-07-28 Reopened by Alisdair. No longer solved by concepts. ]

Date: 2013-01-25.00:32:44

[ Bellevue: ]

Walking into the default/value-initialization mess...

Why two lines? Because we need both expressions to be valid.

AJM not sure what the phrase "default constructed" means. This is unfortunate, as the phrase is already used 24 times in the library!

Example: const int would not accept first line, but will accept the second.

This is an issue that must be solved by concepts, but we might need to solve it independantly first.

It seems that the requirements are the syntax in the proposed first column is valid, but not clear what semantics we need.

A table where there is no post-condition seems odd, but appears to sum up our position best.

At a minimum an object is declared and is destructible.

Move to open, as no-one happy to produce wording on the fly.

Date: 2007-09-12.00:00:00

The DefaultConstructible requirement is referenced in several places in the August 2007 working draft N2369, but is not defined anywhere.

History
Date User Action Args
2013-01-25 00:32:44adminsetmessages: + msg6373
2013-01-25 00:32:44adminsetmessages: + msg6372
2013-01-25 00:32:44adminsetmessages: + msg6371
2013-01-25 00:32:44adminsetmessages: + msg6370
2013-01-25 00:32:44adminsetmessages: + msg6369
2013-01-25 00:32:44adminsetmessages: + msg6368
2013-01-25 00:32:44adminsetmessages: + msg6367
2013-01-25 00:32:44adminsetmessages: + msg6366
2013-01-25 00:32:44adminsetmessages: + msg6365
2013-01-25 00:32:44adminsetmessages: + msg6364
2013-01-25 00:32:44adminsetmessages: + msg6363
2007-09-12 00:00:00admincreate