Boost logo

Boost :

Subject: Re: [boost] Standalone boost::ignore_unused_variable_warning()
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2014-05-18 12:29:46


2014-05-18 16:56 GMT+04:00 Adam Wulkiewicz <adam.wulkiewicz_at_[hidden]>:

> Hi,
>
> 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.

+1

> Since it was already defined in the namespace boost, not boost::detail,
> the right place would probably be:
>
> boost/utility/ignore.hpp
>
> or
>
> boost/utility/ignore_warning.hpp
>

Maybe boost/utility/unused_variable.hpp and
boost/utility/unused_typedef.hpp would be better?

> 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:
>
> boost::ignore_unused_variable_warning(x)
> boost::ignore_unused_variable_warning(y)
> boost::ignore_unused_variable_warning(z)
>
> we could use only one:
>
> boost::ignore_unused_variable_warning(x, y, z)
>
> which would be more convenient to use and read.
>

+1

> 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?
>

As far as I know it is impossible to modify two modules in one commit.

> 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 {};
>

Just move it into some detail namespace (like boost::detail::utility) and
do not define when we have variadic templates.

I'd be happy to have such tool, it is much more clear than (void)x;

-- 
Best regards,
Antony Polukhin

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk