Subject: Re: [boost] [Fusion] begin/end ADL issues with C++0x range-based for
From: Michel MORIN (mimomorin_at_[hidden])
Date: 2010-12-20 19:43:57
Thanks Christopher for your commitment.
Jeffrey Lee Hellrung, Jr. wrote:
> SFINAE'ing out
> boost::fusion::begin/end for only Boost.Fusion sequences is only a partial
> solution, as it doesn't help for structures having both range and
> Boost.Fusion interfaces.
True. SFINAE'ing out is only a partial solution.
Better solutions would be:
A. (almost the same as Jeffrey's suggestion)
If boost::fusion::begin/end doesn't need to be found via ADL,
then use ADL barrier technique to fusion::begin/end
(i.e. defining begin/end in another namespace and pull its name
in namespace fusion by using directive/declaration).
If boost::begin/end doesn't need to be found via ADL,
then use ADL barrier technique to boost::begin/end.
Define begin/end in namespace boost for all containers and ranges
which live in namespace boost (boost::array, boost::iterator_range,
For example, define begin/end for boost::array in namespace boost.
Since this is very tedious work, it would be better to define some
BOOST_DEFINE_BEGIN_END macro for boilerplate code generation.
Solutions B and C are, again, only a partial solution, since this only solves
ambiguity call problems in namespace boost;
the same thing can happen in another namespace.
Solution A might break existing codes that relies on ADL to find
Assuming any code in the Boost libraries does not rely on
ADL for boost::fusion::begin/end, how about defining switch macro
and making a user to choose whether A is applied or not?