Boost logo

Boost :

From: Matthew Austern (austern_at_[hidden])
Date: 2001-01-31 16:10:31

Dietmar Kuehl wrote:

> It ain't pretty but if we really need function template partial
> specialization
> we can emulate it:
> template <typename T>
> struct swap_t {
> static void do(T& t1, T& t2) {
> T tmp = t1;
> t1 = t2;
> t2 = tmp;
> }
> };
> template <typename T>
> void swap(T& t1, T& t2) { swap_t<T>::do(t1, t2); }
> Now 'swap_t::do()' is a partial specializable function. It isn't pretty
> and
> would need a lot of change in the library if this is what is supposed to
> be
> done but it is doable, without a library change and without allowing users
> to add overloads into namespace 'std'.

I don't really see this as more than half a solution, because standard
library implementors can't use it without a whole lot of changes in the
library portions of the C++ standard. You certainly couldn't use
swap_t when writing std::sort(), or abs_t when writing std::valarray().


Boost list run by bdawes at, gregod at, cpdaniel at, john at