Home > Archive > VC Language > June 2005 > Member template internal compiler error
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Member template internal compiler error
|
|
| Kristo 2005-06-02, 4:01 pm |
| I am getting an Internal Compiler Error in VC++ 6 with the following code.
I'm fairly sure it is well-formed (g++ 3.4.2 compiles it fine). Is there a
workaround available?
#include <iostream>
#include <ostream>
class Foo
{
public:
template <int N>
static void Test()
{
std::cout << N << std::endl;
}
};
int main()
{
Foo::Test<5>(); /* I.C.E. here */
}
Thanks for any help you can provide.
Kristo
| |
| Victor Bazarov 2005-06-02, 4:01 pm |
| Kristo wrote:
> I am getting an Internal Compiler Error in VC++ 6 with the following code.
> I'm fairly sure it is well-formed (g++ 3.4.2 compiles it fine). Is there a
> workaround available?
>
> #include <iostream>
> #include <ostream>
>
> class Foo
> {
> public:
> template <int N>
> static void Test()
> {
> std::cout << N << std::endl;
> }
> };
>
> int main()
> {
> Foo::Test<5>(); /* I.C.E. here */
> }
VC++ v6 is notoriously bad with templates. You'll be much better off when
you upgrade to the later compiler (7.1 is currently shipping). For now,
if you can, make this static member non-member but a simple free-standing
function template.
V
| |
| Mycroft Holmes 2005-06-03, 4:02 pm |
| ----- Original Message -----
From: "Kristo" <Kristo@discussions.microsoft.com>
Newsgroups: microsoft.public.vc.language
Sent: Thursday, June 02, 2005 19:01
Subject: Member template internal compiler error
>I am getting an Internal Compiler Error in VC++ 6 with the following code.
> I'm fairly sure it is well-formed (g++ 3.4.2 compiles it fine). Is there
> a
> workaround available?
this should work: maybe it's not what you mean to do, but other workarounds
are dangerous in VC6
template <int N>
struct placeholder
{
};
class Foo
{
public:
template <int N>
static void Test(placeholder<N> )
{
std::cout << N << std::endl;
}
};
int main()
{
Foo::Test(placeholder<5>());
return 0;
}
|
|
|
|
|