<div class="gmail_quote">On Wed, Apr 18, 2012 at 12:11 AM, Jens Auer <span dir="ltr">&lt;<a href="mailto:jensa@miltenyibiotec.de">jensa@miltenyibiotec.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Von: <a href="mailto:boost-users-bounces@lists.boost.org">boost-users-bounces@lists.boost.org</a> [mailto:<a href="mailto:boost-users-bounces@lists.boost.org">boost-users-bounces@lists.boost.org</a>] Im Auftrag von Jeffrey Lee Hellrung, Jr.<br>

1&gt; My guess is this is where that proxy reference bites you, as it makes your Enumerator iterator not strictly a random access iterator, even though it morally is, so boost::iterator_facade won&#39;t set your 1&gt; iterator_category to std::random_access_iterator_tag and instead tries to go a middle-of-the-road approach (IIRC). Try typedef&#39;ing<br>

1&gt;<br>
1&gt; typedef std::random_access_iterator_tag iterator_category; // I think this is right...<br>
1&gt;<br>
1&gt; in your Enumerator definition and see if MSVC complains?<br>
<br>
Hi Jeff,<br>
<br>
this fixed the problem and now it compiles, although I would prefer<br>
typedef typename Iterator::iterator_category iterator_category;<br>
<br>
to make the Enumerator the same category as the underlying iterator.<br></blockquote><div><br>Yes, you are correct, that would be more general (actually, you would use std::iterator_traits&lt; Iterator &gt;::iterator_category rather than Iterator::iterator_category, to be precise). It&#39;s just if you grab the iterator_category from boost::iterator_adaptor, you&#39;ll lose strict random access due to the reference type being a proxy. Indeed, the most robust solution for your use case would probably be to use some metaprogramming logic to determine the iterator_category similar to that outlined in boost::iterator_facade, but which doesn&#39;t see a proxy reference as immediately knocking down the iterator_category to std::input_iterator_tag or whatever.<br>
<br>So, in C++03, you&#39;d technically be lying to your standard library implementation if you say your iterator_category is random access but you have proxy references, since *i is suppose to a &quot;real&quot; reference. However, my draft of the C++11 standard seems to have dropped this requirement, indicating that you&#39;re safe, at least on standard library implementations that follow the C++11 iterator requirements as opposed to the C++03 iterator requirements (and I don&#39;t know where the version of MSVC you&#39;re using stands in this regard). In any case, I think I&#39;ll raise this issue on the developers&#39; list...<br>
<br>- Jeff<br><br></div></div>

