Boost logo

Boost :

From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2008-07-10 12:21:32


> __last and __first were copied from std::sort. Is there a good reason I
> shouldn't use the same notation?

Yes; you're not writing the standard library.

> I'd like to use a smart pointer, but is there one that will call delete[]?

With the way that you've now structured the code, I think your choice
is between a boost::scoped_array (the difference between scoped_ptr and
scoped_array is delete vs. delete[]), or to avoid dynamic allocation by
using a std::vector. If the number of bins is knowable at compile time
then a std::tr1::array or C-style array is another choice, but some
people might complain about having so much data on the stack.

> Is there a simple way to check if an iterator is a vector iterator?

Something like this (probably full of syntax errors....)

template <typename Iter>
void SpreadSort(Iter begin, Iter end) {
   .... generic code ....
}

template <typename T>
void SpreadSort< std::vector<T>::iterator >( std::vector<T>::iterator begin,
                                              std::vector<T>::iterator end)
{
   SpreadSort(&(*begin), &(*end));
}

I have previously asked, probably on this list, about whether there's a
good way to detect iterators that point to contiguous storage. The
answer seems to be that there isn't, except for explicitly detecting
those that are guaranteed to do so (as above).

Phil.


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