Title
Deducing the type in new auto(x)
Status
cd2
Section
7.6.2.8 [expr.new]
Submitter
UK

Created on 2009-03-03.00:00:00 last changed 170 months ago

Messages

Date: 2009-10-15.00:00:00

[Voted into WP at October, 2009 meeting.]

Date: 2009-07-15.00:00:00

Proposed resolution (July, 2009):

Change 7.6.2.8 [expr.new] paragraph 2 as follows:

If the auto type-specifier appears in the type-specifier-seq of a new-type-id or type-id of a new-expression, the new-expression shall contain a new-initializer of the form

    ( assignment-expression )

The allocated type is deduced from the new-initializer as follows: Let (e) be e be the assignment-expression in the new-initializer and T be the new-type-id or type-id of the new-expression, then the allocated type is the type deduced for the variable x in the invented declaration (9.2.9.7 [dcl.spec.auto]):

    T x = e x(e);

[Example:...

Date: 2009-03-03.00:00:00
N2800 comment UKĀ 71

The type of an allocated object wih the type specifier auto is determined by the rules of copy initialization, but the initialization applied will be direct initialization. This would affect classes which declare their copy constructor explicit, for instance. For consistency, use the same form of initiailization for the deduction as the new expression.

History
Date User Action Args
2010-03-29 00:00:00adminsetstatus: dr -> cd2
2009-11-08 00:00:00adminsetmessages: + msg2439
2009-11-08 00:00:00adminsetstatus: ready -> dr
2009-08-03 00:00:00adminsetmessages: + msg2150
2009-08-03 00:00:00adminsetstatus: open -> ready
2009-03-03 00:00:00admincreate