I have a std::multimap, and I want to create a boost::iterator_range from equal_range. I found no simple way of doing it in the documentation, so I tried the following:
typedef std::multimap<int, std::string> Map;
Map map;
...
boost::iterator_range<Map::iterator> r(map.equal_range(2));
Surprisingly, it works (using GCC 4.1.2). I am curious how it works. I found no overload for iterator_range constructor that would do it, and multimap::iterator_range obviously has no overload that would return Boost ranges.
iterator_range_core.hpp:impl::adl_begintakes you toboost::begin. Having a look atbegin.hppwe see (among other voodoo):And for an example how types can be “adapted” into ranges have a look here (they use
pairas an example).