Boost logo

Boost :

From: Niels Dekker - mail address until 2008-12-31 (nd_mail_address_valid_until_2008-12-31_at_[hidden])
Date: 2007-10-03 17:10:50


Joseph Gauterin wrote:
> I have now uploaded the files the boost sandbox.

So you *do* have SVN write access by now :-)

>> The C++ Standard does not allow you to add your own overload of swap
>> to the std namespace...
> I've corrected it in the checked in version - thanks for noticing.

You're welcome.

A small remark about sandbox/swap/libs/utility/swap.html. It says:
  "The alternative to using argument dependent lookup in this situation
is to provide a template specialization of std::swap for every type that
requires a specialized swap. Although this is legal C++, no boost
libraries use this method."

Please note that you cannot add a partial template specialization of
std::swap. So for instance, boost::shared_ptr<T> cannot have a generic
template specialization of std::swap.

  namespace std {
    // This is NOT legal C++!!!
    template <typename T> void swap<boost::shared_ptr<T> >(
      boost::shared_ptr<T> & a, boost::shared_ptr<T> & b) {
      a.swap(b);
    }
  }

This probably explains why boost libraries don't do it like that...

BTW, I think it would be nice to add a literature reference to the doc.
I would suggest adding a reference to Scott Meyers, Effective C++ Third
Edition, Item 25: Consider support for a non-throwing swap.

Kind regards,

  Niels


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