Boost logo

Boost :

Subject: [boost] Standalone boost::ignore_unused_variable_warning()
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2014-05-18 08:56:48


The ignore_unused_variable_warning() tool is used in many libraries. Its
"main" definition (probably the first one) is in concept_check.hpp in
the namespace boost but functions of the same name and purpose are also
defined in the internals of some libraries (GIL, Interval, Test, uBlas,
Unordered), probably to not include the whole concept_check.hpp.

So I propose to move this useful tool out of the concept_check.hpp to
somewhere else. Since it was already defined in the namespace boost, not
boost::detail, the right place would probably be:




Furthermore I propose to add a few overloads becasue it's common that
the compiler warns about a few variables in the same function, so
instead of using N calls:


we could use only one:

boost::ignore_unused_variable_warning(x, y, z)

which would be more convenient to use and read.

If you were ok with the change, I'd be glad to hear some tips how to
make it in one commit, i.e. to modify two modules at once - modify a
file in ConceptCheck and add a file to Utility?

And finally I'm considering adding similar tool for unused typedefs
because some compilers (GCC4.8) warns about them and there are cases,
e.g. when some part of code is shielded with some #ifdef, where they
can't be commented out or removed. E.g. something like this would work,
though I'm not sure if there is no better way, so I'm open to suggestion.

struct empty_type {};

template <typename T1, typename T2 = empty_type, typename T3 = empty_type>
struct ignore_unused_typedef_warning {};

int main()
typedef int T1;
typedef int T2;

ignore_unused_typedef_warning<T1, T2>();


Boost list run by bdawes at, gregod at, cpdaniel at, john at