Boost logo

Boost :

Subject: Re: [boost] [fusion] Adapter for std::array
From: Jonathan Wakely (jwakely.boost_at_[hidden])
Date: 2013-07-05 20:25:57


On 6 July 2013 00:47, Mateusz Loskot <mateusz_at_[hidden]> wrote:
> On 5 July 2013 10:44, Jonathan Wakely <jwakely.boost_at_[hidden]> wrote:
>> On 5 July 2013 00:57, Mateusz Loskot wrote:
>>>
>>> Unfortunately, I have hit t apparently well-known problem.
>>> It is the Fusion begin/end ADL issues with C++0x range-based for
>>> and such, as discussed and reported here:
>>>
>>> http://lists.boost.org/Archives/boost/2010/12/174199.php
>>> https://svn.boost.org/trac/boost/ticket/4028
>>>
>>> There has been no feedback to the ticket #8241, so I'm not
>>> sure what is the Fusion authors' view on std::array adoption.
>>> So, a couple of questions:
>>>
>>> Do the Fusion authors consider any cure for the ADL issues?
>>
>> Stop using C++0x compilers and use C++11 compilers? :)
>>
>> We fixed the standard via Option 5 from
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3257.pdf
>
> Jonathan,
>
> Thanks for this paper.
>
> It is still unclear to me if/how the option 4/5 might solve the ambiguous
> calls to begin/end as here:
>
> std::array<int, 3> = {{1,2,3}};
> boost::fusion::distance(begin(arr), end(arr)) == 3;
>
> as the std::array does provide begin/end members.
>
> AFAIU, solution that remains is to fully qualify:
>
> boost::fusion::distance(boost::fusion::begin(arr),
> boost::fusion::end(arr)) == 3;
>
> So, the following rule kicks:
>
> "to call begin() and end() members if they exist, and if not then to
> make unqualified calls as specified in the current draft."
>
> I'm missing something, am I not?

No, I think I'm missing something: I thought you meant the problem
was with the range-based for loop, but it's with other uses of
unqualified begin/end. The standard was changed to *not* use
unqualified begin/end when the type has begin/end members, because
when there are multiple "greedy" overloads that can be found by ADL
there is no simple way to prevent ambiguity. So I agree that your
best option might be to avoid those unqualified calls.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk