From 5c423972440523f505a6f904c42173ff6ff0e92e Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 16 Aug 2008 08:56:19 +0000 Subject: [PATCH] Added explanatory comments, requested by Isaac Dupree, "Re: [boost] [swap] Renaming boost_swap_impl::swap_impl and/or its namespace?", http://lists.boost.org/Archives/boost/2008/08/141007.php [SVN r48171] --- include/boost/utility/swap.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/boost/utility/swap.hpp b/include/boost/utility/swap.hpp index f42264c..6845e79 100644 --- a/include/boost/utility/swap.hpp +++ b/include/boost/utility/swap.hpp @@ -9,6 +9,18 @@ #ifndef BOOST_UTILITY_SWAP_HPP #define BOOST_UTILITY_SWAP_HPP +// Note: the implementation of this utility contains various workarounds: +// - swap_impl is put outside the boost namespace, to avoid infinite +// recursion (causing stack overflow) when swapping objects of a primitive +// type. +// - swap_impl has a using-directive, rather than a using-declaration, +// because some compilers (including MSVC 7.1, Borland 5.9.3, and +// Intel 8.1) don't do argument-dependent lookup when it has a +// using-declaration instead. +// - boost::swap has two template arguments, instead of one, to +// avoid ambiguity when swapping objects of a Boost type that does +// not have its own boost::swap overload. + #include //for std::swap #include //for std::size_t