Friday, June 21, 2013

FeedaMail: Comments for Sutter’s Mill

feedamail.com Comments for Sutter's Mill

Comment on GotW #92 Solution: Auto Variables, Part 1 by Maxim Yanchenko

@Herb, thanks for the article!
2 questions as I didn’t chase it closely:
1) Will auto pick type attributes like alignment? The code I mean is smth like:

  typedef float aligned_block[4] alignas(16);  aligned_block a{...};  auto b = a; // is b aligned on 16?  

2) what about explicit auto? Is there any protection for private classes that we don’t want to expose (e.g. because it holds references to temporary objects from the enclosing full expression)?

Read More »

Comment on GotW #91 Solution: Smart Pointer Parameters by earwicker

re: Herb’s caveat “(Yes, you have to be careful if the smart pointer parameter can be aliased, but in this respect it's no different than any other aliased object).”

Reminds me of the guy who was hitting himself with a hammer. When his doctor told him “Stop hitting yourself with a hammer”, he replied “Oh, come on, you can’t blame the hammer. It would be just as bad if I hit myself with a brick or anything else for that matter!”

Yes, if g calls f then as long as f is still running, then g is still running. But g could pass to f a member variable, m, which presently refers to an object, and then some unholy, filthy chain of callbacks set off within f could reach back and cause m to be mutated, all while f – and therefore g – still have not returned.

So Herb’s paragraph “However, we already get this for free…” would seem to be followed by the caveat “… (except when we don’t).” What actual firm claim is being made here? When can it be relied on? How can we tell?

Read More »
 
Delievered to you by Feedamail.
Unsubscribe

No comments:

Post a Comment