Boost logo

Boost :

From: Stephen Silver (boost_at_[hidden])
Date: 2001-01-25 07:02:59

Jens Maurer wrote:

> Stephen Silver wrote:

> > This is a specialization, not an overload, and is legal.
> This is fine for classes such as the one you describe. However,
> this covers only a small part of the problem, because most
> entities in boost are class templates, e.g. rational<T>.
> This would require something like
> namespace std
> {
> template <class T>
> void swap(boost::rational<T>& a, boost::rational<T>& b)
> {
> a.swap(b);
> }
> }
> which is an overload and not a specialization,

Yes. In fact, I pointed this out at the end of my message in
reference to Darin Adler's std::swap overloads in smart_ptr.hpp,
which are almost identical to your example above.

But I was originally posting in response to Daryle Walker's e-mail
which appeared to object to

    IntType r(n%m);

on the grounds that people couldn't specialize std::swap for IntType.
Since specializing std::swap is perfectly possible and legal this is
not a valid objection, and that was all I was trying to say. Of course,
there is a problem if someone wants to use boost::rational with an
unlimited set of IntTypes, but boost::rational really isn't designed
for such use (e.g. there are no operators that allow comparison between
rationals with different underlying IntTypes), so I don't think we need
to worry about this.


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