
In C++0x, begin and end are supposed to be found through ADL, and this might end up considering fusion::begin/fusion::end as possible overloads. Unfortunately, this breaks, as fusion::begin and fusion::end produce hard errors when passed something else than a fusion sequence. All in all, I find ADL very dangerous. Should it be advocated not to use the names "begin" and "end" for something else than ranges to avoid issues? I suppose that for Fusion, it could be possible to use SFINAE to mask the overloads if the arguments aren't fusion sequences.

Mathias Gaunard wrote:
In C++0x, begin and end are supposed to be found through ADL, and this might end up considering fusion::begin/fusion::end as possible overloads.
Unfortunately, this breaks, as fusion::begin and fusion::end produce hard errors when passed something else than a fusion sequence.
All in all, I find ADL very dangerous. Should it be advocated not to use the names "begin" and "end" for something else than ranges to avoid issues? I suppose that for Fusion, it could be possible to use SFINAE to mask the overloads if the arguments aren't fusion sequences.
Hmmm...that's unfortunate that C++0x decided to "usurp" use of begin/end, seeing as how it's established practice (isn't it?) that those functions could be meaningful outside the context of ranges. Seems to me that Boost.Range's lookup via ADL of range_begin and range_end makes more sense... - Jeff

Mathias Gaunard a écrit :
In C++0x, begin and end are supposed to be found through ADL, and this might end up considering fusion::begin/fusion::end as possible overloads.
Unfortunately, this breaks, as fusion::begin and fusion::end produce hard errors when passed something else than a fusion sequence.
All in all, I find ADL very dangerous. Should it be advocated not to use the names "begin" and "end" for something else than ranges to avoid issues? I suppose that for Fusion, it could be possible to use SFINAE to mask the overloads if the arguments aren't fusion sequences.
Of course, keeping the names begin and end for fusion means we won't be able to have a range that is at the same time a fusion sequence, even though that could be somewhat useful. Since this is not leading to a discussion of what to do about this issue as I expected, I've filed a ticket here: https://svn.boost.org/trac/boost/ticket/4028

AMDG Mathias Gaunard wrote:
Mathias Gaunard a écrit :
In C++0x, begin and end are supposed to be found through ADL, and this might end up considering fusion::begin/fusion::end as possible overloads.
Unfortunately, this breaks, as fusion::begin and fusion::end produce hard errors when passed something else than a fusion sequence.
All in all, I find ADL very dangerous. Should it be advocated not to use the names "begin" and "end" for something else than ranges to avoid issues? I suppose that for Fusion, it could be possible to use SFINAE to mask the overloads if the arguments aren't fusion sequences.
Of course, keeping the names begin and end for fusion means we won't be able to have a range that is at the same time a fusion sequence, even though that could be somewhat useful.
Hmm. I think it works just fine for boost::array, since fusion::begin won't be found by ADL.
Since this is not leading to a discussion of what to do about this issue as I expected, I've filed a ticket here: https://svn.boost.org/trac/boost/ticket/4028
In Christ, Steven Watanabe

Steven Watanabe wrote:
Of course, keeping the names begin and end for fusion means we won't be able to have a range that is at the same time a fusion sequence, even though that could be somewhat useful.
Hmm. I think it works just fine for boost::array, since fusion::begin won't be found by ADL.
It *may* be found by ADL. Consider the following: #include <boost/array.hpp> #include <boost/fusion/container/vector.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp> #include <boost/fusion/adapted/array.hpp> #include <boost/range.hpp> int main() { boost::array<boost::fusion::vector<>, 42> foo; begin(foo); // ambiguous, boost::begin or boost::fusion::begin } Namespaces of template arguments are also considered for ADL. (Yes, that's a terrible rule -- no idea why it was coined)

Mathias Gaunard wrote:
Steven Watanabe wrote:
Of course, keeping the names begin and end for fusion means we won't be able to have a range that is at the same time a fusion sequence, even though that could be somewhat useful.
Hmm. I think it works just fine for boost::array, since fusion::begin won't be found by ADL.
It *may* be found by ADL. Consider the following:
#include <boost/array.hpp> #include <boost/fusion/container/vector.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp> #include <boost/fusion/adapted/array.hpp> #include <boost/range.hpp>
int main() { boost::array<boost::fusion::vector<>, 42> foo; begin(foo); // ambiguous, boost::begin or boost::fusion::begin }
Namespaces of template arguments are also considered for ADL. (Yes, that's a terrible rule -- no idea why it was coined)
Rename boost::fusion::begin/end to boost::fusion::some_other_namespace::begin/end ???
participants (3)
-
Jeffrey Hellrung
-
Mathias Gaunard
-
Steven Watanabe