Comment regarding full-expression in [intro.execution] (12)

72 vistas
Ir al primer mensaje no leído

razvyb...@gmail.com

no leída,
9/08/2017, 6:22:29 a. m.9/08/17
para ISO C++ Standard - Discussion
In paragraph 12 of [intro.execution] (http://eel.is/c++draft/intro.execution#12) (defining full-expressions), there is this code sample:

S s1(1);//full-expression is call of S::S(int)

S s1(1) is an init-declarator, correct? Therefore, as stated in the same paragraph (third dot), it is a full-expression.

Why does the comment say that the full-expression is the call to the constructor? Shouldn't "full-expression includes call of S::S(int)" be the correct comment? Am I not understanding this correctly?

Language Lawyer

no leída,
9/08/2017, 2:17:30 p. m.9/08/17
para ISO C++ Standard - Discussion
среда, 9 августа 2017 г., 13:22:29 UTC+3 пользователь razvyb...@gmail.com написал:
The http://eel.is/c++draft/intro.execution#12.3 is indeed confusing, because it claims that declarator is expression, which doesn't seem to be formally correct.
I think the answer could be found in this http://eel.is/c++draft/class.base.init#7.note-1 :
The initialization performed by each mem-initializer constitutes a full-expression.
 
Any expression in a mem-initializer is evaluated as part of the full-expression that performs the initialization.

So neither init-declarators nor mem-initializers are full-expressions, but the initializations perfomed by them are. Looks like someone decided to shorten the definition of full-expression a bit and turned "A full-expression is constituted by the initialization performed by an init-declarator or a mem-initializer" into "A full-expression in an init-declarator or a mem-initializer".

If we accept this interpretation, then the example will look correct.

razvyb...@gmail.com

no leída,
9/08/2017, 2:48:25 p. m.9/08/17
para ISO C++ Standard - Discussion
Thank you for your response. I think there is another contradiction in this paragraph. It says that "If a language construct is defined to produce an implicit call of a function, a use of the language construct is considered to be an expression for the purposes of this definition.". I believe an init-declarator is such a construct. Therefore, considering this passage, again, the "construct" itself should be considered the full-expression.

I also have another question related to this paragraph. What other "constructs" are there that respect the condition of the passage that I quoted (produce an implicit call of a function) and are not expressions? Because I only had in mind the init-declarator, but this is treated specially by this paragraph.
Se borró el mensaje

razvyb...@gmail.com

no leída,
17/08/2017, 4:36:09 a. m.17/08/17
para ISO C++ Standard - Discussion
I believe that an init-declarator is indeed a full-expression. Because in the following code sample:

arrayOfT[] = {T(), T()};


there is no implicit function call, therefore there is no "explicit initialization" performed by the init-declarator. I believe the comment is wrong. 
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos