
13 Aug
2007
13 Aug
'07
2:48 p.m.
On Sat, 11 Aug 2007, Joseph Gauterin wrote:
Would anyone be interested in me adding an koenig lookup swap function to boost? (I would say it belongs in boost.utility).
It would be a swap function that uses Koenig lookup to find the 'best' swap funciton, falling back on std::swap like this:
template <class T> void koenig_swap(T& left, T& right) { using std::swap; swap(left,right); }
Several boost libraries (multi array, compressed pair, graph, optional, spirit) already use this technique, each time explicitly with 'using std::swap' instead of abstracting it out.
I feel a little dumb, but I have to ask. What is the problem with overloading std::swap? What does this koenig_swap offer better? -- François Duranleau