Declaring the value_type when implementing an iterator
<p>I am implementing an iterator for a custom container in c++11</p>

<p>I get the following error:</p>

<pre><code>no type named 'value_type' in 'struct std::iterator_traits&lt;PixBuffer&lt;float&gt;::seq_read_iterator&gt;'
    typedef typename iterator_traits&lt;_OI&gt;::value_type _ValueTypeO;
</code></pre>

<p>I have read before the answer here:
<a href="https://stackoverflow.com/questions/8054273/how-to-implement-an-stl-style-iterator-and-avoid-common-pitfalls">How to implement an STL-style iterator and avoid common pitfalls?</a></p>

<p>It states that I can:</p>

<ul>
<li>specialize <code>std::iterator_traits&lt;youriterator&gt;</code> : This is not the preferred method according to the author, for code readability, as this type declaration is not nested in the class</li>
<li>Put the same typedefs in the iterator itself : I did this but I still have the error above</li>
<li>Inherit from std::iterator : will this fix my problem, and what is the proper way to use this method?</li>
</ul>

<p>This interator works as a back_inserter.
The current class definition is:</p>

<pre><code>template&lt;typename T&gt;
class PixBuffer
{
public:
    friend class seq_read_iterator;

    /* container class implementation removed from here */

public:
    class seq_read_iterator
    {
    public:
        typedef T value_type;

        seq_read_iterator(PixBuffer &amp; pb);
        seq_read_iterator &amp; operator*(T val);
        seq_read_iterator &amp; operator++();
        seq_read_iterator operator++(int);
        seq_read_iterator &amp; operator=(T val);

        /* iterator class implementation removed from here */
    };


    seq_read_iterator seqReadIterator() { return seq_read_iterator(*this); }
};
</code></pre>

<p>Thanks in advance</p>