
My collection does not have a const iterator defined for it. I suppose that bothers the machinery in FOREACH even though I'm not asking for one here?
Let's take a look at the docs. The Foreach docs say [1] that Foreach is built on top of Boost.Range, and supports types that satisfy the Single Pass Range Concept. The Boost.Range iterator docs on the Single Pass Range Concept [2] say that such ranges have associated iterator and const iterator types, accessible by boost::range_iterator<X>::type and boost::range_iterator<const X>::type, respectively. There are two methods for adapting a type to fit the Single Pass Range Concept requirement. The most commonly used method [3] is to give your range type methods named 'begin()' and 'end()' and typedefs named 'iterator' and 'const_iterator'. There is also another method suitable for cases where you cannot modify the range type [4]. So yes, if you want your range type to work with Boost.Foreach, you should employ one of those methods to make it compliant to the Single Pass Range Concept (including having a const iterator). Regards, Nate [1] http://www.boost.org/doc/libs/1_49_0/doc/html/foreach.html [2] http://www.boost.org/doc/libs/1_49_0/libs/range/doc/html/range/concepts/sing... [3] http://www.boost.org/doc/libs/1_49_0/libs/range/doc/html/range/reference/ext... [4] http://www.boost.org/doc/libs/1_49_0/libs/range/doc/html/range/reference/ext...