$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Stephen Silver (boost_at_[hidden])
Date: 2001-01-24 16:41:15
Darin Adler wrote:
> on 1/23/01 3:27 PM, Stephen Silver at boost_at_[hidden] wrote:
>
> > Daryle Walker wrote:
> >
> >> Since we can't put specializations of template functions, like "swap",
> >> in the "std" namespace,
> >
> > But we can. 17.4.3.1 / 1 says:
[snip quote from standard]
> This has been discussed in the past on this list at length. Defining another
> std::swap for a particular type might seem to be a "specialization" at first
> glance, but it is actually an overloaded function, hence not legal.
The std::swap I have for my GMP mpz_t wrapper is like this:
namespace std
{
template <>
void swap(::Integer& a, ::Integer& b)
{
::mpz_swap(a.mpz, b.mpz);
}
}
This is a specialization, not an overload, and is legal.
> Here's a message from the middle of that old thread:
> <http://www.egroups.com/message/boost/6136>.
I've read this thread, and some others on a similar theme, but I don't
see anything contradicting the correctness of specializations like the
one shown above. And I do find some like this:
http://www.egroups.com/message/boost/2814
confirming that such specializations are legal.
> I decided to ignore this issue after adding swap to smart_ptr.hpp, and so
> the std::swap specializations/overloads (I still don't 100% understand
> which) are still there even though they are theoretically illegal.
Those are overloads, so they really are illegal.
Stephen