[Bug c++/12216] Bad "implicit typename" warning
igodard at pacbell dot net
gcc-bugzilla@gcc.gnu.org
Tue Sep 9 07:02:00 GMT 2003
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
------- Additional Comments From igodard at pacbell dot net 2003-09-09 07:02 -------
Subject: Re: Bad "implicit typename" warning
Understood. Thanks.
Ivan
----- Original Message -----
From: "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org>
To: <igodard@pacbell.net>
Sent: Monday, September 08, 2003 2:41 PM
Subject: [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.
>
>
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
More information about the Gcc-bugs
mailing list