Conversation started Jun 24, 2011 at 11:24.
Jun 24, 2011 11:24
what do you make of is_this_ill_formed((standard_layout{}, 0)) where the function accepts an int? This was my original intent but I was under the impression that the lifetime of standard_layout{} was only the subexpression, not the full-expression.
The lifetime is always at least the full-expression. Otherwise, temporaries would be completely useless.
@LucDanton full-expression
It's the semicolon that cleans up the temps.
@LucDanton This still "works", but again, you are modifying a temporary through an lvalue. I don't think this is what we're after.
An even better example then (but as pointed out earlier by Fred, I still need an lvalue: global)
Jun 24, 2011 11:25
@MartinhoFernandes ugh!
@FredOverflow I've successfully made use of the example, though, with the caveat that it's not what the question is about. Which is nice.
@MartinhoFernandes Semicolons don't clean anything up! OCD alert!
Well, there are exceptions to this rule. For example, in if (std::string() == "") { foo; bar; baz; } the temporary will be destroyed at the closing parenthesis after the comparison.
Now, I 'm getting thoroughly confused.
@MartinhoFernandes Semicolons end statements. That's it!
Jun 24, 2011 11:27
Ok, got it. OCD threw me off. Was that "Obsessive compulsive disorder" (which confused me) or something else?
@FredOverflow What's the full-expression there? std::string() == "", no?
exactly
@FredOverflow Then it's not an exception to anything
So not every full-expression is terminated by a semicolon. Only expression-statements :)
@TomalakGeretkal It's an exception to the simplified "semicolons clean up temps" 'rule' which works 90% of the time.
@MartinhoFernandes Aye. When people attribute magical powers to things like semicolons based on empirically observed behaviour (that actually is not attributable to the semicolon itself but to more complex semantics), my OCD twitches
@FredOverflow Ah, you were talking about that one.
Jun 24, 2011 11:28
What is OCD?
Obsessive compulsive disorder
Obsessive–compulsive disorder (OCD) is an anxiety disorder characterized by intrusive thoughts that produce uneasiness, apprehension, fear, or worry, by repetitive behaviors aimed at reducing the associated anxiety, or by a combination of such obsessions and compulsions. Symptoms of the disorder include excessive washing or cleaning; repeated checking; extreme hoarding; preoccupation with sexual, violent or religious thoughts; aversion to particular numbers; and nervous rituals, such as opening and closing a door a certain number of times before entering or leaving a room. These sympt...
Oft cited by software developers in a mild form, explaining pedanticism and general pickiness
But you are correct of course, the full-expression rule has no exceptions. Well, except for the extending-lifetime exception when binding to local references :) But that's it.
I almost forgot my tea! runs to kitchen
> Repetitive handwashing is a common OCD symptom
Oh, I have that.
What about recompiling after every new line of written code? Is that also OCD? :)
Jun 24, 2011 11:31
For example, I'm incredibly diligent when I program, and I'm known for considering all the cases and really going through the motions to make sure things aren't missed out. That's not to say that I'm perfect: of course, I get this wrong as often as anyone else; but it's the approach. And that is sometimes attributed to a higher rate of mild OCD amongst the technically-inclined than in others.
I do that too.
And typing :w all the time (or Ctrl+S on lower-class editors).
I think that in effect, the paragraph is much more about non-class types than class types. I.e. as my example shows one can always use tricks to modify an object without an lvalue to the object itself, but that's fine.
I'd forgotten until now, but my Ctrl-S finger is bloody itchy
 
Conversation ended Jun 24, 2011 at 11:32.