Puppet_Sock wrote:
You don't need to do it for v. The variable v is
already referenced.
Yes :-), but the reference is not used. That is what the compiler is
jumping about.
I sometimes bind temporaries to reference to scope them, for example:
const int& i( 10 );
now the value 10 lives for as long as the enclosed scope, but i is not
used. This is a stupid example, but I have a class that calls a
function at scope end (its scope end), and I have a make that returns
a temporary that is bounded to a const reference.
Pete has a point, I suppose. Sometimes, though - I might want to know
about unused variables, so disabling the (compiler) options at project
level is too much for me. Also, it is tedious to disable the option
every time a piece of often used code is used. Perhaps options can be
disabled by pragmas or by comments, but to do that for various
compilers becomes more messy than just simply stating "verbosely" in
the code...
isUsed( x );
.... due to the fact that it is the exiting of scope that matters.
Admittely, 95% percent of the time this warning is really stupid.
Regards,
Werner