This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12216] Bad "implicit typename" warning
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Sep 2003 21:41:53 -0000
- Subject: [Bug c++/12216] Bad "implicit typename" warning
- References: <20030908210124.12216.igodard@pacbell.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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.