This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/12216] Bad "implicit typename" warning


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12216


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


------- Additional Comments From bangerth at dealii dot org  2003-09-08 21:41 -------
No. Given your code
-------------------------
template<typename I>
class C : public std::iterator<
              typename std::iterator_traits<I>::Category,
              typename std::iterator_traits<I>::value_type,
              typename std::iterator_traits<I>::difference_type,
              typename std::iterator_traits<I>::pointer,
              typename std::iterator_traits<I>::reference
                                                        > {
public:
                                C(I i) : iter(i) {}

        value_type operator*() const { return *iter; }
private:
        I iter;
        };

int main() {
        }

---------------------------------
the typedef value_type is not visible with two-stage lookup. Your code
is thus invalid, but gcc up to and including 3.3.x accepts it. You
really need to write the thing with the typename, but including the
classname, i.e.
  typename C<I>::value_type
or
  typename std::iterator<...>::value_type

The point is that you need to make the name of the type dependent, so
that it is looked up on instantiation, rather than declaration time. So
the thing before :: must be template dependent, but then you also need
the typename.

W.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]