Questions tagged [full-expression]
7 questions
37
votes
2 answers
Lifetime of temporaries
The following code works fine, but why is this correct code? Why is the "c_str()" pointer of the temporary returned by foo() valid? I thought, that this temporary is already destroyed when bar() is entered - but it doesn't seem to be like this. So,…

Frunsi
- 7,099
- 5
- 36
- 42
12
votes
2 answers
Full-expression boundaries and lifetime of temporaries
Possible Duplicate:
C++: Life span of temporary arguments?
It is said that temporary variables are destroyed as the last step in evaluating the full-expression, e.g.
bar( foo().c_str() );
temporary pointer lives until bar returns, but what for…

Vasaka
- 1,953
- 1
- 19
- 30
5
votes
0 answers
How to understand the sentence "full-expression must be a constant expression" which mentioned in the standard
Ago, Some rules in the standard that say they are applied to expression, I was confused about whether these rules can also be applied to full-expression arbitrarily. I get an answers in that question. However, there are some rules like "the…

xmh0511
- 7,010
- 1
- 9
- 36
5
votes
1 answer
Intent of [basic.execution] p5 sentence 2
[basic.execution] p5 sentence 2 states:
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.
However, the intent of…

Krystian S
- 1,586
- 7
- 23
3
votes
0 answers
C++ 17 full-expression standard definition
This paragraph from the C++ 17 standard draft states, among others, that:
A full-expression is:
-an unevaluated operand,
-a constant-expression ([expr.const]),
-an init-declarator ([dcl.decl]) or a mem-initializer ([class.base.init]), including the…

user42768
- 1,951
- 11
- 22
2
votes
5 answers
Dereference operator on temporary object
In a code like this
#include
#include
struct A {
int i;
A() {
std::cout << "A()" << std::endl;
}
~A() {
std::cout << "~A()" << std::endl;
}
};
void f(const A& a) {
std::cout << "f(A)"…

tmlen
- 8,533
- 5
- 31
- 84
2
votes
1 answer
"full-expression" versus "full expression"
I was looking at this post in GitHub, but I couldn't understand what the OP meant by this:
"full expression" suggest that it is a kind of expression, but sometimes it is not.
My interpretation is that a "full-expression" (term used in the Standard)…

João Afonso
- 1,934
- 13
- 19