public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/5260: g++ rejects references to typedef in template parameter
@ 2002-01-02 13:55 paolo
0 siblings, 0 replies; 2+ messages in thread
From: paolo @ 2002-01-02 13:55 UTC (permalink / raw)
To: cchen, gcc-bugs, gcc-prs, nobody
Synopsis: g++ rejects references to typedef in template parameter
State-Changed-From-To: open->closed
State-Changed-By: paolo
State-Changed-When: Wed Jan 2 13:55:22 2002
State-Changed-Why:
User error.
Your code is missing a typename keyword!
...
typename H::KeyType s = 0;
...
Thanks,
Paolo
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5260
^ permalink raw reply [flat|nested] 2+ messages in thread
* c++/5260: g++ rejects references to typedef in template parameter
@ 2002-01-02 13:06 cchen
0 siblings, 0 replies; 2+ messages in thread
From: cchen @ 2002-01-02 13:06 UTC (permalink / raw)
To: gcc-gnats
>Number: 5260
>Category: c++
>Synopsis: g++ rejects references to typedef in template parameter
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Wed Jan 02 13:06:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Cheng Che Chen
>Release: 3.0.x
>Organization:
>Environment:
RedHat 7.2
>Description:
I have a templatized function which references a typedef
in a template parameter. g++ does not like that reference
to the typedef.
>How-To-Repeat:
g++ gcctest.cpp
>Fix:
I don't see how to get around the problem.
Sometimes you simply have to reference a typedef
inside a class.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="gcctest.cpp"
Content-Disposition: inline; filename="gcctest.cpp"
#include <cstdio>
struct HLP {
typedef unsigned KeyType;
KeyType Get(const double x) const { return ((KeyType) x); }
};
template <class H>
double sum(const unsigned n, const double v[], H &h)
{
#if (1)
// This doesn't compile under g++.
H::KeyType s = 0;
#else
// workaround to allow me to check that everything else compiles
unsigned s = 0;
#endif
for (unsigned i=0; i<n; ++i) { s += h.Get(v[i]); }
return ((double) s);
}
int main(int argc, char *argv[])
{
const unsigned n = 5;
const double v[n] = { 0.0, 1.0, 2.0, 3.0, 4.0 };
HLP h;
const double s = sum<HLP>(n, v, h);
printf("%f\n", s);
return (0);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-01-02 21:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-02 13:55 c++/5260: g++ rejects references to typedef in template parameter paolo
-- strict thread matches above, loose matches on Subject: below --
2002-01-02 13:06 cchen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).