public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* aren't specialized templates templates?
@ 2005-02-12 16:34 Tim Janik
2005-02-13 17:50 ` Gabriel Dos Reis
2005-02-14 0:17 ` Martin Sebor
0 siblings, 2 replies; 3+ messages in thread
From: Tim Janik @ 2005-02-12 16:34 UTC (permalink / raw)
To: gcc-bugs
hi all.
the code snippet below is extracted from a much more
complicated piece of code. basically the problem is that
g++ (3.3 and 3.4) demand different typedef syntax inside
template bodies, depending on whether full or partial
specialization is used.
is this really the correct behaviour and standard conform?
(to me it seems, line20 should still be considered part of
a template and thus accept the "typename")
--------------------snip---------------------
template<class C>
struct Base {
typedef C* Iterator;
};
template<class C, class D>
struct Derived : Base<D> {
typedef typename Base<D>::Iterator Iterator;
};
#define BASE_ITER(BASE) typename BASE :: Iterator
template<class D>
struct Derived<char, D> : Base<D> {
typedef BASE_ITER (Base<D>) Iterator; // line15
};
template<>
struct Derived<char, int> : Base<int> {
typedef BASE_ITER (Base<int>) Iterator; // line20
};
// test.cc:20: error: using `typename' outside of template
--------------------snip---------------------
---
ciaoTJ
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: aren't specialized templates templates?
2005-02-12 16:34 aren't specialized templates templates? Tim Janik
@ 2005-02-13 17:50 ` Gabriel Dos Reis
2005-02-14 0:17 ` Martin Sebor
1 sibling, 0 replies; 3+ messages in thread
From: Gabriel Dos Reis @ 2005-02-13 17:50 UTC (permalink / raw)
To: Tim Janik; +Cc: gcc-bugs
Tim Janik <timj@gtk.org> writes:
| hi all.
|
| the code snippet below is extracted from a much more
| complicated piece of code. basically the problem is that
| g++ (3.3 and 3.4) demand different typedef syntax inside
| template bodies, depending on whether full or partial
| specialization is used.
|
| is this really the correct behaviour and standard conform?
Yes. An explicit specialization is not a template. Therefore line20
is in error.
| (to me it seems, line20 should still be considered part of
| a template and thus accept the "typename")
|
| --------------------snip---------------------
| template<class C>
| struct Base {
| typedef C* Iterator;
| };
|
| template<class C, class D>
| struct Derived : Base<D> {
| typedef typename Base<D>::Iterator Iterator;
| };
|
| #define BASE_ITER(BASE) typename BASE :: Iterator
|
| template<class D>
| struct Derived<char, D> : Base<D> {
| typedef BASE_ITER (Base<D>) Iterator; // line15
| };
|
| template<>
| struct Derived<char, int> : Base<int> {
| typedef BASE_ITER (Base<int>) Iterator; // line20
| };
|
| // test.cc:20: error: using `typename' outside of template
| --------------------snip---------------------
|
|
| ---
| ciaoTJ
|
--
Gabriel Dos Reis
gdr@integrable-solutions.net
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: aren't specialized templates templates?
2005-02-12 16:34 aren't specialized templates templates? Tim Janik
2005-02-13 17:50 ` Gabriel Dos Reis
@ 2005-02-14 0:17 ` Martin Sebor
1 sibling, 0 replies; 3+ messages in thread
From: Martin Sebor @ 2005-02-14 0:17 UTC (permalink / raw)
To: Tim Janik; +Cc: gcc-bugs
Tim Janik wrote:
> hi all.
>
> the code snippet below is extracted from a much more
> complicated piece of code. basically the problem is that
> g++ (3.3 and 3.4) demand different typedef syntax inside
> template bodies, depending on whether full or partial
> specialization is used.
>
> is this really the correct behaviour and standard conform?
> (to me it seems, line20 should still be considered part of
> a template and thus accept the "typename")
Unfortunately, it is the correct behavior. But because it makes
typename hard to use, a relaxation of the rule that would make
your code well-formed is now being considered. For the status
of this proposed change see:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#382
Martin
>
> --------------------snip---------------------
> template<class C>
> struct Base {
> typedef C* Iterator;
> };
>
> template<class C, class D>
> struct Derived : Base<D> {
> typedef typename Base<D>::Iterator Iterator;
> };
>
> #define BASE_ITER(BASE) typename BASE :: Iterator
>
> template<class D>
> struct Derived<char, D> : Base<D> {
> typedef BASE_ITER (Base<D>) Iterator; // line15
> };
>
> template<>
> struct Derived<char, int> : Base<int> {
> typedef BASE_ITER (Base<int>) Iterator; // line20
> };
>
> // test.cc:20: error: using `typename' outside of template
> --------------------snip---------------------
>
>
> ---
> ciaoTJ
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-02-13 17:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-12 16:34 aren't specialized templates templates? Tim Janik
2005-02-13 17:50 ` Gabriel Dos Reis
2005-02-14 0:17 ` Martin Sebor
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).