title: no type named ‘pointer’ in struct std::iterator_traits<...>
body: <p>Here are the fragments of my linked_list template :</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iterator&gt;
  
  template &lt; class &gt;
  struct linked_list {
      struct iterator_base : public std::iterator&lt; std::bidirectional_iterator_tag , int &gt;
      {  
          typename std::iterator_traits&lt; iterator_base &gt;::pointer operator -&gt; () const {
              std::cerr &lt;&lt; __func__ ; 
              return nullptr ; } ;
      };
      using difference_type = typename std::iterator_traits&lt; iterator_base &gt;::difference_type ;
  } ;
  
  int main ()
  {
      int * inullptr = linked_list&lt; int &gt;::iterator_base().operator-&gt;() ;
      return 0 ;
  }
  </code></pre>
  
  <p>When I leave <code>using...</code> line uncommented, the code doesn't compile.</p>
  
  <p>g++5.4 :</p>
  
  <pre><code>list2.cxx:105:66: error: no type named ‘pointer’ in ‘struct std::iterator_traits&lt;linked_list&lt;int&gt;::iterator_base&lt;(linked_list&lt;int, std::allocator&lt;int&gt; &gt;::constantness)1u&gt; &gt;’
            typename std::iterator_traits&lt; iterator_base &gt;::pointer operator -&gt; () const { return &amp;( to_obj_node( current_node_ ) -&gt; object() ) ; }
  </code></pre>
  
  <p>icpc :</p>
  
  <pre><code>list.cxx(105): error: incomplete type is not allowed typename std::iterator_traits&lt; iterator_base &gt;::pointer operator -&gt; () const { return &amp;( to_obj_node( current_node_ ) -&gt; object() ) ; }
  </code></pre>
  
  <p>Without that line all compiles fine.  </p>
  
  <p>the question is : What happens, when i'm commenting <code>using difference_type = typename std::iterator_traits&lt; iterator &gt;::difference_type;</code> in above code ( only with such changes code compiles ).?</p>
  
  <p>==========================================================================
  <a href="http://eel.is/c++draft/res.on.functions" rel="nofollow">res.on.functions/2.5</a></p>
  
  <blockquote>
    <ol start="2">
    <li>In particular, the <strong><em>effects are undefined</em></strong> in the following cases:...
    
    <ol start="5">
    <li>if an incomplete type ([basic.types]) is used as a template argument when instantiating a template component, unless specifically
    allowed for that component.</li>
    </ol></li>
    </ol>
  </blockquote>
  
  <p>and historical <a href="http://open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#287" rel="nofollow">discussion</a> on that.</p>