Boost logo

Boost :

Subject: Re: [boost] Standalone boost::ignore_unused_variable_warning()
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2014-05-18 21:58:02


On Sun, May 18, 2014 at 5:56 AM, Adam Wulkiewicz
<adam.wulkiewicz_at_[hidden]>wrote:

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

I support these going in, though I have a suggestion for the unused typedef
warning -- you may want to be able to do this outside of a function
definition (I.E. at global scope or in a class's body). For situations like
this, I often find that using a static_assert may be better than an
expression, as it can be written almost anywhere. In other words, something
along the lines of:

/////
static_assert( ignore_unused_typedef< T1, T2 >::value, "This will never
fire." );
/////

where the ignore_unused_typedef metafunction is basically just an
always_true metafunction. In other words, I suggest you simply have it
inherit from std::true_type or boost::mpl::true_. A macro alias that hides
the static_assert and unseen message may also be beneficial.

-- 
-Matt Calabrese

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