Boost logo

Boost :

Subject: Re: [boost] sorting library proposal
From: Steven Ross (spreadsort_at_[hidden])
Date: 2009-06-05 02:36:02


On Thu, Jun 4, 2009 at 8:03 AM, Gevorg Voskanyan <v_gevorg_at_[hidden]> wrote:

> template < typename Div_type >
> typename boost::disable_if_c< sizeof(Div_type) <= sizeof(size_t), void
> >::type
> foo( /*args*/ )
> {
> // fallback to std::sort
> BOOST_STATIC_WARNING( sizeof(Div_type) <= sizeof(size_t) );
> // BOOST_STATIC_WARNING( false ); won't work because the expression must
> depend on a template parameter
> }
>
> Thanks Gevorg, that's what I needed. integer_sort is now safe against
too-large data types, and the default float_sort is safe against bad casts.
The warning message is confusing, but it's a compile-time warning, which is
what I need to let the user know that there is a problem.
Is it bad for my unit tests to be issuing intentional static warnings?


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