What does it mean to evaluate object creation?

I came across a sentence: "Even when the creation of a temporary object is not evaluated," in the standard 12.2 and I do not understand what they mean.

So I read about expressions, but I still don't understand what they mean, what they meant by that. The reason, I believe, is that I was struggling to define my definition of unvalued expressions and apply the quotation above to it.

So can someone please tell me what they mean by "Even when creating a temporary object is not appreciated"?

Context:

Temporary classes of the class type are created in various contexts: binding a reference to prvalue (8.5.3), returning the value (6.6.3), a transformation that creates a prvalue (4.1, 5.2.9, 5.2.11, 5.4), throwing an exception ( 15.1), included in the handler (15.3), and in some initialization (8.5). [Note: lifetime of exception objects described in 15.1. - end note] Even when creating a temporary object is not evaluated (Section 5) or otherwise avoided (12.8), all semantic restrictions must be respected as if the temporary object was created and subsequently destroyed. [Note: even if there is no call to the constructor of the destructor or copy / move, all semantic restrictions, such as accessibility (clause 11) and the function are deleted (8.4.3), is fulfilled. However, in the special case of a function call used as the decltype-specifier operand (5.2.2), temporary input is not entered, so the above does not apply to the value of any such function call. - end note]

+5
source share
1 answer

There are certain contexts in which you can enter an expression that is not actually executed at run time. The arguments sizeof and decltype , for example, are not actually executed. They exist solely for the compiler to calculate the type of result.

These contexts are called " unreasonable contexts ." This is what we are talking about. And he says that even in an invaluable context, the expression that constructs the object should still be a valid form of object initialization.

+6
source

Source: https://habr.com/ru/post/1270160/


All Articles