public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Error compiling program with nested template classes
@ 2003-11-23  0:05 Dara Hazeghi
  0 siblings, 0 replies; 2+ messages in thread
From: Dara Hazeghi @ 2003-11-23  0:05 UTC (permalink / raw)
  To: danmay; +Cc: gcc-help

Hello,

aside from the fact that line 3 should read:
static const int value = 0;

I don't see anything wrong. Intel's C++ accepts it as
valid (with the above change). Perhaps you've found a
bug. You can submit it through gcc's bugzilla.

Dara

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Error compiling program with nested template classes
@ 2003-11-18 22:16 Dan May
  0 siblings, 0 replies; 2+ messages in thread
From: Dan May @ 2003-11-18 22:16 UTC (permalink / raw)
  To: gcc-help

Hello,
   I have been having a problem compiling a program that has a templated 
structure inside of a templated structure.  here is some code that 
generates the compiler errors:

template<class T>
struct traits{
   static const int i = 0;
};

template<int i>
struct outer
{
   template<class T>
   struct inner{
     static void do_something(){
       //perform an action
     }
   };
};

template<class T>
void func(T t){
   outer< ::traits<T>::value>::inner<T>::do_something();
}

int main(int,char**){
   func('c');
}

there error messages are as follows:
temp.cc: In function `void func(T) [with T = char]':
temp.cc:23:   instantiated from here
temp.cc:19: error: type/value mismatch at argument 1 in template 
parameter list
    for `template<int i> struct outer'
temp.cc:19: error:   expected a constant of type `int', got `char'
temp.cc:19: error: type/value mismatch at argument 1 in template 
parameter list
    for `template<int i> template<class T> struct outer<i>::inner'
temp.cc:19: error:   expected a constant of type `int', got `char'
temp.cc:10: confused by earlier errors, bailing out

% gcc --version
gcc (GCC) 3.3.2
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I believe I am passing the correct template parameters.  If anyone could 
show me what I am doing wrong, or, if this is a bug, how to work around 
it I would be grateful.
Thanks,
-Dan May

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-11-23  0:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-23  0:05 Error compiling program with nested template classes Dara Hazeghi
  -- strict thread matches above, loose matches on Subject: below --
2003-11-18 22:16 Dan May

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).