1

I'm using boost 1.52 and Visual Studio 2010.

I'm wondering why I can't enforce on the elements returned by boost::adaptors::indirected.

This sample code shows what I'm trying to achieve:

#include <vector>
#include <string>
#include <boost/range/adaptor/indirected.hpp>
#include <boost/foreach.hpp>

int main() {
    using std::vector;
    using std::string;

    typedef vector<string*> type;
    type range;
    range.push_back(new string("42"));
    type const& const_range = range;

    // This is ok to compile
    BOOST_FOREACH(string const& foo, const_range | boost::adaptors::indirected) {
        //...
    }

    // I don't want this to compile
    BOOST_FOREACH(string& foo, const_range | boost::adaptors::indirected) {
        //...
    }
    return 0;
}
Edison Gustavo Muenz
  • 8,202
  • 6
  • 35
  • 41

0 Answers0