custom iterator and insert_iterator
<p>I recently wrote my first custom iterator (Yay!) It's operating on top of a container (buffer), currently an std::vector buffer but should at least in theory work with any other standard container, of variable length byte encoded data. Nothing fancy. Basically what my iterator does is calculating how far to step to get to the next entry in the buffer. I'm using th std::bidirectional_iterator_tag for my iterator.</p>

<p>Anyway I've been testing it a bit and it works perfectly when using it for iterating and some standard operations like std:distance or std::copy. </p>

<p>Then I got the idea that it would be pretty neat to be able to insert new items into the buffer. How do we do that? Well I figuerd that as I now have an iterator I could use some std::insert function. Didn't find one, std::insert_iterator/std::inserter seems to be the way to go.</p>

<p>Well that didn't work.</p>

<pre><code>std::vector&lt;unsigned char&gt; dataBuffer;
std::vector&lt;unsigned char&gt; otherDataBuffer;

//*Fill dataBuffer with data*

ByteCrawlerIterator&lt;std::vector&lt;unsigned char&gt; &gt; insertionPoint(dataBuffer.begin());

//*pick an insertion point (this works)*
std::advance(insertionPoint, 5);

//*this will produce a lot of really ugly and confusing compiler errors*
std::insert_iterator&lt;std::vector&lt;unsigned char&gt; &gt; insert_itr(dataBuffer, insertionPoint);

//*Well we don't get this far, but I intended to use it something like this*
std::copy(ByteCrawlerIterator(otherDataBuffer.begin()), ByteCrawlerIterator(otherDataBuffer.end()), insert_it);
</code></pre>

<p>I was under the assumption that an insertion iterator was an adapter able to work with any iterator, even custom one. But I guess that was incorrect, what do I have to do to get my custom iterator to work with std::inserter? Or am I supposed to implement a custom insert_iterator? And when we are on the topic what about the reverse_iterator?</p>
