Boost logo

Boost :

Subject: Re: [boost] [Config] Macro for C++0x range-based for
From: Michel MORIN (mimomorin_at_[hidden])
Date: 2010-12-17 17:17:31


Sebastian Redl wrote:
> No, a standard library that provides std::begin() and std::end() conflicts
> with boost::begin() and boost::end() provided by Boost.Range. These functions
> are used by for-range, so their existence is a requirement for a compiler
> supporting for-range on anything but arrays, but the language feature itself
> has nothing to do with the conflict.

Agreed. My description of the problem was too poor...
I will start a new thread to explain what I want to do. Can you take a
look at it?

>> Yeah, we can always use BOOST_FOREACH instead of range-based for.
>> And considering portability, BOOST_FOREACH is a must.
>> But IMHO it's a pity that users of the Boost libraries are recommended
>> not to use a language feature.
>
> Er, what? Who recommended that Boost users not use a language feature?
> Dave merely said that Boost authors should just use BOOST_FOREACH.

Sorry, the last sentence is unnecessary. May I withdraw it?
I just wanted to say it is important to fix boost/range/begin.hpp (end.hpp)
so that the following code does compile.

    #include <boost/range/iterator_range.hpp>
    int main(int argc, char* argv[])
    {
        int ar[2] = {2, 2};
        boost::iterator_range<int*> rng(ar, ar + 2);
        for (int i : rng) {} // error: ambiguous calls
        return 0;
    }

Thanks,
Michel


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