home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,631 of 33,346   
   egg1nog@googlemail.com to Ulrich Eckhardt   
   Re: iterator problem   
   02 Nov 12 14:15:20   
   
   Ulrich Eckhardt wrote:   
   > egg...@googlemail.com wrote:   
   > > template   
   > >                                                       class Graph {   
   > > public:   
   > >     struct Edge {   
   > >         NodeIndex lo, hi;   
   > >         EdgeData *data;   
   > >   
   > >         Edge() : lo(0), hi(0), data(0) {}   
   > >     } ;   
   > [...]   
   > >     std::list::iterator works;   
      
   > >     std::list::iterator help;   
   > [...]   
   > > } ;  // Graph   
   > [...]   
      
   > Edge indirectly depends on a template parameter via its data   
   > member. For the same reason, std::list depends on the template   
   > parameter. Now, if you refer to something inside that dependent   
   > type, you must tell the compiler that it is a type, it could also be   
   > a function or an instance.  Note that the compiler wont guess that   
   > from the class template std::list, because (at least in theory)   
   > there could be a specialization where iterator refers to something   
   > else. For that reason, the line needs to be   
   >   
   >    typename std::list::iterator help;   
      
   Thanks.  I should have guessed that.  The change allowed compiling.   
   I'd previously encountered the need for typename in a derived class   
   that inherited from a template class.   
      
   > so that the compiler knows that iterator is a type.   
      
   In this case, the requirement does not seem to make sense: If graph   
   were specialized, std::list::iterator help; would not be there.   
   If std::list were specialized, std::list::iterator works; would   
   be affected.   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca