Why the same type duplicated declared in the gcc library
<p>In the gcc library, the template basic_stringbuf is derived from basic_streambuf. In the base class basic_streambuf, the type names, such as char_type, traits_type, are already declared. Why they are duplicated declared in the child class basic_stringbuf?</p>

<p>The related code is pasted below.</p>

<pre><code>// c++/4.2.1/streambuf
template&lt;typename _CharT, typename _Traits&gt;
    class basic_streambuf 
    {
    public:
      //@{
      /**
       *  These are standard types.  They permit a standardized way of
       *  referring to names of (or names dependant on) the template
       *  parameters, which are specific to the implementation.
      */
      typedef _CharT                    char_type;
      typedef _Traits                   traits_type;
      typedef typename traits_type::int_type        int_type;
      typedef typename traits_type::pos_type        pos_type;
      typedef typename traits_type::off_type        off_type;
      //@}

      //@{
      /**
       *  @if maint
       *  This is a non-standard type.
       *  @endif
      */
      typedef basic_streambuf&lt;char_type, traits_type&gt;   __streambuf_type;
      //@}
…
};

// c++/4.2.1/sstream
template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
    class basic_stringbuf : public basic_streambuf&lt;_CharT, _Traits&gt;
    {
    public:
      // Types:
      typedef _CharT                    char_type;
      typedef _Traits                   traits_type;
      // _GLIBCXX_RESOLVE_LIB_DEFECTS
      // 251. basic_stringbuf missing allocator_type
      typedef _Alloc                        allocator_type;
      typedef typename traits_type::int_type        int_type;
      typedef typename traits_type::pos_type        pos_type;
      typedef typename traits_type::off_type        off_type;

      typedef basic_streambuf&lt;char_type, traits_type&gt;   __streambuf_type;
      typedef basic_string&lt;char_type, _Traits, _Alloc&gt;  __string_type;
      typedef typename __string_type::size_type     __size_type;
…
};
</code></pre>

<p><strong>Update:</strong></p>

<p>The char_type is already declared in the parent class as a public member. The child class can use it directly. My question is why not gcc implements the basic_stringbuf as below</p>

<pre><code>template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
    class basic_stringbuf : public basic_streambuf&lt;_CharT, _Traits&gt;
    {
    public:
      // Types:
      //typedef _CharT                  char_type;
      //typedef _Traits                     traits_type;
      // _GLIBCXX_RESOLVE_LIB_DEFECTS
      // 251. basic_stringbuf missing allocator_type
      typedef _Alloc                        allocator_type;
      //typedef typename traits_type::int_type      int_type;
      //typedef typename traits_type::pos_type      pos_type;
      //typedef typename traits_type::off_type      off_type;

      typedef basic_streambuf&lt;char_type, traits_type&gt;   __streambuf_type;
      typedef basic_string&lt;char_type, _Traits, _Alloc&gt;  __string_type;
      typedef typename __string_type::size_type     __size_type;
…
};
</code></pre>

<p><strong>EDIT:</strong></p>

<p>Thanks K-ballo. I think your answer makes sense. I tried the code below. The type name char_type can't be used in the child class. </p>

<pre><code>template&lt;typename _CharT&gt;
class Base
{
public:
    typedef _CharT char_type; 
};

template&lt;typename _CharT&gt;
class Child : public Base&lt;_CharT&gt;
{
private:
    char_type _M_Data; // FAIL: Unknown type name 'char_type'
};
</code></pre>
