Saturday, June 22, 2013

FeedaMail: Comments for Sutter’s Mill

feedamail.com Comments for Sutter's Mill

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

“What actual firm claim is being made here?”

Absent aliasing, which is a problem no matter which kind of pointer you are using, and can’t be dealt with just by using a different kind of pointer, you can be guaranteed that the object will be alive for as long as the function call.

“When can it be relied on? How can we tell?”

It can be relied on as long as there is no aliasing of the pointer. As for how you can tell, that’s going to require that you look at your program to see if there is any aliasing going on.

Read More »

Comment on GotW #94 Special Edition: AAA Style (Almost Always Auto) by jlehrer

I don’t have an 11 compiler to play with right now or I’d answer this question myself.

What does this do:

auto i=1,f=2.0;

Does that make two integers, an int and a float, or two floats?

Read More »

Comment on GotW #93 Solution: Auto Variables, Part 2 by Adrian

@Jon: Yes, I’m familiar with Bjarne’s “too pedantic” comment, but I watched one of his presentations from 2012, and the examples in his slides used vector::size_type.

Having spent many blissful years with the compiler warning on reliably catching real bugs, and then a few years at another company with “int i” for loop (and therefore the warning disabled), I conclude that there’s nothing pedantic about it. Signed/unsigned bugs are insidious and hard to find. I’m not really worried about the for-loop indexes, but what we miss because those indexes force us to disable the warnings.

Read More »

Comment on GotW #94 Special Edition: AAA Style (Almost Always Auto) by Róbert Dávid

@jlehrer: That’s ill-formed, both have to deduce to the same type. I’m not sure but as I remember GCC does allow it, and gives you an int and a float, but that’s nonconforming behaviour.

Read More »

Comment on GotW #94 Special Edition: AAA Style (Almost Always Auto) by jlehrer

So this is well formed:

auto i=1,j=2;

but this is ill-formed:

auto i=1,j=2.0;

Okay.

What about this:

auto x=1,*j=&x;

I’m going to guess that is ill-formed as well.

Read More »

Comment on GotW #94 Special Edition: AAA Style (Almost Always Auto) by André Müller

@jlehrer
g++ 4.7.3 says

  auto i = 0, j = 1;   //does compile  auto i = 0, *j = &i; //does compile  auto i = 0, j = 2.0; //error: inconsistent deduction for 'auto': 'int' and then 'double'  

Read More »
 
Delievered to you by Feedamail.
Unsubscribe