Boost logo

Boost :

From: Niels Dekker - mail address until 2008-12-31 (nd_mail_address_valid_until_2008-12-31_at_[hidden])
Date: 2008-07-26 09:02:26

Is any end-user allowed to add her own overloads of existing Boost
functions to the boost namespace?

The boost::swap utility from Joseph Gauterin (recently moved to the
trunk) allows the user to customize boost::swap for her class, by
providing a swap function for her class within the namespace of the
class. Internally boost::swap does the idiomatical "using std::swap;
swap(left,right);", to allow finding such a user-provided swap function
by argument-dependent lookup (ADL)

Unfortunately some compilers don't fully supported ADL, as is shown by
the mixed test results of swap/test/specialized_in_global.cpp and
swap/test/specialized_in_other.cpp, at
ADL failures appear to occur for GCC 3.3.1 (PathScale), Intel C++ 8.1,
MSVC 7.1 (2003), and Borland (up to 5.9.3).

Once the boost::swap utility would be used by other Boost libraries, end
users might want to add a custom overload of swap for their classes to
the boost namespace. Especially when users would have to deal with
lacking ADL support of their compiler. Would it be okay for them to do
so? Or are there some moral objections, or technical issues, regarding
a user-provided overload within the boost namespace?

Kind regards,


PS Volodya, thanks for fixing swap/Jamfile.v2!

Niels Dekker
Scientific programmer at LKEB, Leiden University Medical Center

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