Boost logo

Boost :

Subject: Re: [boost] radix sort
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2013-07-22 04:55:52


On Jul 21, 2013, at 10:58 AM, Steven Ross <spreadsort_at_[hidden]> wrote:

>> I'm not real sure about the interface, though: do they have to be different named functions (integer_, float_, string_)? Can't it be called bucket_sort() and specialized for different types?

[snip]

> With regards to different types, this covers three different
> cases: sorting by an integer or integer-like key of finite length, sorting a float correctly by casting it to an integer (tricky but fast), and sorting strings of
> variable length. Specializing by type isn't ideal as people often want to sort larger data types by a key, and the key could itself be a more complex data type that isn't an integer, float, or string, but supports the necessary operators.

Use a function template, don't implement the primary specialization. Just implement the specializations you support. If you dispatch to a static member function of a class template, PTS with type traits can give wider support without specializing for otherwise similar types. (all integral types, for example).

___
Rob

(Sent from my portable computation engine)


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