Boost logo

Boost :

Subject: Re: [boost] sorting library proposal
From: Steven Ross (spreadsort_at_[hidden])
Date: 2009-06-04 10:41:25


Is there a good way to issue a compile-time warning telling people that
integer_sort or float_sort isn't being used, because they passed in an
incompatible data type? I see static assertions, but what I need is an
equivalent static warning, after which I use std::sort.

integer_sort won't run on long longs, because it uses size_t for distance
codes. I've added a check to see whether the key type being used is of the
same size or smaller than a size_t to handle this problem. I don't think
integer_sort is an appropriate algorithm for data types larger than a
size_t, unless comparisons are ridiculously slow, as the k/s factor starts
becoming quite large.

Also, I'm using a simple if to decided this:
if(sizeof(Div_type) <= sizeof(size_t))
because enable_if appears to only work with classes. I'm assuming here that
the compiler is smart enough to figure out that the expression is constant
and to only bring in the code if it's true. It would be nice to be able to
eliminate the compiler warnings about size, and issue a more concise and
meaningful message telling the user that their data type is too big for
integer_sort (or incompatible with float_sort, as appropriate).


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