|
Boost : |
Subject: Re: [boost] [swap] please update documentation with the header I need to include
From: Niels Dekker - address until 2010-10-10 (niels_address_until_2010-10-10_at_[hidden])
Date: 2009-06-27 05:04:51
Thorsten Ottosen wrote:
> please update documentation with the header I need to include
I agree, and I do think the documentation at libs/utility/swap.html
could be further improved by adding a little example. E.g.,
#include <boost/swap.hpp>
template <typename T>
void do_some_generic_work(T& arg1, T& arg2)
{
// ....
boost::swap(arg1, arg2);
// ....
}
IMO such a simple example would suggest the proper use of boost::swap.
The utility is especially useful within a generic context. But it's not
recommended to do an unqualified call to boost::swap:
std::string a1[42];
std::string a2[42];
boost::swap(a1, a2); // Okay.
using boost::swap;
swap(a1, a2); // Does not compile!
It's also not recommended to explicitly specify the template arguments
passed to boost::swap. The fact that boost::swap has two template
arguments, instead of one, should be considered an implementation
detail. (Both arguments must be of the same type anyway.)
Just my 2 cents, Niels
-- Niels Dekker http://www.xs4all.nl/~nd/dekkerware Scientific programmer at LKEB, Leiden University Medical Center -- Niels Dekker http://www.xs4all.nl/~nd/dekkerware Scientific programmer at LKEB, Leiden University Medical Center
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk