|
Boost : |
Subject: Re: [boost] [Fusion] begin/end ADL issues with C++0x range-based for
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2010-12-20 12:53:06
On 12/20/2010 9:21 AM, Christopher Schmidt wrote:
[...]
> Unfortunately this still leaves us with ADL ambiguity in some cases:
>
> https://svn.boost.org/trac/boost/ticket/4028#comment:6
>
> -Christopher
That boost::fusion::begin/end could be found via ADL in range-based for
loops is a bit worrying, and, as mentioned in the ticket, 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.
I don't know if I fully understand the problem, and I don't know if the
following is a viable solution or what all the implications are (yes,
that's a lot of qualifications), but maybe we could put the Boost.Fusion
data structures (and anything else that would cause boost::fusion to be
included in the set of "associated namespaces" when using ADL for
unqualified begin/end) into another namespace, and bring them into the
boost::fusion namespace with using declarations. Then maybe
boost::fusion::begin/end wouldn't be found via ADL, but one would still
refer to them as boost::fusion::vector, etc. E.g., the following
compiles on MSVC9:
namespace fusion_data_structures
{
struct X { };
} // namespace fusion_data_structures
namespace fusion
{
template< class T > void f(T) { }
using fusion_data_structures::X;
} // namespace fusion
template< class T > void f(T) { }
int main(int argc, char* argv[])
{
fusion::X x; f(x);
return 0;
}
The fusion_data_structures namespace would be an implementation-detail,
never to be referred to outside of the Boost.Fusion library.
Just a thought,
- Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk