From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-09-26 14:21:46
At 11:51 AM 9/26/2001, Darin Adler wrote:
>on 9/26/01 4:13 AM, Beman Dawes at bdawes_at_[hidden] wrote:
>> But isn't the usual practice in that case to wrap the temporary and
>> to it in an #ifndef NDEBUG?
>A good way to see where this comes up is to look at the examples already
>Boost. In most cases, we just don't declare the variable or don't name it
>the parameter list, but there are a number of files that use one of the
>techniques we're discussing.
>The ignore_unused_variable_warning function template is used in 8
>source files in Boost: boost/concept_check.hpp,
>libs/utility/call_traits_test.cpp (called unused_variable in this file),
>libs/tuple/test/tuple_test_bench.cpp (called dummy in this file).
>The cast to (void) technique is used in 32 different source files in
>libs/utility/half_open_range_test.cpp, and in many of the tests in the
Interesting. Note that those uses involve a number of different
developers, too, not just one person repeating a personal favorite
I wouldn't have guessed anywhere near that much use for either
technique. Makes a strong argument we should have something in Boost.
>I find the function template more readable, more elegant, and perhaps
>slightly more portable, since it relies on the "don't complain about
>parameters without names" behavior rather than the "mentioning in an
>expression that is unused is using a variable" behavior.
>About 1/2 of the uses of the (void) technique also have a comment to
>explain what the void cast means.
>There can be overhead caused by the function template technique, though,
>when the compiler is not doing function inlining. This is not an issue
>me, but it might be an issue for others.
Pending more discussion, I lean toward the template too.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk